From cbfafb1d157392072db8920aa01d26b1f6121779 Mon Sep 17 00:00:00 2001 From: Vladyslav Morokhovych Date: Tue, 8 Jun 2021 09:34:05 -0700 Subject: [PATCH] [common]: Fix of get_port_map *Fix get_port_map due to deprecation of plugins/getportmap.py Signed-off-by: Vladyslav Morokhovych --- tests/common/platform/interface_utils.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tests/common/platform/interface_utils.py b/tests/common/platform/interface_utils.py index db84d19c7ce..2a8402cd78e 100644 --- a/tests/common/platform/interface_utils.py +++ b/tests/common/platform/interface_utils.py @@ -115,18 +115,10 @@ def get_port_map(dut, asic_index=None): @return: a dictionary containing the port map """ logging.info("Retrieving port mapping from DUT") - # copy the helper to DUT - src_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files/getportmap.py') - dest_path = os.path.join('/usr/share/sonic/device', dut.facts['platform'], 'plugins/getportmap.py') - dut.copy(src=src_path, dest=dest_path) - - # execute command on the DUT to get portmap - get_portmap_cmd = "docker exec pmon python /usr/share/sonic/platform/plugins/getportmap.py -asicid {}".format(asic_index) - portmap_json_string = dut.command(get_portmap_cmd)["stdout"] - - # parse the json - port_mapping = json.loads(portmap_json_string) - assert port_mapping, "Retrieve port mapping from DUT failed" + namespace = dut.get_namespace_from_asic_id(asic_index) + config_facts = dut.config_facts(host=dut.hostname, source="running",namespace=namespace)['ansible_facts'] + port_mapping = config_facts['port_index_map'] + for k,v in port_mapping.items(): + port_mapping[k] = [v] return port_mapping -