From 1f81544483a1f1a006ea88238d52c10935fd2f5a Mon Sep 17 00:00:00 2001 From: Judy Joseph Date: Tue, 14 Jun 2022 13:03:57 -0700 Subject: [PATCH 1/2] Update the feature table in STATE_DB in database running in namespace for multi-asic platforms. This will be used by features running in namesapces Also add the support to enable macsec when type is SpineRouter --- files/build_templates/init_cfg.json.j2 | 2 +- src/sonic-host-services/scripts/hostcfgd | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index a197c22a9020..0ea859e6b6c3 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -46,7 +46,7 @@ {%- if include_p4rt == "y" %}{% do features.append(("p4rt", "enabled", false, "enabled")) %}{% endif %} {%- if include_restapi == "y" %}{% do features.append(("restapi", "enabled", false, "enabled")) %}{% endif %} {%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %} -{%- if include_macsec == "y" %}{% do features.append(("macsec", "disabled", false, "enabled")) %}{% endif %} +{%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %} {%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %} "FEATURE": { {# has_timer field if set, will start the feature systemd .timer unit instead of .service unit #} diff --git a/src/sonic-host-services/scripts/hostcfgd b/src/sonic-host-services/scripts/hostcfgd index 41da37490be4..c21cfc730930 100755 --- a/src/sonic-host-services/scripts/hostcfgd +++ b/src/sonic-host-services/scripts/hostcfgd @@ -11,7 +11,7 @@ import signal import jinja2 from sonic_py_common import device_info -from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table +from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table, SonicDBConfig # FILE PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic" @@ -399,6 +399,12 @@ class FeatureHandler(object): def set_feature_state(self, feature, state): self._feature_state_table.set(feature.name, [('state', state)]) + # Update the feature state in STATE_DB in namespaces in multi-asic platform + namespaces = device_info.get_namespaces() + for namespace in namespaces: + db_conn = DBConnector(STATE_DB, 0, False, namespace); + feature_state_tbl = Table(db_conn, 'FEATURE') + feature_state_tbl.set(feature.name, [('state', state)]) class Iptables(object): def __init__(self): @@ -1086,6 +1092,10 @@ class HostConfigDaemon: self.is_multi_npu = device_info.is_multi_npu() + # Initlaize Global config that loads all database*.json + if self.is_multi_npu: + SonicDBConfig.initializeGlobalConfig() + # Initialize AAACfg self.hostname_cache="" self.aaacfg = AaaCfg() From 206392f8ac465d71f73461a0222efd0a24de1fea Mon Sep 17 00:00:00 2001 From: Judy Joseph Date: Tue, 21 Jun 2022 19:23:37 -0700 Subject: [PATCH 2/2] Revert the change to update the FEATURE state in STATE_DB of namespace databases. --- src/sonic-host-services/scripts/hostcfgd | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/sonic-host-services/scripts/hostcfgd b/src/sonic-host-services/scripts/hostcfgd index c21cfc730930..41da37490be4 100755 --- a/src/sonic-host-services/scripts/hostcfgd +++ b/src/sonic-host-services/scripts/hostcfgd @@ -11,7 +11,7 @@ import signal import jinja2 from sonic_py_common import device_info -from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table, SonicDBConfig +from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table # FILE PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic" @@ -399,12 +399,6 @@ class FeatureHandler(object): def set_feature_state(self, feature, state): self._feature_state_table.set(feature.name, [('state', state)]) - # Update the feature state in STATE_DB in namespaces in multi-asic platform - namespaces = device_info.get_namespaces() - for namespace in namespaces: - db_conn = DBConnector(STATE_DB, 0, False, namespace); - feature_state_tbl = Table(db_conn, 'FEATURE') - feature_state_tbl.set(feature.name, [('state', state)]) class Iptables(object): def __init__(self): @@ -1092,10 +1086,6 @@ class HostConfigDaemon: self.is_multi_npu = device_info.is_multi_npu() - # Initlaize Global config that loads all database*.json - if self.is_multi_npu: - SonicDBConfig.initializeGlobalConfig() - # Initialize AAACfg self.hostname_cache="" self.aaacfg = AaaCfg()