Skip to content

Commit

Permalink
Support both str and int type for slot_id received in pmon API (#5518)
Browse files Browse the repository at this point in the history
Based on PR sonic-net/SONiC#945, we should return
the sticker/label name on the chassis for the physical slot id
in the get_supervisor_slot PMON API and 'show chassis module status' command.

For Nokia linecards, the sticker label for supervisor is 'A'.
Thus we need to allow for string as possible return value as well - apart for int.
  • Loading branch information
sanmalho-git committed May 18, 2022
1 parent e80445f commit a93e1ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/platform_tests/api/test_chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,13 @@ def test_get_eeprom(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
def test_get_supervisor_slot(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
if chassis.is_modular_chassis(platform_api_conn):
sup_slot = chassis.get_supervisor_slot(platform_api_conn)
pytest_assert(isinstance(sup_slot, int), "supervisor slot is not type integer")
pytest_assert(isinstance(sup_slot, int) or isinstance(sup_slot, STRING_TYPE), "supervisor slot is not type integer")
else:
pytest.skip("skipped as this test is applicable to modular chassis only")

def test_get_my_slot(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
if chassis.is_modular_chassis(platform_api_conn):
my_slot = chassis.get_my_slot(platform_api_conn)
pytest_assert(isinstance(my_slot, int), "supervisor slot is not type integer")
pytest_assert(isinstance(my_slot, int) or isinstance(my_slot, STRING_TYPE), "supervisor slot is not type integer")
else:
pytest.skip("skipped as this test is applicable to modular chassis only")
2 changes: 1 addition & 1 deletion tests/platform_tests/api/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def test_get_slot(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, p
for i in range(self.num_modules):
slot_id = module.get_slot(platform_api_conn, i)
if self.expect(slot_id is not None, "Unable to retrieve module {} slot id".format(i)):
self.expect(isinstance(slot_id, int), "Module {} slot id is not correct ".format(i))
self.expect(isinstance(slot_id, int) or isinstance(slot_id, STRING_TYPE), "Module {} slot id is not correct ".format(i))
self.assert_expectations()

def test_get_type(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
Expand Down

0 comments on commit a93e1ab

Please sign in to comment.