diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index ea8fdea5b5..04f3e44167 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -35,16 +35,24 @@ RUN useradd -u ${frr_user_uid} -g ${frr_user_gid} -M -s /bin/false frr {{ install_debian_packages(docker_fpm_frr_debs.split(' ')) }} {%- endif %} +{% if docker_fpm_frr_whls.strip() %} +# Copy locally-built Python wheel dependencies +{{ copy_files("python-wheels/", docker_fpm_frr_whls.split(' '), "/python-wheels/") }} + +# Install locally-built Python wheel dependencies +{{ install_python_wheels(docker_fpm_frr_whls.split(' ')) }} +{% endif %} + RUN chown -R ${frr_user_uid}:${frr_user_gid} /etc/frr/ # Clean up RUN apt-get clean -y && \ apt-get autoclean -y && \ apt-get autoremove -y && \ - rm -rf /debs ~/.cache + rm -rf /debs ~/.cache /python-wheels COPY ["frr", "/usr/share/sonic/templates"] -COPY ["bgpcfgd", "start.sh", "/usr/bin/"] +COPY ["start.sh", "/usr/bin/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["snmp.conf", "/etc/snmp/frr.conf"] COPY ["TSA", "/usr/bin/TSA"] diff --git a/dockers/docker-fpm-frr/base_image_files/monit_bgp b/dockers/docker-fpm-frr/base_image_files/monit_bgp index 5b943ea7c0..5dbb794c34 100644 --- a/dockers/docker-fpm-frr/base_image_files/monit_bgp +++ b/dockers/docker-fpm-frr/base_image_files/monit_bgp @@ -19,5 +19,5 @@ check process bgpd matching "/usr/lib/frr/bgpd" check process staticd matching "/usr/lib/frr/staticd" if does not exist for 5 times within 5 cycles then alert -check process bgpcfgd matching "python /usr/bin/bgpcfgd" +check process bgpcfgd matching "python /usr/local/bin/bgpcfgd" if does not exist for 5 times within 5 cycles then alert diff --git a/dockers/docker-fpm-frr/supervisord.conf b/dockers/docker-fpm-frr/supervisord.conf index 3e544b64b2..316662cdd0 100644 --- a/dockers/docker-fpm-frr/supervisord.conf +++ b/dockers/docker-fpm-frr/supervisord.conf @@ -64,8 +64,8 @@ startsecs=0 stdout_logfile=syslog stderr_logfile=syslog -[program:vtysh_b] -command=/usr/bin/vtysh -b +[program:fpmsyncd] +command=fpmsyncd priority=6 autostart=false autorestart=false @@ -73,8 +73,17 @@ startsecs=0 stdout_logfile=syslog stderr_logfile=syslog -[program:fpmsyncd] -command=fpmsyncd +[program:bgpcfgd] +command=/usr/local/bin/bgpcfgd +priority=6 +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog + +[program:vtysh_b] +command=/usr/bin/vtysh -b priority=6 autostart=false autorestart=false diff --git a/rules/docker-fpm-frr.mk b/rules/docker-fpm-frr.mk index 45a755a928..ad6613a685 100644 --- a/rules/docker-fpm-frr.mk +++ b/rules/docker-fpm-frr.mk @@ -5,6 +5,7 @@ DOCKER_FPM_FRR = $(DOCKER_FPM_FRR_STEM).gz DOCKER_FPM_FRR_DBG = $(DOCKER_FPM_FRR_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM) +$(DOCKER_FPM_FRR)_PYTHON_WHEELS += $(SONIC_BGPCFGD) $(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG) $(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) diff --git a/rules/sonic_bgpcfgd.dep b/rules/sonic_bgpcfgd.dep new file mode 100644 index 0000000000..abd51062b8 --- /dev/null +++ b/rules/sonic_bgpcfgd.dep @@ -0,0 +1,10 @@ + +SPATH := $($(SONIC_BGPCFGD)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic_bgpcfgd.mk rules/sonic_bgpcfgd.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(SPATH)) + +$(SONIC_BGPCFGD)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_BGPCFGD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_BGPCFGD)_DEP_FILES := $(DEP_FILES) + diff --git a/rules/sonic_bgpcfgd.mk b/rules/sonic_bgpcfgd.mk new file mode 100644 index 0000000000..650874b619 --- /dev/null +++ b/rules/sonic_bgpcfgd.mk @@ -0,0 +1,7 @@ +# sonic-bgpcfgd package + +SONIC_BGPCFGD = sonic_bgpcfgd-1.0-py2-none-any.whl +$(SONIC_BGPCFGD)_SRC_PATH = $(SRC_PATH)/sonic-bgpcfgd +$(SONIC_BGPCFGD)_DEPENDS += $(SWSSSDK_PY2) +$(SONIC_BGPCFGD)_PYTHON_VERSION = 2 +SONIC_PYTHON_WHEELS += $(SONIC_BGPCFGD) diff --git a/src/sonic-bgpcfgd/.gitignore b/src/sonic-bgpcfgd/.gitignore new file mode 100644 index 0000000000..013f588165 --- /dev/null +++ b/src/sonic-bgpcfgd/.gitignore @@ -0,0 +1,6 @@ +.eggs/ +build/ +dist/ +*.egg-info/ +tests/*.pyc +tests/__pycache__/ diff --git a/dockers/docker-fpm-frr/bgpcfgd b/src/sonic-bgpcfgd/bgpcfgd similarity index 100% rename from dockers/docker-fpm-frr/bgpcfgd rename to src/sonic-bgpcfgd/bgpcfgd diff --git a/src/sonic-bgpcfgd/setup.cfg b/src/sonic-bgpcfgd/setup.cfg new file mode 100644 index 0000000000..00ed5efbcb --- /dev/null +++ b/src/sonic-bgpcfgd/setup.cfg @@ -0,0 +1,5 @@ +[aliases] +test=pytest +[tool:pytest] +addopts = --verbose +python_files = tests/*.py diff --git a/src/sonic-bgpcfgd/setup.py b/src/sonic-bgpcfgd/setup.py new file mode 100755 index 0000000000..2aea5cdb0c --- /dev/null +++ b/src/sonic-bgpcfgd/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup(name='sonic-bgpcfgd', + version='1.0', + description='Utility to dynamically generate BGP configuration for FRR', + author='Pavel Shirshov', + author_email='pavelsh@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + scripts=['bgpcfgd'], + install_requires=['jinja2>=2.10', 'netaddr', 'pyyaml'], + setup_requires=['pytest-runner', 'pytest'], +) diff --git a/src/sonic-bgpcfgd/tests/__init__.py b/src/sonic-bgpcfgd/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/sonic-bgpcfgd/tests/test_sample.py b/src/sonic-bgpcfgd/tests/test_sample.py new file mode 100644 index 0000000000..3adfe439d2 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_sample.py @@ -0,0 +1,4 @@ +import pytest + +def test_sample(): + assert True