Exemplo n.º 1
0
def pfc_test_setup(duthosts, rand_one_dut_hostname, tbinfo, ptfhost):
    """
    Generate configurations for the tests

    Args:
        duthosts(AnsibleHost) : multi dut instance
        rand_one_dut_hostname(string) : one of the dut instances from the multi dut

    Yields:
        setup(dict): DUT interfaces, PTF interfaces, PTF IP addresses, and PTF MAC addresses
    """
    """ Get all the active physical interfaces enslaved to the Vlan """
    """ These interfaces are actually server-faced interfaces at T0 """
    duthost = duthosts[rand_one_dut_hostname]
    vlan_members, vlan_id = get_active_vlan_members(duthost)
    """ Get Vlan subnet """
    vlan_subnet = get_vlan_subnet(duthost)
    """ Generate IP addresses for servers in the Vlan """
    vlan_ip_addrs = list()
    if 'dualtor' in tbinfo['topo']['name']:
        servers = mux_cable_server_ip(duthost)
        for intf, value in natsorted(servers.items()):
            vlan_ip_addrs.append(value['server_ipv4'].split('/')[0])
    else:
        vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, len(vlan_members))
    """ Find correspoinding interfaces on PTF """
    phy_intfs = get_phy_intfs(duthost)
    phy_intfs.sort(key=natural_keys)
    vlan_members.sort(key=natural_keys)
    vlan_members_index = [phy_intfs.index(intf) for intf in vlan_members]
    ptf_intfs = ['eth' + str(i) for i in vlan_members_index]

    duthost.command('sonic-clear fdb all')
    """ Disable DUT's PFC wd """
    duthost.shell('sudo pfcwd stop')

    testbed_type = tbinfo['topo']['name']

    yield {
        'vlan_members': vlan_members,
        'vlan_id': vlan_id,
        'ptf_intfs': ptf_intfs,
        'vlan_ip_addrs': vlan_ip_addrs,
        'testbed_type': testbed_type
    }

    duthost.command('sonic-clear fdb all')
    """ Enable DUT's PFC wd """
    duthost.shell('sudo pfcwd start_default')
Exemplo n.º 2
0
def pfc_test_setup(duthosts, rand_one_dut_hostname, tbinfo):
    """
    Generate configurations for the tests

    Args:
        duthosts(AnsibleHost) : multi dut instance
        rand_one_dut_hostname(string) : one of the dut instances from the multi dut

    Yields:
        setup(dict): DUT interfaces, PTF interfaces, PTF IP addresses, and PTF MAC addresses
    """

    """ Get all the active physical interfaces enslaved to the Vlan """
    """ These interfaces are actually server-faced interfaces at T0 """
    duthost = duthosts[rand_one_dut_hostname]
    vlan_members = get_active_vlan_members(duthost)

    """ Get Vlan subnet """
    vlan_subnet = get_vlan_subnet(duthost)

    """ Generate IP addresses for servers in the Vlan """
    vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, len(vlan_members))

    """ Generate MAC addresses 00:00:00:00:00:XX for servers in the Vlan """
    vlan_mac_addrs = [5 * '00:' + format(k, '02x') for k in random.sample(range(1, 256), len(vlan_members))]

    """ Find correspoinding interfaces on PTF """
    phy_intfs = get_phy_intfs(duthost)
    phy_intfs.sort(key=natural_keys)
    vlan_members.sort(key=natural_keys)
    vlan_members_index = [phy_intfs.index(intf) for intf in vlan_members]
    ptf_intfs = ['eth' + str(i) for i in vlan_members_index]

    """ Disable DUT's PFC wd """
    duthost.shell('sudo pfcwd stop')

    yield {
                  'vlan_members': vlan_members,
                  'ptf_intfs': ptf_intfs,
                  'vlan_ip_addrs': vlan_ip_addrs,
                  'vlan_mac_addrs':  vlan_mac_addrs
                }

    """ Enable DUT's PFC wd """
    if 'dualtor' not in tbinfo['topo']['name']:
        duthost.shell('sudo pfcwd start_default')