Skip to content

Commit

Permalink
create init_cfg.json.j2 template for vs
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak committed Jun 11, 2021
1 parent a441c39 commit a253498
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
1 change: 1 addition & 0 deletions platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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/"]
Expand Down
17 changes: 17 additions & 0 deletions platform/vs/docker-sonic-vs/init_cfg.json.j2
Original file line number Diff line number Diff line change
@@ -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 %}
}
}

26 changes: 1 addition & 25 deletions platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +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}')
cat <<EOF > /tmp/init_cfg.json
{
"DEVICE_METADATA": {
"localhost": {
"mac": "$SYSTEM_MAC_ADDRESS",
"buffer_model": "traditional"
}
},
"FEATURE": {
"swss": {
"state": "enabled"
},
"bgp": {
"state": "enabled"
},
"teamd": {
"state": "enabled"
},
"nat": {
"state": "enabled"
}
}
}
EOF
sonic-cfggen -j /tmp/init_cfg.json $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
Expand Down

0 comments on commit a253498

Please sign in to comment.