Skip to content

Commit 694b338

Browse files
tjchadagapull[bot]
authored andcommitted
Fixed switch role check for IDF isolation configuration (#19543)
Fixed switch role check for IDF isolation configuration
1 parent 1f1a114 commit 694b338

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def __init__(self, common_objs, db_name, table_name, peer_type, check_neig_meta)
107107

108108
deps = [
109109
("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/bgp_asn"),
110+
("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"),
110111
("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback0"),
111112
("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "tsa_enabled"),
112113
("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "idf_isolation_state"),

src/sonic-bgpcfgd/bgpcfgd/managers_device_global.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def __init__(self, common_objs, db, table):
1919
:param common_objs: common object dictionary
2020
:param db: name of the db
2121
:param table: name of the table in the db
22-
"""
23-
self.switch_type = ""
22+
"""
23+
self.switch_role = ""
2424
self.chassis_tsa = ""
2525
self.directory = common_objs['directory']
2626
self.cfg_mgr = common_objs['cfg_mgr']
@@ -29,8 +29,8 @@ def __init__(self, common_objs, db, table):
2929
self.tsb_template = common_objs['tf'].from_file("bgpd/tsa/bgpd.tsa.unisolate.conf.j2")
3030
self.wcmp_template = common_objs['tf'].from_file("bgpd/wcmp/bgpd.wcmp.conf.j2")
3131
self.idf_isolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_isolate.conf.j2")
32-
self.idf_unisolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_unisolate.conf.j2")
33-
self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"),], self.on_switch_type_change)
32+
self.idf_unisolate_template = common_objs['tf'].from_file("bgpd/idf_isolate/idf_unisolate.conf.j2")
33+
self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"),], self.handle_type_update)
3434
super(DeviceGlobalCfgMgr, self).__init__(
3535
common_objs,
3636
[],
@@ -48,18 +48,16 @@ def __init__(self, common_objs, db, table):
4848
if not self.directory.path_exist(self.db_name, self.table_name, "idf_isolation_state"):
4949
self.directory.put(self.db_name, self.table_name, "idf_isolation_state", self.IDF_DEFAULTS)
5050

51-
def on_switch_type_change(self):
52-
log_debug("DeviceGlobalCfgMgr:: Switch type update handler")
53-
if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/switch_type"):
54-
self.switch_type = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["switch_type"]
55-
log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type)
51+
def handle_type_update(self):
52+
log_debug("DeviceGlobalCfgMgr:: Switch role update handler")
53+
if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/type"):
54+
self.switch_role = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["type"]
55+
log_debug("DeviceGlobalCfgMgr:: Switch role: %s" % self.switch_role)
5656

5757
def set_handler(self, key, data):
5858
""" Handle device TSA/W-ECMP state change """
5959
log_debug("DeviceGlobalCfgMgr:: set handler")
6060

61-
if self.switch_type:
62-
log_debug("DeviceGlobalCfgMgr:: Switch type: %s" % self.switch_type)
6361
if not data:
6462
log_err("DeviceGlobalCfgMgr:: data is None")
6563
return False
@@ -259,8 +257,8 @@ def downstream_isolate_unisolate(self, idf_isolation_state):
259257
log_err("IDF: invalid value({}) is provided".format(idf_isolation_state))
260258
return False
261259

262-
if self.switch_type and self.switch_type != "SpineRouter":
263-
log_debug("DeviceGlobalCfgMgr:: Skipping IDF isolation configuration on Switch type: %s" % self.switch_type)
260+
if self.switch_role and self.switch_role != "SpineRouter":
261+
log_debug("DeviceGlobalCfgMgr:: Skipping IDF isolation configuration on %s" % self.switch_role)
264262
return True
265263

266264
cmd = "\n"

0 commit comments

Comments
 (0)