sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

[snappi] Need to generate asic_port_map based on dut info in snappi multidut fixture.

Open sdszhang opened this issue 1 year ago • 1 comments

In tests/common/snappi_tests/snappi_fixtures.py file, the asic_port_map is hard coded to two asics.

Following code needs to be enhanced to generate asic_port_map based on DUT.

def get_multidut_snappi_ports(duthosts, conn_graph_facts, fanout_graph_facts):            # noqa: F811
...
    def _get_multidut_snappi_ports(line_card_choice, line_card_info):
        host_names = line_card_info['hostname']
        asic_info = line_card_info['asic']
        asic_port_map = {
            "asic0": ['Ethernet%d' % i for i in range(0, 72, 4)],
            "asic1": ['Ethernet%d' % i for i in range(72, 144, 4)],
            None: ['Ethernet%d' % i for i in range(0, 144, 4)],
        }
        ports = []

sdszhang avatar Jun 21 '24 02:06 sdszhang

I have added Nokia specific code change using the following code. Will this work for you?

We can write a generic function for this and call it whenever required.

        config_facts = duthosts[0].config_facts(host=duthosts[0].hostname,
                                                source="running", namespace=asic_info[0])['ansible_facts']

        device_mtd = config_facts['DEVICE_METADATA']['localhost']['hwsku']
        is_nokia_7250 = True if ('Nokia' or 'nokia') and '7250' in device_mtd else False

        if (is_nokia_7250):
            asic_port_map = {
                "asic0": ['Ethernet%d' % i for i in range(0, 144, 4)],
                "asic1": ['Ethernet%d' % i for i in range(144, 284, 4)],
                None: ['Ethernet%d' % i for i in range(0, 144, 4)],
            }
        else:
             asic_port_map = {
                "asic0": ['Ethernet%d' % i for i in range(0, 72, 4)],
                "asic1": ['Ethernet%d' % i for i in range(72, 144, 4)],
                None: ['Ethernet%d' % i for i in range(0, 144, 4)],
            }

amitpawar12 avatar Jul 10 '24 20:07 amitpawar12

@amitpawar12 Looks like the asic_port_map here is just to figure out which ASIC the port is on. Can you try duthost.get_port_asic_instance() to see if it works?

sdszhang avatar Jul 16 '24 13:07 sdszhang

@sdszhang 👍

That sounds good but it returns class object. Improvising it further, this will work better: duthost1.get_port_asic_instance().get_asic_namespace()

Example: (Pdb) duthost1.get_port_asic_instance('Ethernet88').get_asic_namespace() 'asic0' (Pdb) duthost1.get_port_asic_instance('Ethernet144').get_asic_namespace() 'asic1'

Thanks, -A

amitpawar12 avatar Jul 16 '24 13:07 amitpawar12

not needed anymore after #14127

sdszhang avatar Dec 11 '24 10:12 sdszhang