Skip to content

Commit

Permalink
[common]: Fix of get_port_map
Browse files Browse the repository at this point in the history
*Fix get_port_map due to deprecation of plugins/getportmap.py

  Signed-off-by: Vladyslav Morokhovych <vladyslavx.morokhovych@intel.com>
  • Loading branch information
vmorokhx committed Jun 8, 2021
1 parent 4309468 commit cbfafb1
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions tests/common/platform/interface_utils.py
Expand Up @@ -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

0 comments on commit cbfafb1

Please sign in to comment.