Skip to content

Commit 018770e

Browse files
committed
Add "state" field in CONFIG_DB fabric_monitor table as a toggle of the
fabric port monitoring feature. The command to set this is "config fabric port monitor state <enable/disable>" Signed-off-by: Jie Feng <[email protected]>
1 parent 3b7cc1f commit 018770e

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

config/fabric.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ def setFabricPortMonitorState(state, namespace ):
163163
config_db = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace)
164164
config_db.connect()
165165

166-
# Connect to state database
167-
state_db = SonicV2Connector(use_unix_socket_path=True, namespace=namespace)
168-
state_db.connect(state_db.STATE_DB, False)
169-
170166
# Make sure configuration data exists
171167
monitorData = config_db.get_all(config_db.CONFIG_DB, "FABRIC_MONITOR|FABRIC_MONITOR_DATA")
172168
if not bool(monitorData):
@@ -188,8 +184,7 @@ def state(state, namespace):
188184

189185
n_asics = multi_asic.get_num_asics()
190186
if n_asics > 1 and namespace is None:
191-
ns = multi_asic.get_all_namespaces()
192-
ns_list = ns['front_ns'] + ns['back_ns'] + ns['fabric_ns']
187+
ns_list = multi_asic.get_namespace_list()
193188
for namespace in ns_list:
194189
setFabricPortMonitorState(state, namespace)
195190
else:

tests/config_fabric_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,32 @@ def test_config_fabric_monitor_state(self, ctx):
103103
result = self.basic_check("port", ["monitor", "state", "disable"], ctx)
104104
expect_result = 0
105105
assert operator.eq(result.exit_code, expect_result)
106+
107+
class TestMultiAsicConfigFabric(object):
108+
@classmethod
109+
def setup_class(cls):
110+
print("SETUP")
111+
os.environ["PATH"] += os.pathsep + scripts_path
112+
os.environ["UTILITIES_UNIT_TESTING"] = "2"
113+
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic"
114+
115+
def basic_check(self, command_name, para_list, ctx):
116+
# This function issues command of "config fabric xxxx",
117+
# and returns the result of the command.
118+
runner = CliRunner()
119+
result = runner.invoke(config.config.commands["fabric"].commands[command_name], para_list, obj = ctx)
120+
print(result.output)
121+
return result
122+
123+
def test_multi_config_fabric_monitor_state(self, ctx):
124+
result = self.basic_check("port", ["monitor", "state", "disable"], ctx)
125+
expect_result = 0
126+
assert operator.eq(result.exit_code, expect_result)
127+
128+
@classmethod
129+
def teardown_class(cls):
130+
print("TEARDOWN_TEST")
131+
os.environ["PATH"] = os.pathsep.join(
132+
os.environ["PATH"].split(os.pathsep)[:-1])
133+
os.environ["UTILITIES_UNIT_TESTING"] = "0"
134+
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = ""

0 commit comments

Comments
 (0)