Ejemplo n.º 1
0
def reload_ptf_config(request, ptfhost, define_sub_ports_configuration):
    """
    PTF's configuration reload on teardown

    Args:
        request: pytest request object
        ptfhost: PTF host object
        define_sub_ports_configuration: Dictonary of parameters for configuration DUT
    """
    yield
    sub_ports = define_sub_ports_configuration['sub_ports']
    ptf_port_list = get_ptf_port_list(ptfhost)

    for sub_port_info in sub_ports.values():
        if sub_port_info['neighbor_port'] in ptf_port_list:
            remove_sub_port_from_ptf(ptfhost, sub_port_info['neighbor_port'],
                                     sub_port_info['neighbor_ip'])

    if 'port_in_lag' in request.node.name:
        ptf_ports = define_sub_ports_configuration['ptf_ports']
        for bond_port, port_name in ptf_ports.items():
            if bond_port in ptf_port_list:
                remove_bond_port(ptfhost, bond_port, port_name)

    ptfhost.shell("supervisorctl restart ptf_nn_agent")
    time.sleep(5)
Ejemplo n.º 2
0
def reload_ptf_config(request, ptfhost, define_sub_ports_configuration):
    """
    PTF's configuration reload on teardown

    Args:
        request: pytest request object
        ptfhost: PTF host object
        define_sub_ports_configuration: Dictonary of parameters for configuration DUT
    """
    yield

    sub_ports = define_sub_ports_configuration['sub_ports']
    ptf_port_list = get_ptf_port_list(ptfhost)

    for sub_port_info in sub_ports.values():
        if sub_port_info['neighbor_port'] in ptf_port_list:
            ptfhost.shell("ip address del {} dev {}".format(
                sub_port_info['neighbor_ip'], sub_port_info['neighbor_port']))
            ptfhost.shell("ip link del {}".format(
                sub_port_info['neighbor_port']))

    if 'port_in_lag' in request.node.name:
        ptf_ports = define_sub_ports_configuration['ptf_ports']
        for bond_port, port_name in ptf_ports.items():
            if bond_port in ptf_port_list:
                ptfhost.shell("ip link set {} nomaster".format(bond_port))
                ptfhost.shell("ip link set {} nomaster".format(port_name))
                ptfhost.shell("ip link set {} up".format(port_name))
                ptfhost.shell("ip link del {}".format(bond_port))

    ptfhost.shell("supervisorctl restart ptf_nn_agent")
    time.sleep(5)