From 3e909014f9dc1c89957a31d912717de4b6e4c0fd Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Wed, 23 Jun 2021 20:18:55 +0300 Subject: [PATCH] [vs] add information about features to config db (#7857) vs has components from swss, bgp, teamd and nat. This table is needed by this change https://github.com/Azure/sonic-utilities/pull/1554. Because Azure/sonic-utilities#1554 requires "config warm_restart enable FEATURE" and the FEATURE has to be in feature table. Signed-off-by: Stepan Blyschak --- platform/vs/docker-sonic-vs/Dockerfile.j2 | 1 + platform/vs/docker-sonic-vs/init_cfg.json.j2 | 17 +++++++++++++++++ platform/vs/docker-sonic-vs/start.sh | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 platform/vs/docker-sonic-vs/init_cfg.json.j2 diff --git a/platform/vs/docker-sonic-vs/Dockerfile.j2 b/platform/vs/docker-sonic-vs/Dockerfile.j2 index 4313d84a23..2e11cdaea3 100644 --- a/platform/vs/docker-sonic-vs/Dockerfile.j2 +++ b/platform/vs/docker-sonic-vs/Dockerfile.j2 @@ -168,6 +168,7 @@ COPY ["files/sonic_version.yml", "/etc/sonic/"] COPY ["port_breakout_config_db.json", "/etc/sonic/"] COPY ["database_config.json", "/etc/default/sonic-db/"] COPY ["hostname.j2", "/usr/share/sonic/templates/"] +COPY ["init_cfg.json.j2", "/usr/share/sonic/templates/"] COPY ["default_chassis_cfg.json", "/etc/default/sonic-db/"] COPY ["asic_table.json", "/etc/sonic/"] COPY ["buffermgrd.sh", "/usr/bin/"] diff --git a/platform/vs/docker-sonic-vs/init_cfg.json.j2 b/platform/vs/docker-sonic-vs/init_cfg.json.j2 new file mode 100644 index 0000000000..0b2ce51242 --- /dev/null +++ b/platform/vs/docker-sonic-vs/init_cfg.json.j2 @@ -0,0 +1,17 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "mac": "{{ system_mac }}", + "buffer_model": "traditional" + } + }, +{% set features = ["swss", "bgp", "teamd", "nat", "database"] %} + "FEATURE": { +{% for feature in features %} + "{{ feature }}": { + "state": "enabled" + }{% if not loop.last %},{% endif %} +{% endfor %} + } +} + diff --git a/platform/vs/docker-sonic-vs/start.sh b/platform/vs/docker-sonic-vs/start.sh index b4adbc2fd3..2d771a3cc6 100755 --- a/platform/vs/docker-sonic-vs/start.sh +++ b/platform/vs/docker-sonic-vs/start.sh @@ -37,7 +37,7 @@ mkdir -p /var/run/redis/sonic-db cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/ SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') -sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "buffer_model": "traditional"}}}' $CHASS_CFG --print-data > /etc/sonic/init_cfg.json +sonic-cfggen -t /usr/share/sonic/templates/init_cfg.json.j2 -a "{\"system_mac\": \"$SYSTEM_MAC_ADDRESS\"}" $CHASS_CFG > /etc/sonic/init_cfg.json if [ -f /etc/sonic/config_db.json ]; then sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --print-data > /tmp/config_db.json