import logging


def get_port_map(dut, asic_index=None):
    """
    @summary: Get the port mapping info from the DUT
    @return: a dictionary containing the port map
    """
    logging.info("Retrieving port mapping from DUT")
    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