diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py b/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py index ce3f60fad144..cb47d1976493 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py @@ -107,6 +107,7 @@ def __init__(self, common_objs, db_name, table_name, peer_type, check_neig_meta) deps = [ ("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/bgp_asn"), + ("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"), ("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback0"), ("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "tsa_enabled"), ("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "idf_isolation_state"), diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_device_global.py b/src/sonic-bgpcfgd/bgpcfgd/managers_device_global.py index 26c0a1ee69fc..30ff726cb597 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_device_global.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_device_global.py @@ -19,8 +19,8 @@ def __init__(self, common_objs, db, table): :param common_objs: common object dictionary :param db: name of the db :param table: name of the table in the db - """ - self.switch_type = "" + """ + self.switch_role = "" self.chassis_tsa = "" self.directory = common_objs['directory'] self.cfg_mgr = common_objs['cfg_mgr'] @@ -29,8 +29,8 @@ def __init__(self, common_objs, db, table): self.tsb_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.unisolate.conf.j2") self.wcmp_template = common_objs['tf'].from_file("bgpd/wcmp/bgpd.wcmp.conf.j2") self.idf_isolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_isolate.conf.j2") - self.idf_unisolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_unisolate.conf.j2") - self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"),], self.on_switch_type_change) + self.idf_unisolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_unisolate.conf.j2") + self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"),], self.handle_type_update) super(DeviceGlobalCfgMgr, self).__init__( common_objs, [], @@ -48,18 +48,16 @@ def __init__(self, common_objs, db, table): if not self.directory.path_exist(self.db_name, self.table_name, "idf_isolation_state"): self.directory.put(self.db_name, self.table_name, "idf_isolation_state", self.IDF_DEFAULTS) - def on_switch_type_change(self): - log_debug("DeviceGlobalCfgMgr:: Switch type update handler") - if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"): - self.switch_type = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["switch_type"] - log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type) + def handle_type_update(self): + log_debug("DeviceGlobalCfgMgr:: Switch role update handler") + if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"): + self.switch_role = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["type"] + log_debug("DeviceGlobalCfgMgr:: Switch role: %s" % self.switch_role) def set_handler(self, key, data): """ Handle device TSA/W-ECMP state change """ log_debug("DeviceGlobalCfgMgr:: set handler") - if self.switch_type: - log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type) if not data: log_err("DeviceGlobalCfgMgr:: data is None") return False @@ -259,8 +257,8 @@ def downstream_isolate_unisolate(self, idf_isolation_state): log_err("IDF: invalid value({}) is provided".format(idf_isolation_state)) return False - if self.switch_type and self.switch_type != "SpineRouter": - log_debug("DeviceGlobalCfgMgr:: Skipping IDF isolation configuration on Switch type: %s" % self.switch_type) + if self.switch_role and self.switch_role != "SpineRouter": + log_debug("DeviceGlobalCfgMgr:: Skipping IDF isolation configuration on %s" % self.switch_role) return True cmd = "\n"