Skip to content

Commit

Permalink
Added Support to runtime render bgp and teamd feature state and lldp …
Browse files Browse the repository at this point in the history
…has_asic_scope flag (sonic-net#11796)

Added Support to runtime render bgp and teamd feature `state` and lldp `has_asic_scope`  flag
Needed for SONiC on chassis.

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
Co-authored-by: mlok <marty.lok@nokia.com>
  • Loading branch information
abdosi and mlok-nokia committed Nov 28, 2022
1 parent 80837d4 commit 2996bb9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
10 changes: 7 additions & 3 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"tsa_enabled": "false"
}
},
{%- set features = [("bgp", "enabled", false, "enabled"),
{%- set features = [("bgp", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}disabled{% else %}enabled{% endif %}", false, "enabled"),
("database", "always_enabled", false, "always_enabled"),
("lldp", "enabled", true, "enabled"),
("pmon", "enabled", true, "enabled"),
Expand All @@ -41,7 +41,7 @@
("snmp", "enabled", true, "enabled"),
("swss", "enabled", false, "enabled"),
("syncd", "enabled", false, "enabled"),
("teamd", "enabled", false, "enabled")] %}
("teamd", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] %}disabled{% else %}enabled{% endif %}", false, "enabled")] %}
{% do features.append(("dhcp_relay", "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] is not in ['ToRRouter', 'EPMS', 'MgmtTsToR', 'MgmtToRRouter', 'BmcMgmtToRRouter']) %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
Expand All @@ -60,7 +60,11 @@
"state": "{{state}}",
"has_timer" : {{has_timer | lower()}},
"has_global_scope": {% if feature + '.service' in installer_services.split(' ') %}true{% else %}false{% endif %},
"has_per_asic_scope": {% if feature + '@.service' in installer_services.split(' ') %}true{% else %}false{% endif %},
{%- if feature in ["lldp"] %}
"has_per_asic_scope": {% raw %}"{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}"{% endraw %},
{%- else %}
"has_per_asic_scope": {% if feature + '@.service' in installer_services.split(' ') %}"True"{% else %}"False"{% endif %},
{%- endif %}
"auto_restart": "{{autorestart}}",
{# Set check_up_status to true here when app readiness will be marked in state db #}
{# For now, to support the infrastrucure, setting the check_up_status to false for bgp,swss,pmon #}
Expand Down
33 changes: 27 additions & 6 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ LOCKFILE="/tmp/swss-syncd-lock$DEV"
NAMESPACE_PREFIX="asic"
ETC_SONIC_PATH="/etc/sonic/"

# DEPENDENT initially contains namespace independent services
# namespace specific services are added later in this script.
DEPENDENT="radv"
MULTI_INST_DEPENDENT="teamd"

. /usr/local/bin/asic_status.sh

Expand Down Expand Up @@ -299,8 +295,6 @@ stop() {

function check_peer_gbsyncd()
{
PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
HWSKU=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' hwsku`
GEARBOX_CONFIG=/usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV/gearbox_config.json

if [ -f $GEARBOX_CONFIG ]; then
Expand All @@ -321,6 +315,22 @@ function check_macsec()
fi
}

function check_ports_present()
{
PORT_CONFIG_INI=/usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV/port_config.ini
HWSKU_JSON=/usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV/hwsku.json

if [[ -f $PORT_CONFIG_INI ]] || [[ -f $HWSKU_JSON ]]; then
return 0
fi
return 1
}

# DEPENDENT initially contains namespace independent services
# namespace specific services are added later in this script.
DEPENDENT="radv"
MULTI_INST_DEPENDENT=""

if [ "$DEV" ]; then
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
SONIC_DB_CLI="sonic-db-cli -n $NET_NS"
Expand All @@ -331,8 +341,19 @@ else
DEPENDENT+=" bgp"
fi

PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
HWSKU=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' hwsku`

check_peer_gbsyncd
check_macsec

check_ports_present
PORTS_PRESENT=$?

if [[ $PORTS_PRESENT == 0 ]]; then
MULTI_INST_DEPENDENT="teamd"
fi

read_dependent_services

case "$1" in
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@
"lldp": {
"auto_restart": "enabled",
"has_global_scope": "false",
"has_per_asic_scope": "true",
"has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}",
"has_timer": "false",
"high_mem_alert": "disabled",
"state": "enabled",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"auto_restart": "disabled",
"has_timer": "false",
"has_global_scope": "false",
"has_per_asic_scope": "true",
"has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}",
"set_owner": "kube"
},
{
Expand All @@ -71,7 +71,7 @@
"auto_restart": "disabled",
"has_timer": "false",
"has_global_scope": "false",
"has_per_asic_scope": "true",
"has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}",
"set_owner": "invalid"
}
]
Expand All @@ -88,7 +88,7 @@
"auto_restart": "disabled",
"has_timer": "false",
"has_global_scope": "false",
"has_per_asic_scope": "true"
"has_per_asic_scope": "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}False{% else %}True{% endif %}"
}
]
}
Expand Down
7 changes: 6 additions & 1 deletion src/sonic-yang-models/yang-models/sonic-feature.yang
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ module sonic-feature{
}
}

typedef feature-scope-status {
description "configuration to set the feature has asic scope as true/false";
type string;
}

container sonic-feature {

container FEATURE {
Expand Down Expand Up @@ -69,7 +74,7 @@ module sonic-feature{
leaf has_per_asic_scope {
description "This configuration identicates there will only one service
spawned per asic";
type stypes:boolean_type;
type feature-scope-status;
default "false";
}

Expand Down

0 comments on commit 2996bb9

Please sign in to comment.