Exemplo n.º 1
0
def tg_vrf_bind(**kwargs):
    vars = st.get_testbed_vars()

    dut1 = st.get_dut_names()[0]
    dut2 = st.get_dut_names()[1]
    if 'config' in kwargs:
        config = kwargs['config']
    else:
        config = ''

    if config == '':
        st.log('######------Configure vlans on the PE--CE side-------######')
        for i in range(3):
            utils.exec_all(True, [[vlan_obj.create_vlan, vars.D1, data.dut1_tg1_vlan[i]], [vlan_obj.create_vlan, vars.D2, data.dut2_tg1_vlan[i]]])
            utils.exec_all(True,[[vlan_obj.add_vlan_member,vars.D1,data.dut1_tg1_vlan[i],vars.D1T1P1,True,True], [vlan_obj.add_vlan_member,vars.D2,data.dut2_tg1_vlan[i],vars.D2T1P1,True,True]])
            '''
            vlan_obj.create_vlan(vars.D1, data.dut1_tg1_vlan[i]) # Vlan-1, VRF-101, port1
            vlan_obj.add_vlan_member(vars.D1, data.dut1_tg1_vlan[i], vars.D1T1P1, True, True)
            vlan_obj.create_vlan(vars.D2, data.dut2_tg1_vlan[i])
            vlan_obj.add_vlan_member(vars.D2, data.dut2_tg1_vlan[i], vars.D2T1P1, True, True)
            '''
        st.log('######------Bind DUT1 <--> tg1 vlans to vrf, assign v4 and v6 address------######')
        for vrf, vlan, ip, ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan[0:3],data.dut1_tg1_vrf_ip[0:3], data.dut1_tg1_vrf_ipv6[0:3]):
            vrf_api.bind_vrf_interface(dut = vars.D1, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True)
            ipfeature.config_ip_addr_interface(vars.D1, 'Vlan'+vlan, ip, data.dut1_tg1_vrf_ip_subnet, 'ipv4')
            ipfeature.config_ip_addr_interface(vars.D1, 'Vlan'+vlan, ipv6, data.dut1_tg1_vrf_ipv6_subnet, 'ipv6')

        st.log('######------Bind DUT2 <--> tg1 vlans to vrf, assign v4 and v6 address------######')
        for vrf, vlan,ip,ipv6 in zip(data.vrf_name[0:3], data.dut2_tg1_vlan[0:3], data.dut2_tg1_vrf_ip[0:3], data.dut2_tg1_vrf_ipv6[0:3]):
            vrf_api.bind_vrf_interface(dut = vars.D2, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True)
            ipfeature.config_ip_addr_interface(vars.D2, 'Vlan'+vlan, ip, data.dut2_tg1_vrf_ip_subnet, 'ipv4')
            ipfeature.config_ip_addr_interface(vars.D2, 'Vlan'+vlan, ipv6, data.dut2_tg1_vrf_ipv6_subnet, 'ipv6')
    else:
        st.log('######------Unbind DUT1 <--> tg1port1 vlans to vrf, assign v4 and v6 address------######')
        for vrf, vlan, ip, ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan[0:3],data.dut1_tg1_vrf_ip[0:3], data.dut1_tg1_vrf_ipv6[0:3]):
            ipfeature.delete_ip_interface(dut1, 'Vlan'+vlan, ip, data.dut1_tg1_vrf_ip_subnet, 'ipv4')
            ipfeature.delete_ip_interface(dut1, 'Vlan'+vlan, ipv6, data.dut1_tg1_vrf_ipv6_subnet, 'ipv6')
            vrf_api.bind_vrf_interface(dut = dut1, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True, config = 'no')
        st.log('######------Unbind DUT2 <--> tg1 vlans to vrf, assign v4 and v6 address------######')
        for vrf, vlan,ip,ipv6 in zip(data.vrf_name[0:3], data.dut2_tg1_vlan[0:3], data.dut2_tg1_vrf_ip[0:3], data.dut2_tg1_vrf_ipv6[0:3]):
            ipfeature.delete_ip_interface(dut2, 'Vlan'+vlan, ip, data.dut2_tg1_vrf_ip_subnet, 'ipv4')
            ipfeature.delete_ip_interface(dut2, 'Vlan'+vlan, ipv6, data.dut2_tg1_vrf_ipv6_subnet, 'ipv6')
            vrf_api.bind_vrf_interface(dut = dut2, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True, config = 'no')

        st.log('######------Unconfigure vlans on the PE--CE side -------######')
        for i in range(3):
            vlan_obj.delete_vlan_member(dut1, data.dut1_tg1_vlan[i], vars.D1T1P1, tagging_mode=True)
            vlan_obj.delete_vlan(dut1, data.dut1_tg1_vlan[i]) # Vlan-1, VRF-101, port1
            vlan_obj.delete_vlan_member(dut2, data.dut2_tg1_vlan[i], vars.D2T1P1, tagging_mode=True)
            vlan_obj.delete_vlan(dut2, data.dut2_tg1_vlan[i])
def test_ft_ipv6_link_local_vrf():
    report_flag = 0
    st.log("Clearing all interface counters")
    utils.exec_all(True, [[intf_obj.clear_interface_counters, vars.D1], [intf_obj.clear_interface_counters, vars.D2]])
    st.log("clearing TG stats")
    tgapi.traffic_action_control(tg_handler, actions=['clear_stats'])
    st.log("Check the auto configured ipv6 link local address for VRF interface")
    if not ip_obj.get_link_local_addresses(vars.D1, data.vlan_in_2):
        st.log(
            "Ipv6 link local address is not auto generated for VRF binded vlan based routing interface {}".format(data.vlan_in_2))
        report_flag = 1
    ip_obj.show_ip_route(vars.D1, "ipv6", "sonic", data.vrf_name)
    st.log("binding the TG connected interface to VRF {}".format(data.vrf_name))
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0], data.tg_ip6_addr_mask_l[0], "ipv6",
                                    'remove')
    vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=vars.D1T1P1, config='yes', skip_error=True)
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0],data.tg_ip6_addr_mask_l[0], "ipv6", 'add')
    tg1.tg_traffic_control(action='run', handle=tg_str_data[1]["tg1_ipv6_data_str_id_1"])
    st.wait(data.pkts_tx_time)
    tg1.tg_traffic_control(action='stop', handle=tg_str_data[1]["tg1_ipv6_data_str_id_1"])
    # Show command for debugging purpose in case of failures.
    utils.exec_all(True, [[intf_obj.show_interface_counters_all, vars.D1],
                          [intf_obj.show_interface_counters_all, vars.D2]])
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P1],
            'tx_obj': [tg1],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D2P1],
            'rx_obj': [tg2],
        }
    }

    filter_result = tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count')
    if not filter_result:
        st.log(
            "After flap in next hop interfaces, traffic loss observed for ipv6 traffic forwarded via ipv6 link local next hop")
        report_flag = 1
    if report_flag:
        vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=vars.D1T1P1, config='no', skip_error=True)
        ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0], data.tg_ip6_addr_mask_l[0],
                                        "ipv6", 'add')
        st.report_fail("ip6_traffic_over_link_local_nh_fail_vrf")
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0], data.tg_ip6_addr_mask_l[0], "ipv6",
                                    'remove')
    vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=vars.D1T1P1, config='no', skip_error=True)
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0],data.tg_ip6_addr_mask_l[0], "ipv6", 'add')
    st.report_pass("test_case_passed")
def test_unnumvrf_donar(fixture_unnumvrf_test_donar):

    tc_list = [
        'FtOpSoRoIPnumvrfFun007', 'FtOpSoRoIPnumvrfFun008',
        'FtOpSoRoIPnumvrfFun009'
    ]
    final_result = 0
    result = True
    error_list = []
    st.banner('FtOpSoRoIPnumvrfFun007 -- to -- FtOpSoRoIPnumvrfFun009')

    st.banner(
        'Verify unnumbered interface for non default vrf after unbind and rebind vrf'
    )
    tc_result = True
    st.log('Remove the unnumbered configuration on DUT1')
    loc_lib.dut1_config_unnumbered('phy', 'no')
    loc_lib.dut1_config_unnumbered('vlan', 'no')
    loc_lib.dut1_config_unnumbered('pc', 'no')

    st.log(
        'Remove the OSPF configuration for the unnumbered interfaces on DUT1')
    ospf_obj.config_interface_ip_ospf_network_type(data.dut1,
                                                   data.d1_d2_ports[0],
                                                   'point-to-point',
                                                   data.dut1_vrf[0], 'no')
    ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point',
        data.dut1_vrf[0], 'no')
    ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.portchannel,
                                                   'point-to-point',
                                                   data.dut1_vrf[0], 'no')

    st.log('Remove the IP addresses for the unnumbered interfaces on DUT1')
    ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[2],
                               data.dut1_loopback_ip[2],
                               data.ip_loopback_prefix, "ipv4")
    ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[1],
                               data.dut1_loopback_ip[1],
                               data.ip_loopback_prefix, "ipv4")
    ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[0],
                               data.dut1_loopback_ip[0],
                               data.ip_loopback_prefix, "ipv4")

    st.log('Remove the VRF binding for the unnumbered interfaces on DUT1')
    vrf_obj.bind_vrf_interface(
        dut=data.dut1,
        vrf_name=[data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0]],
        intf_name=[
            data.d1_d2_ports[0], 'Vlan' + data.dut1_dut2_vlan[0],
            data.portchannel
        ],
        config='no')

    st.log('Bind the back to the unnumbered interfaces on DUT1')
    vrf_obj.bind_vrf_interface(
        dut=data.dut1,
        vrf_name=[data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0]],
        intf_name=[
            data.d1_d2_ports[0], 'Vlan' + data.dut1_dut2_vlan[0],
            data.portchannel
        ],
        config='yes')

    st.banner('On DUT1 verify vrf bindings for all the interfaces')
    output = vrf_obj.get_vrf_verbose(dut=data.dut1, vrfname=data.dut1_vrf[0])
    if data.dut1_vrf[0] in output['vrfname']:
        st.log('VRF configured on DUT1 is as expected', data.dut1_vrf[0])
    else:
        st.error('VRF name configured on DUT1 is as not expected',
                 data.dut1_vrf[0])
        result = False
    for value in output['interfaces']:
        if data.dut1_tg_ports[0] or data.dut1_loopback[
                0] or data.dut1_loopback[1] or data.dut1_loopback[
                    2] or data.d1_d2_ports[0] or 'Vlan' + data.dut1_dut2_vlan[
                        0] or data.portchannel == value:
            st.log('Bind to VRF is as expected', value)
        else:
            st.error('Bind to VRF is not as expected', value)
            result = False
    if result is False:
        error = "Unbind/Rebind of unnumbered interfaces failed"
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[0], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[0], 'test_case_failure_message', error)

    st.banner(
        'Verify unnumbered interface for non default vrf after adding and removing donar IP'
    )
    tc_result = True
    st.log('On DUT1 configure back the ip addresses on the loopbacks')
    ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[1],
                                    data.dut1_loopback_ip[1],
                                    data.ip_loopback_prefix, 'ipv4')
    ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[2],
                                    data.dut1_loopback_ip[2],
                                    data.ip_loopback_prefix, 'ipv4')

    st.log('On DUT1 add the interfaces back in the ospf network')
    ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point',
        data.dut1_vrf[0], 'yes')
    ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.portchannel,
                                                   'point-to-point',
                                                   data.dut1_vrf[0], 'yes')

    st.log(
        'On DUT1 configure and verify portchannel and vlan as unnumbered interfaces'
    )
    loc_lib.dut1_config_unnumbered('vlan', '')
    result = loc_lib.dut1_verify_unnumbered('vlan')
    if result is False:
        error = "Verification of unnumbered interfaces over vrf on a vlan failed after adding/removing the donar interface"
        tc_result = False
        error_list.append(error)
    loc_lib.dut1_config_unnumbered('pc', '')
    result = loc_lib.dut1_verify_unnumbered('pc')
    if result is False:
        error = "Verification of unnumbered interfaces over vrf on a portchannel failed after adding/removing the donar interface"
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[1], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[1], 'test_case_failure_message', error)

    st.banner(
        'Verify unnumbered interface for non default vrf after modifying the donar IP'
    )
    tc_result = True
    st.log(
        'On DUT1 modify the donar interface address, add them to the ospf network and configure the physical interface as unnumbered for the new donar IP'
    )
    ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[0],
                                    data.dut1_loopback_ip[3],
                                    data.ip_loopback_prefix, 'ipv4')
    ospf_obj.config_interface_ip_ospf_network_type(data.dut1,
                                                   data.d1_d2_ports[0],
                                                   'point-to-point',
                                                   data.dut1_vrf[0], 'yes')
    ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'yes')
    ip_obj.config_unnumbered_interface(data.dut1,
                                       family='ipv4',
                                       action='add',
                                       interface=data.d1_d2_ports[0],
                                       loop_back=data.dut1_loopback[0])

    st.log('Verify OSPF is up for all interfaces')
    result = loc_lib.verify_ospf()
    if result is False:
        error = "OSPF neighbors are not up for all/some of the unnumbered interfaces"
        tc_result = False
        error_list.append(error)

    result = ip_obj.verify_interface_ip_address(
        data.dut1, data.d1_d2_ports[0],
        data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, 'ipv4',
        data.dut1_vrf[0], 'U')
    if result is False:
        error = "Verification of unnumbered interfaces over vrf on a physical interface failed after modifying the donar IP"
        tc_result = False
        error_list.append(error)
    st.log(
        'Shutting the other ports for traffic to take new configured donar address'
    )
    port_obj.shutdown(
        data.dut1,
        [data.d1_d2_ports[1], data.d1_d2_ports[2], data.d1_d2_ports[3]])

    result = retry_api(ip_obj.verify_ip_route,
                       data.dut2,
                       type='O',
                       nexthop=data.dut1_loopback_ip[3],
                       interface=data.d2_d1_ports[0],
                       ip_address=data.dut1_loopback_ip[3] + '/' +
                       data.ip_loopback_prefix,
                       family="ipv4",
                       retry_count=7,
                       delay=5)
    if result is False:
        error = "IP routes on non-default vrf with new IP failed"
        tc_result = False
        error_list.append(error)

    result = loc_lib.send_verify_traffic()
    if result is False:
        error = "Traffic over vrf on a physical interface failed after modifying the donar IP"
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[2], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[2], 'test_case_failure_message', error)

    if final_result != 0:
        st.report_fail('test_case_failure_message', error_list)
    else:
        st.report_pass('test_case_passed')
Exemplo n.º 4
0
def dut3_config(config=''):
    st.log('On DUT3 physical interface IPv4 and IPv6 addresses on it')
    vrf_obj.config_vrf(dut=data.dut3_client,
                       vrf_name=data.dut3_vrf_phy,
                       config='yes')
    vrf_obj.bind_vrf_interface(dut=data.dut3_client,
                               vrf_name=data.dut3_vrf_phy,
                               intf_name=data.d3_d2_ports[0],
                               config='yes')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.d3_d2_ports[0],
                                    data.dut3_dut2_ipv6[0],
                                    data.dut3_dut2_ipv6_subnet, 'ipv6')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.d3_d2_ports[0],
                                    data.dut3_dut2_ip[0],
                                    data.dut3_dut2_ip_subnet, 'ipv4')
    vlan_obj.create_vlan(data.dut3_client, data.dut2_dut3_vlan[0])
    vlan_obj.add_vlan_member(data.dut3_client, data.dut2_dut3_vlan[0],
                             data.d3_d2_ports[1], True, True)
    st.log('On DUT3 configure vlan and IPv4 and IPv6 addresses on it')
    vrf_obj.config_vrf(dut=data.dut3_client,
                       vrf_name=data.dut3_vrf_vlan,
                       config='yes')
    vrf_obj.bind_vrf_interface(dut=data.dut3_client,
                               vrf_name=data.dut3_vrf_vlan,
                               intf_name='Vlan' + data.dut2_dut3_vlan[0],
                               config='yes')
    ip_obj.config_ip_addr_interface(data.dut3_client,
                                    'Vlan' + data.dut2_dut3_vlan[0],
                                    data.dut3_dut2_ipv6[1],
                                    data.dut3_dut2_ipv6_subnet, 'ipv6')
    ip_obj.config_ip_addr_interface(data.dut3_client,
                                    'Vlan' + data.dut2_dut3_vlan[0],
                                    data.dut3_dut2_ip[1],
                                    data.dut3_dut2_ip_subnet, 'ipv4')
    st.log('On DUT3 configure portchannel and IPv4 and IPv6 addresses on it')
    pc_obj.create_portchannel(data.dut3_client, data.portchannel_2)
    pc_obj.add_portchannel_member(data.dut3_client, data.portchannel_2,
                                  [data.d3_d2_ports[2], data.d3_d2_ports[3]])
    vrf_obj.config_vrf(dut=data.dut3_client,
                       vrf_name=data.dut3_vrf_pc,
                       config='yes')
    vrf_obj.bind_vrf_interface(dut=data.dut3_client,
                               vrf_name=data.dut3_vrf_pc,
                               intf_name=data.portchannel_2,
                               config='yes')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.portchannel_2,
                                    data.dut3_dut2_ipv6[2],
                                    data.dut3_dut2_ipv6_subnet, 'ipv6')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.portchannel_2,
                                    data.dut3_dut2_ip[2],
                                    data.dut3_dut2_ip_subnet, 'ipv4')

    st.log('On DUT3 configure loopback and IPv4 and IPv6 addresses on it')
    ip_obj.configure_loopback(data.dut3_client,
                              config='yes',
                              loopback_name=data.dut3_loopback[1])
    vrf_obj.config_vrf(dut=data.dut3_client,
                       vrf_name=data.dut3_vrf_phy,
                       config='yes')
    vrf_obj.bind_vrf_interface(dut=data.dut3_client,
                               vrf_name=data.dut3_vrf_phy,
                               intf_name=data.dut3_loopback[1],
                               config='yes')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.dut3_loopback[1],
                                    data.dut3_loopback_ipv6[1],
                                    data.dut3_loopback_ipv6_subnet, 'ipv6')
    ip_obj.config_ip_addr_interface(data.dut3_client, data.dut3_loopback[1],
                                    data.dut3_loopback_ip[1],
                                    data.dut3_loopback_ip_subnet, 'ipv4')

    st.log('IPv4 and IPv6 static routes for loopback reachability')
    ip_obj.create_static_route(data.dut3_client,
                               data.dut2_dut3_ip[0],
                               data.dut2_loopback_ip[1] + '/32',
                               family='ipv4',
                               interface=data.d3_d2_ports[0],
                               vrf=data.dut3_vrf_phy)
    ip_obj.create_static_route(data.dut3_client,
                               data.dut2_dut3_ipv6[0],
                               data.dut2_loopback_ipv6[1] + '/128',
                               family='ipv6',
                               interface=data.d3_d2_ports[0],
                               vrf=data.dut3_vrf_phy)
    return True
def dut1_config():

    result = True
    st.log('On DUT1 configure vrfs and loopbacks')
    result = vrf_obj.config_vrf(dut=data.dut1,
                                vrf_name=data.dut1_vrf[0],
                                config='yes')
    result = ip_obj.configure_loopback(data.dut1,
                                       config='yes',
                                       loopback_name=[
                                           data.dut1_loopback[0],
                                           data.dut1_loopback[1],
                                           data.dut1_loopback[2]
                                       ])

    st.log('On DUT1 configure vlan')
    result = vlan_obj.create_vlan(data.dut1, data.dut1_dut2_vlan[0])
    result = vlan_obj.add_vlan_member(data.dut1, data.dut1_dut2_vlan[0],
                                      data.d1_d2_ports[1], True, True)

    st.log('On DUT1 configure portchannel')
    result = pc_obj.create_portchannel(data.dut1, data.portchannel)
    result = pc_obj.add_portchannel_member(
        data.dut1, data.portchannel,
        [data.d1_d2_ports[2], data.d1_d2_ports[3]])

    st.log(
        'On DUT1 bind all the loopbacks, physical, vlan and portchannel interfaces between the DUTs to the VRF'
    )
    result = vrf_obj.bind_vrf_interface(
        dut=data.dut1,
        vrf_name=[
            data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0],
            data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0],
            data.dut1_vrf[0], data.dut1_vrf[0]
        ],
        intf_name=[
            data.dut1_tg_ports[0], data.dut1_loopback[0],
            data.dut1_loopback[1], data.dut1_loopback[2], data.d1_d2_ports[0],
            'Vlan' + data.dut1_dut2_vlan[0], data.portchannel
        ],
        config='yes')

    st.banner('On DUT1 verify vrf bindings for all the interfaces')
    output = vrf_obj.get_vrf_verbose(dut=data.dut1, vrfname=data.dut1_vrf[0])
    if data.dut1_vrf[0] in output['vrfname']:
        st.log('VRF configured on DUT1 is as expected', data.dut1_vrf[0])
    else:
        st.error('VRF name configured on DUT1 is as not expected',
                 data.dut1_vrf[0])
        result = False
    for value in output['interfaces']:
        if data.dut1_tg_ports[0] or data.dut1_loopback[
                0] or data.dut1_loopback[1] or data.dut1_loopback[
                    2] or data.d1_d2_ports[0] or 'Vlan' + data.dut1_dut2_vlan[
                        0] or data.portchannel == value:
            st.log('Bind to VRF is as expected', value)
        else:
            st.error('Bind to VRF is not as expected', value)
            result = False

    st.log(
        'On DUT1 configure OSPF router ID, ospf networks and add all the ospf interfaces'
    )
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[0],
                                             data.dut1_loopback_ipv6[0],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[0],
                                             data.dut1_loopback_ip[0],
                                             data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[1],
                                             data.dut1_loopback_ipv6[1],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[1],
                                             data.dut1_loopback_ip[1],
                                             data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[2],
                                             data.dut1_loopback_ipv6[2],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[2],
                                             data.dut1_loopback_ip[2],
                                             data.ip_loopback_prefix, 'ipv4')

    st.log(
        'On DUT1 configure OSPF router ID, ospf networks and add all the ospf interfaces'
    )
    result = ospf_obj.config_ospf_router_id(data.dut1,
                                            data.dut1_ospf_router_id,
                                            data.dut1_vrf[0], '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[0] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[1] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[2] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'yes')
    result = ospf_obj.config_ospf_network(data.dut1, data.dut1_tg1_network_v4,
                                          0, data.dut1_vrf[0], '', 'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, data.d1_d2_ports[0], 'point-to-point', data.dut1_vrf[0],
        'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point',
        data.dut1_vrf[0], 'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, data.portchannel, 'point-to-point', data.dut1_vrf[0], 'yes')

    st.log('On DUT1 configure IP addresses on DUT - TG interfaces')
    ip_obj.config_ip_addr_interface(data.dut1, data.dut1_tg_ports[0],
                                    data.dut1_tg_ipv6[0], data.tg_ipv6_subnet,
                                    'ipv6')
    ip_obj.config_ip_addr_interface(data.dut1, data.dut1_tg_ports[0],
                                    data.dut1_tg_ip[0], data.tg_ip_subnet,
                                    'ipv4')
    return result
def dut1_unconfig():

    result = 0
    st.log('On DUT1 unconfigure IP addresses on DUT - TG interfaces')
    ip_obj.delete_ip_interface(data.dut1, data.dut1_tg_ports[0],
                               data.dut1_tg_ipv6[0], data.tg_ipv6_subnet,
                               'ipv6')
    ip_obj.delete_ip_interface(data.dut1, data.dut1_tg_ports[0],
                               data.dut1_tg_ip[0], data.tg_ip_subnet, 'ipv4')

    st.log(
        'On DUT1 Unonfigure OSPF router ID, ospf network and add all the ospf interfaces'
    )
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, data.d1_d2_ports[0], 'point-to-point', data.dut1_vrf[0],
        'no')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point',
        data.dut1_vrf[0], 'no')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut1, data.portchannel, 'point-to-point', data.dut1_vrf[0], 'no')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[0] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'no')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[1] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'no')
    result = ospf_obj.config_ospf_network(
        data.dut1, data.dut1_loopback_ip[2] + '/' + data.ip_loopback_prefix, 0,
        data.dut1_vrf[0], '', 'no')
    result = ospf_obj.config_ospf_router_id(data.dut1,
                                            data.dut1_ospf_router_id,
                                            data.dut1_vrf[0], '', 'no')

    st.banner('Unconfigure IPv4 and IPv6 addresses on the loopback interfaces')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[0],
                                        data.dut1_loopback_ipv6[0],
                                        data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[0],
                                        data.dut1_loopback_ip[0],
                                        data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[1],
                                        data.dut1_loopback_ipv6[1],
                                        data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[1],
                                        data.dut1_loopback_ip[1],
                                        data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[2],
                                        data.dut1_loopback_ipv6[2],
                                        data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[2],
                                        data.dut1_loopback_ip[2],
                                        data.ip_loopback_prefix, 'ipv4')

    st.log(
        'On DUT1 unbind all the loopbacks, physical, vlan and portchannel interfaces to the VRF'
    )
    result = vrf_obj.bind_vrf_interface(
        dut=data.dut1,
        vrf_name=data.dut1_vrf[0],
        intf_name=[
            data.dut1_loopback[0], data.dut1_loopback[1],
            data.dut1_loopback[2], data.d1_d2_ports[0],
            'Vlan' + data.dut1_dut2_vlan[0], data.portchannel
        ],
        config='no')

    st.log('On DUT1 unconfigure vlan')
    result = vlan_obj.delete_vlan_member(data.dut1_client,
                                         data.dut1_dut2_vlan[0],
                                         data.d1_d2_ports[1], True)
    result = vlan_obj.create_vlan(data.dut1_client, data.dut1_dut2_vlan[0])

    st.banner('Unconfigure portchannel on DUT1')
    result = pc_obj.add_del_portchannel_member(
        data.dut1_client, data.portchannel,
        [data.d1_d2_ports[2], data.d1_d2_ports[3]], 'del')
    result = pc_obj.delete_portchannel(data.dut1_client, data.portchannel)

    st.log('On DUT1 unconfigure vrfs and loopbacks')
    result = ip_obj.configure_loopback(data.dut1,
                                       config='no',
                                       loopback_name=[
                                           data.dut1_loopback[0],
                                           data.dut1_loopback[1],
                                           data.dut1_loopback[2]
                                       ])
    result = vrf_obj.config_vrf(dut=data.dut3_client,
                                vrf_name=data.dut1_vrf[0],
                                config='no')

    return result
def ipv6_link_local_pre_config():
    global vars
    vars = st.ensure_min_topology("D1D2:4", "D1T1:1", "D2T1:1")
    global tg_handler, tg1, tg2, tg_ph_1, tg_ph_2, tg_str_data, dut1_rt_int_mac, dut2_rt_int_mac, \
        tg_rt_int_handle, d1_prt_link_local, d2_prt_link_local, d1_int_ipv6_list, d2_int_ipv6_list
    tg_handler = util_tg_init(vars, [vars.T1D1P1, vars.T1D2P1])
    tg1 = tg_handler["tg"]
    tg2 = tg_handler["tg"]
    tg_ph_1 = tg_handler["tg_ph_1"]
    tg_ph_2 = tg_handler["tg_ph_2"]

    st.log("For debugging purpose, checking 'running config' before proceeding for module config")
    utils.exec_all(True, [[sc_obj.get_running_config, vars.D1], [sc_obj.get_running_config, vars.D2]])

    st.log("For debugging purpose, checking 'routing interfaces' before proceeding for module config")
    utils.exec_all(True, [[ip_obj.get_interface_ip_address, vars.D1, None, "ipv6"], [ip_obj.get_interface_ip_address, vars.D2, None, "ipv6"]])
    pc_obj.config_portchannel(vars.D1, vars.D2, data.prt_chnl, [vars.D1D2P3, vars.D1D2P4],
                              [vars.D2D1P3, vars.D2D1P4], config='add', thread=True)

    st.log("Vlan config")
    utils.exec_all(True, [[vlan_obj.create_vlan, vars.D1, [data.vlan_li[0], data.vlan_li[1]]],
                          [vlan_obj.create_vlan, vars.D2, [data.vlan_li[0], data.vlan_li[1]]]])
    utils.exec_all(True, [
        [vlan_mem_cfg, vars.D1, [[data.vlan_li[0], vars.D1D2P2, True], [data.vlan_li[1], vars.D1D2P2, True]]],
        [vlan_mem_cfg, vars.D2, [[data.vlan_li[0], vars.D2D1P2, True], [data.vlan_li[1], vars.D2D1P2, True]]]])
    st.log("VRF Config and binding 2nd vlan routing interface to that VRF")
    vrf_obj.config_vrf(vars.D1, vrf_name=data.vrf_name, config='yes')
    vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=data.vlan_in_2, config='yes', skip_error=True)
    st.log("Enabling ipv6 link local")
    d1_int_ipv6_list =[vars.D1D2P1, data.vlan_in_1, data.vlan_in_2,data.prt_chnl]
    d2_int_ipv6_list = [vars.D2D1P1, data.vlan_in_1, data.vlan_in_2, data.prt_chnl]
    utils.exec_all(True, [[ip_obj.config_interface_ip6_link_local, vars.D1,d1_int_ipv6_list, 'enable'],
                          [ip_obj.config_interface_ip6_link_local, vars.D2,d2_int_ipv6_list, 'enable']])

    st.log("TG connected int ipv6 address config")
    utils.exec_all(True, [[ip_obj.config_ip_addr_interface, vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0],
                           data.tg_ip6_addr_mask_l[0],"ipv6",'add'], [ip_obj.config_ip_addr_interface, vars.D2,
                                                                      vars.D2T1P1, data.tgd_ip6_addr_l[1],
                           data.tg_ip6_addr_mask_l[1],"ipv6",'add']])

    st.log("Get DUT mac address")
    [rt_int_mac, exceptions] = utils.exec_all(True, [[basic_obj.get_ifconfig_ether, vars.D1, vars.D1D2P1],
                                                     [basic_obj.get_ifconfig_ether, vars.D2, vars.D2D1P1]])
    utils.ensure_no_exception(exceptions)
    dut1_rt_int_mac = rt_int_mac[0]
    dut2_rt_int_mac = rt_int_mac[1]


    st.log("Get DUT link local addresses")
    [rt_link_local_addr, exceptions] = utils.exec_all(True, [[ip_obj.get_link_local_addresses, vars.D1, vars.D1D2P1],
                                                     [ip_obj.get_link_local_addresses, vars.D2, vars.D2D1P1]])
    utils.ensure_no_exception(exceptions)
    d1_prt_link_local = rt_link_local_addr[0]
    d2_prt_link_local = rt_link_local_addr[1]

    if not d1_prt_link_local or not d2_prt_link_local:
        st.log("DUT Link Local Address are empty")
        st.report_fail("link_local_address_not_found")

    st.log("Routing interface config in TG")
    tg_rt_int_handle = util_tg_routing_int_config(vars, tg1, tg2, tg_ph_1, tg_ph_2)

    st.log("Doing ping to the TG ipv6 address to resolve the next hop")
    utils.exec_all(True, [[ip_obj.ping, vars.D1, data.tgd_ip6_addr_l[0], 'ipv6'],[ip_obj.ping, vars.D2, data.tgd_ip6_addr_l[1], 'ipv6']])

    st.log("Get show ndp output")
    utils.exec_all(True, [[arp_obj.show_ndp, vars.D1, None],[arp_obj.show_ndp, vars.D2, None]])

    st.log("Static route config")
    utils.exec_all(True, [[ip_obj.create_static_route, vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', vars.D1D2P1],
                          [ip_obj.create_static_route, vars.D2, data.tg_ip6_addr_l[1], data.static_rt, "vtysh", 'ipv6', vars.D2T1P1]])
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_1)
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.prt_chnl)
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_2, vrf=data.vrf_name)
    st.log("Get show ipv6 route output")
    utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1, "ipv6", "sonic", None],[ip_obj.show_ip_route, vars.D2, "ipv6", "sonic", None]])
    ip_obj.show_ip_route(vars.D1, "ipv6", "sonic", data.vrf_name)

    st.log("TG Stream config")
    tg_str_data = util_tg_stream_config(tg1, tg2, tg_ph_1, tg_ph_2)

    st.log("Clearing all interface counters for debugging purpose")
    utils.exec_all(True, [[intf_obj.clear_interface_counters, vars.D1], [intf_obj.clear_interface_counters, vars.D2]])