From 159e69f3464450f0e4eeaf3f5416cc4f5560a0dd Mon Sep 17 00:00:00 2001 From: Prabhu Sreenivasan Date: Tue, 18 Jun 2019 21:03:47 -0700 Subject: [PATCH 1/4] Added sonic-mgmt-framework as submodule / docker --- .gitmodules | 3 ++ .../docker-sonic-mgmt-framework/Dockerfile.j2 | 34 +++++++++++++++++++ .../rest-server.sh | 7 ++++ dockers/docker-sonic-mgmt-framework/start.sh | 10 ++++++ .../supervisord.conf | 28 +++++++++++++++ .../build_templates/mgmt-framework.service.j2 | 14 ++++++++ rules/docker-sonic-mgmt-framework.mk | 22 ++++++++++++ rules/sonic-mgmt-framework.mk | 5 +++ src/sonic-mgmt-framework | 1 + 9 files changed, 124 insertions(+) create mode 100644 dockers/docker-sonic-mgmt-framework/Dockerfile.j2 create mode 100755 dockers/docker-sonic-mgmt-framework/rest-server.sh create mode 100755 dockers/docker-sonic-mgmt-framework/start.sh create mode 100644 dockers/docker-sonic-mgmt-framework/supervisord.conf create mode 100644 files/build_templates/mgmt-framework.service.j2 create mode 100644 rules/docker-sonic-mgmt-framework.mk create mode 100644 rules/sonic-mgmt-framework.mk create mode 160000 src/sonic-mgmt-framework diff --git a/.gitmodules b/.gitmodules index 3d2a8e3f7a1d..908b70834d51 100644 --- a/.gitmodules +++ b/.gitmodules @@ -66,3 +66,6 @@ [submodule "platform/mellanox/mlnx-sai/SAI-Implementation"] path = platform/mellanox/mlnx-sai/SAI-Implementation url = https://github.com/Mellanox/SAI-Implementation +[submodule "src/sonic-mgmt-framework"] + path = src/sonic-mgmt-framework + url = https://github.com/project-arlo/sonic-mgmt-framework.git diff --git a/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 new file mode 100644 index 000000000000..a181020d6b43 --- /dev/null +++ b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 @@ -0,0 +1,34 @@ +FROM docker-config-engine-stretch + +ARG docker_container_name +RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +#RUN apt-get install -f -y libdbus-1-3 libdaemon0 libjansson4 + +## Install redis-tools dependencies +## TODO: implicitly install dependencies +RUN apt-get -y install libjemalloc1 + +COPY \ +{% for deb in docker_sonic_mgmt_framework_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor -%} +debs/ + +RUN dpkg -i \ +{% for deb in docker_sonic_mgmt_framework_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor %} + +COPY ["start.sh", "rest-server.sh", "/usr/bin/"] +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] + +RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y +RUN rm -rf /debs + +ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/dockers/docker-sonic-mgmt-framework/rest-server.sh b/dockers/docker-sonic-mgmt-framework/rest-server.sh new file mode 100755 index 000000000000..ebc4193a39c4 --- /dev/null +++ b/dockers/docker-sonic-mgmt-framework/rest-server.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +REST_SERVER_ARGS=" -ui /rest_ui -port=80 -logtostderr" + +exec /usr/sbin/rest_server ${REST_SERVER_ARGS} + + diff --git a/dockers/docker-sonic-mgmt-framework/start.sh b/dockers/docker-sonic-mgmt-framework/start.sh new file mode 100755 index 000000000000..24d355670e87 --- /dev/null +++ b/dockers/docker-sonic-mgmt-framework/start.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +mkdir -p /var/sonic +echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status + +rm -f /var/run/rsyslogd.pid + +supervisorctl start rsyslogd + +supervisorctl start rest-server diff --git a/dockers/docker-sonic-mgmt-framework/supervisord.conf b/dockers/docker-sonic-mgmt-framework/supervisord.conf new file mode 100644 index 000000000000..e26f815f5fb9 --- /dev/null +++ b/dockers/docker-sonic-mgmt-framework/supervisord.conf @@ -0,0 +1,28 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[program:start.sh] +command=/usr/bin/start.sh +priority=1 +autostart=true +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n +priority=2 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog + +[program:rest-server] +command=/usr/bin/rest-server.sh +priority=3 +autostart=false +autorestart=true +stdout_logfile=syslog +stderr_logfile=syslog diff --git a/files/build_templates/mgmt-framework.service.j2 b/files/build_templates/mgmt-framework.service.j2 new file mode 100644 index 000000000000..d0a030347b51 --- /dev/null +++ b/files/build_templates/mgmt-framework.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Management Framework container +Requires=swss.service +After=swss.service +Before=ntp-config.service + +[Service] +User={{ sonicadmin_user }} +ExecStartPre=/usr/bin/{{docker_container_name}}.sh start +ExecStart=/usr/bin/{{docker_container_name}}.sh wait +ExecStop=/usr/bin/{{docker_container_name}}.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/rules/docker-sonic-mgmt-framework.mk b/rules/docker-sonic-mgmt-framework.mk new file mode 100644 index 000000000000..f963a77251ad --- /dev/null +++ b/rules/docker-sonic-mgmt-framework.mk @@ -0,0 +1,22 @@ +# docker image for mgmt-framework + +DOCKER_MGMT-FRAMEWORK_STEM = docker-sonic-mgmt-framework +DOCKER_MGMT-FRAMEWORK = $(DOCKER_MGMT-FRAMEWORK_STEM).gz +DOCKER_MGMT-FRAMEWORK_DBG = $(DOCKER_MGMT-FRAMEWORK_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_MGMT-FRAMEWORK)_PATH = $(DOCKERS_PATH)/$(DOCKER_MGMT-FRAMEWORK_STEM) + +$(DOCKER_MGMT-FRAMEWORK)_DEPENDS += $(REDIS_TOOLS) $(SONIC_MGMT-FRAMEWORK) +$(DOCKER_MGMT-FRAMEWORK)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) + +SONIC_DOCKER_IMAGES += $(DOCKER_MGMT-FRAMEWORK) +$(DOCKER_MGMT-FRAMEWORK)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) +$(DOCKER_MGMT-FRAMEWORK)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_MGMT-FRAMEWORK) +SONIC_STRETCH_DOCKERS += $(DOCKER_MGMT-FRAMEWORK) + +$(DOCKER_MGMT-FRAMEWORK)_CONTAINER_NAME = mgmt-framework +$(DOCKER_MGMT-FRAMEWORK)_RUN_OPT += --net=host --privileged -t +$(DOCKER_MGMT-FRAMEWORK)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + diff --git a/rules/sonic-mgmt-framework.mk b/rules/sonic-mgmt-framework.mk new file mode 100644 index 000000000000..c74ad5757e8b --- /dev/null +++ b/rules/sonic-mgmt-framework.mk @@ -0,0 +1,5 @@ +# SONiC mgmt-framework package + +SONIC_MGMT-FRAMEWORK = sonic-mgmt-framework_1.0-01_amd64.deb +$(SONIC_MGMT-FRAMEWORK)_SRC_PATH = $(SRC_PATH)/sonic-mgmt-framework +SONIC_DPKG_DEBS += $(SONIC_MGMT-FRAMEWORK) diff --git a/src/sonic-mgmt-framework b/src/sonic-mgmt-framework new file mode 160000 index 000000000000..6dd9125f1f0a --- /dev/null +++ b/src/sonic-mgmt-framework @@ -0,0 +1 @@ +Subproject commit 6dd9125f1f0a5dc950857676239497b885b17b3e From 3a8ef73d0e9a39db42510a08ff2896b52afc590b Mon Sep 17 00:00:00 2001 From: Prabhu Sreenivasan Date: Wed, 19 Jun 2019 11:01:06 -0700 Subject: [PATCH 2/4] fix build issues --- dockers/docker-sonic-mgmt-framework/Dockerfile.j2 | 2 +- rules/docker-sonic-mgmt-framework.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 index a181020d6b43..c38e0b4d2970 100644 --- a/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt-framework/Dockerfile.j2 @@ -1,4 +1,4 @@ -FROM docker-config-engine-stretch +FROM {{ docker_sonic_mgmt_framework_load_image }} ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/rules/docker-sonic-mgmt-framework.mk b/rules/docker-sonic-mgmt-framework.mk index f963a77251ad..8e973da313b4 100644 --- a/rules/docker-sonic-mgmt-framework.mk +++ b/rules/docker-sonic-mgmt-framework.mk @@ -7,11 +7,11 @@ DOCKER_MGMT-FRAMEWORK_DBG = $(DOCKER_MGMT-FRAMEWORK_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_MGMT-FRAMEWORK)_PATH = $(DOCKERS_PATH)/$(DOCKER_MGMT-FRAMEWORK_STEM) $(DOCKER_MGMT-FRAMEWORK)_DEPENDS += $(REDIS_TOOLS) $(SONIC_MGMT-FRAMEWORK) -$(DOCKER_MGMT-FRAMEWORK)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +#$(DOCKER_MGMT-FRAMEWORK)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) SONIC_DOCKER_IMAGES += $(DOCKER_MGMT-FRAMEWORK) $(DOCKER_MGMT-FRAMEWORK)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) -$(DOCKER_MGMT-FRAMEWORK)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) +#$(DOCKER_MGMT-FRAMEWORK)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_MGMT-FRAMEWORK) SONIC_STRETCH_DOCKERS += $(DOCKER_MGMT-FRAMEWORK) From 477f233ca6b91592da555af85e9d7d642967505c Mon Sep 17 00:00:00 2001 From: Prabhu Sreenivasan Date: Wed, 19 Jun 2019 12:04:36 -0700 Subject: [PATCH 3/4] update sonic-mgmt-framework submodule branch to master --- src/sonic-mgmt-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-mgmt-framework b/src/sonic-mgmt-framework index 6dd9125f1f0a..13c9cf139a8e 160000 --- a/src/sonic-mgmt-framework +++ b/src/sonic-mgmt-framework @@ -1 +1 @@ -Subproject commit 6dd9125f1f0a5dc950857676239497b885b17b3e +Subproject commit 13c9cf139a8ee438b2f62ccd54bcc4b3762bcb9b From 3d804a49d7dfe65eefd3c21585264a6aa9329df6 Mon Sep 17 00:00:00 2001 From: Partha Dutta Date: Fri, 21 Jun 2019 23:55:09 -0700 Subject: [PATCH 4/4] Merged changes 70007e6d2ba3a4c0b371cd693ccc63e0a8906e77..00d4fcfed6a759e40d7b92120ea0ee1f08300fc6 00d4fcfed6a759e40d7b92120ea0ee1f08300fc6 Modified environemnt variables --- dockers/docker-sonic-mgmt-framework/rest-server.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dockers/docker-sonic-mgmt-framework/rest-server.sh b/dockers/docker-sonic-mgmt-framework/rest-server.sh index ebc4193a39c4..0fec2c7fa2a6 100755 --- a/dockers/docker-sonic-mgmt-framework/rest-server.sh +++ b/dockers/docker-sonic-mgmt-framework/rest-server.sh @@ -2,6 +2,11 @@ REST_SERVER_ARGS=" -ui /rest_ui -port=80 -logtostderr" -exec /usr/sbin/rest_server ${REST_SERVER_ARGS} - +#export LIBYANG_EXTENSIONS_PLUGINS_DIR +export CVL_SCHEMA_PATH=/usr/sbin/schema +export LIBYANG_EXTENSIONS_PLUGINS_DIR=/usr/sbin/lib +export LIBYANG_USER_TYPES_PLUGINS_DIR=/usr/sbin/lib +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PATH:/usr/sbin/lib +exec /usr/sbin/rest_server ${REST_SERVER_ARGS} +#while [ true ]; do sleep 1; done