diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 0eafc00f0826..9a4b82c45939 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -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"), @@ -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 %} @@ -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 #} diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index e0c9d2d3f94d..7b913476deb1 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -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 @@ -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 @@ -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" @@ -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 diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index e8fd8aec376e..fbf6aa198bae 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -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", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json index 82e403cb147c..33b0ecbfce07 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json @@ -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" }, { @@ -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" } ] @@ -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 %}" } ] } diff --git a/src/sonic-yang-models/yang-models/sonic-feature.yang b/src/sonic-yang-models/yang-models/sonic-feature.yang index 54133ef10612..8358b8952f01 100644 --- a/src/sonic-yang-models/yang-models/sonic-feature.yang +++ b/src/sonic-yang-models/yang-models/sonic-feature.yang @@ -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 { @@ -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"; }