def arp_static_route_reboot_module_hooks(request):
    # add things at the start of this module
    init_vars()
    initialize_variables()
    get_parms()

    global tg_handler
    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2")
    global tg
    tg = tg_handler["tg"]
    tg_ph_list = [tg_handler["tg_ph_1"], tg_handler["tg_ph_2"]]
    st.log("configuring static route")
    adding_static_route()
    st.log("Getting ARP entry dynamically")
    adding_dynamic_arp()
    ip_obj.config_ip_addr_interface(vars.D1,
                                    vars.D1T1P2,
                                    data.ipv4_address_1,
                                    data.mask,
                                    family="ipv4",
                                    config='add')
    st.log("Configuring static ARP")
    arp_obj.add_static_arp(vars.D1, data.static_arp_ip, data.static_arp_mac,
                           vars.D1T1P2)
    st.log(
        "Verifying static route entries before save and reboot/fast-reboot/warm-reboot"
    )
    static_route_verify()
    st.log(
        "Verifying dynamic ARP entries before save and reboot/fast-reboot/warm-reboot"
    )
    if not arp_obj.verify_arp(vars.D1, data.ipv4_address_ixia,
                              data.src_mac_addr, vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.ipv4_address_ixia,
                       vars.D1)
    else:
        st.log("Verified that dynamic ARP entry is present in arp table")
    st.log(
        "Verifying static ARP entries before save and reboot/fast-reboot/warm-reboot"
    )
    if not arp_obj.verify_arp(vars.D1, data.static_arp_ip, data.static_arp_mac,
                              ""):
        st.report_fail("static_arp_create_fail", vars.D1)
    else:
        st.log("Verified that static ARP entry is present in arp table")
    st.log("Save the config on the DUT")
    rb_obj.config_save(vars.D1)
    st.log("saving config in vtysh mode to save static route")
    rb_obj.config_save(vars.D1, shell="vtysh")
    yield
    # Below step will clear IP adresses configured on different interfaces in the device
    ip_obj.clear_ip_configuration(st.get_dut_names())
    #Below step will clear static route configured in the device
    ip_obj.delete_static_route(vars.D1,
                               data.ipv4_address_ixia,
                               data.ipv4_address_network,
                               family='ipv4',
                               shell="vtysh")
    #Below step will delete static arp entries configured in the device
    arp_obj.delete_static_arp(vars.D1, data.static_arp_ip, vars.D1T1P2)
Ejemplo n.º 2
0
def test_Ceta_31902(ceta_31902_fixture):
    success = True
    mac_obj.config_mac(dut=vars.D1,
                       mac=data.host1_mac,
                       vlan=data.host1_vlan,
                       intf=vars.D1T1P1)
    arp_obj.add_static_arp(dut=vars.D1,
                           ipaddress=data_tg_ip,
                           macaddress=data.host1_mac,
                           interface="Vlan" + data.host1_vlan)

    arp_obj.add_static_arp(dut=vars.D1,
                           ipaddress=data_tg_ip,
                           macaddress=data.host2_mac,
                           interface="Vlan" + data.host2_vlan)
    arp_obj.delete_static_arp(dut=vars.D1,
                              ipaddress=data_tg_ip,
                              interface="Vlan" + data.host2_vlan,
                              mac=data.host2_mac)

    arp_obj.add_static_arp(dut=vars.D1,
                           ipaddress=data_tg_ip,
                           macaddress=data.host2_mac,
                           interface="Vlan" + data.host1_vlan)
    arp_obj.delete_static_arp(dut=vars.D1,
                              ipaddress=data_tg_ip,
                              interface="Vlan" + data.host1_vlan,
                              mac=data.host2_mac)

    mac_obj.config_mac(dut=vars.D1,
                       mac=data.host2_mac,
                       vlan=data.host1_vlan,
                       intf=vars.D1T1P2)
    arp_obj.add_static_arp(dut=vars.D1,
                           ipaddress=data_tg_ip,
                           macaddress=data.host2_mac,
                           interface="Vlan" + data.host1_vlan)

    mac_obj.delete_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan)
    mac_obj.config_mac(dut=vars.D1,
                       mac=data.host1_mac,
                       vlan=data.host1_vlan,
                       intf=vars.D1T1P1)
    l2_out = asicapi.get_l2_out(vars.D1, data.host2_mac)
    l3_out = asicapi.get_l3_out(vars.D1, data.host2_mac)
    if l2_out and l3_out:
        l2_gport = l2_out[0]["gport"][9]
        l3_port = l3_out[0]["port"]
        if l2_gport == l3_port:
            st.log("MAC {} points port {} correctly in both ARP and MAC table".
                   format(data.host2_mac, l2_gport))
        else:
            success = False
            st.error("MAC and ARP table are NOT in SYNC; "
                     "MAC {} points to gport {} in \"l2 show\""
                     "but in \"l3 egress show\" it is port {}".format(
                         data.host2_mac, l2_gport, l3_port))
    else:
        success = False
        st.error("MAC NOT present in \"l2 show\" or \"l3 egress show\" output")

    arp_obj.delete_static_arp(dut=vars.D1,
                              ipaddress=data_tg_ip,
                              interface="Vlan" + data.host1_vlan,
                              mac=data.host2_mac)
    mac_obj.delete_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan)
    mac_obj.delete_mac(dut=vars.D1, mac=data.host2_mac, vlan=data.host1_vlan)

    if success:
        st.report_pass("test_case_id_passed", "test_Ceta_31902")
    else:
        st.report_fail("test_case_id_failed", "test_Ceta_31902")
def test_ft_verify_static_portchannel_vlan_routing_l3_traffic():
    """
    Author: Venkatesh Terli <*****@*****.**>
    3.1.6 Verify that LAG can forward traffic when participating in VLAN Routing.
    """
    st.log(
        "verify that scenario - 3.1.6 Verify that LAG can forward traffic when participating in VLAN Routing."
    )

    exceptions = exec_all(
        True,
        [[
            ipobj.config_ip_addr_interface, vars.D1, 'Vlan{}'.format(
                static_data.vid), static_data.ip_addr_pc1, static_data.subnet
        ],
         [
             ipobj.config_ip_addr_interface, vars.D2, 'Vlan{}'.format(
                 static_data.vid), static_data.ip_addr_pc2, static_data.subnet
         ]])[1]
    ensure_no_exception(exceptions)

    exceptions = exec_all(
        True,
        [[delete_vlan_member, vars.D1, static_data.vid, vars.D1T1P1, True],
         [delete_vlan_member, vars.D2, static_data.vid, vars.D2T1P1, True]])[1]
    ensure_no_exception(exceptions)

    exceptions = exec_all(
        True, [[
            ipobj.config_ip_addr_interface, vars.D1, vars.D1T1P1,
            static_data.ip_addr_po1, static_data.subnet
        ],
               [
                   ipobj.config_ip_addr_interface, vars.D2, vars.D2T1P1,
                   static_data.ip_addr_po2, static_data.subnet
               ]])[1]
    ensure_no_exception(exceptions)

    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_1)
    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_3)
    stream = static_data.tg.tg_traffic_config(
        port_handle=static_data.tg_ph_1,
        mode='create',
        length_mode='fixed',
        mac_dst=static_data.dut1_rt_int_mac,
        mac_src='00:05:00:00:00:01',
        mac_src_mode='increment',
        mac_src_step='00:00:00:00:00:01',
        mac_dst_mode='fixed',
        ip_src_addr=static_data.ip41,
        ip_src_mode='increment',
        ip_src_count=static_data.ip_src_count,
        ip_src_step='0.0.0.1',
        mac_src_count=1000,
        ip_dst_addr=static_data.ip42,
        ip_dst_mode='fixed',
        pkts_per_burst=1000,
        l3_protocol='ipv4',
        transmit_mode='single_burst')
    static_data.streams['D1T1_SD_ip_Hash1'] = stream['stream_id']

    if not ipobj.verify_interface_ip_address(
            vars.D1, vars.D1T1P1, "{}/8".format(static_data.ip_addr_po1),
            static_data.ipv4):
        st.report_fail('ip_routing_int_create_fail', static_data.ip_addr_po1)
    if not ipobj.verify_interface_ip_address(
            vars.D2, vars.D2T1P1, "{}/8".format(static_data.ip_addr_po2),
            static_data.ipv4):
        st.report_fail('ip_routing_int_create_fail', static_data.ip_addr_po2)

    exceptions = exec_all(True,
                          [[
                              ipobj.create_static_route, vars.D1,
                              static_data.ip_addr_pc2, static_data.static_ip2
                          ],
                           [
                               ipobj.create_static_route, vars.D2,
                               static_data.ip_addr_pc1, static_data.static_ip1
                           ]])[1]
    ensure_no_exception(exceptions)
    st.wait(5)

    if not arpobj.add_static_arp(vars.D2,
                                 static_data.ip42,
                                 static_data.remote_mac2,
                                 interface=vars.D2T1P1):
        st.report_fail("msg", "Failed to configure static ARP")
    # ping from dut to partner
    ipobj.ping(vars.D1, static_data.ip_addr_pc2, family='ipv4', count=3)

    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    static_data.tg.tg_traffic_control(
        action='run', stream_handle=static_data.streams['D1T1_SD_ip_Hash1'])
    st.wait(2)
    static_data.tg.tg_traffic_control(
        action='stop', stream_handle=static_data.streams['D1T1_SD_ip_Hash1'])
    st.log("Verify that traffic is forwarding over portchannel members")
    verify_traffic_hashed_or_not(
        vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
        200,
        traffic_loss_verify=True,
        rx_port=vars.D1T1P1,
        tx_port=vars.D2T1P1,
        dut2=vars.D2)
    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_1)
    st.report_pass('portchannel_l3_vlan_routing_success',
                   static_data.portchannel_name)
Ejemplo n.º 4
0
def test_ft_arp_clear_cache_static_and_dynamic_entries(
        fixture_ft_arp_clear_cache_static_and_dynamic_entries):
    ################## Author Details ###############
    # Name: Rakesh Kumar Vooturi
    # Email: [email protected]
    #################################################
    #
    # Objective - Verify that the clearing the ARP cache,
    #             all dynamic entries are removed and static entries are not cleared.
    #
    ############### Test bed details ################
    #  TG-----DUT-----TG
    #################################################
    # Adding static arp entries
    arp_obj.add_static_arp(dut1, data.static_arp_ip_1, data.static_arp_mac_1,
                           vars.D1T1P1)
    arp_obj.add_static_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                           data.vlan_int_1)

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.d1t1_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_2"],
                            dev_handle=h2['handle'],
                            dst_ip=data.d1t2_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    # Verify static and dynamic arp entries
    st.log("Verifying the arp entries on the DUT")
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_create_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_create_fail", dut1)

    st.banner(
        "Start - Verifying dynamic and static arp entries behavior on issuing sonic-clear arp command *WITH* traffic flowing"
    )

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    #TG stream formation
    s1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"],
                              mode='create',
                              rate_pps=10,
                              mac_src=data.t2d1_mac_addr,
                              transmit_mode="continuous",
                              mac_dst=d1_mac_addr,
                              l2_encap='ethernet_ii_vlan',
                              l3_protocol="ipv4",
                              ip_dst_addr=data.t1d1_ip_addr,
                              ip_src_addr=data.t2d1_ip_addr,
                              vlan_id=data.vlan_1,
                              vlan="enable")
    s2 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                              mode='create',
                              rate_pps=10,
                              mac_src=data.t1d1_mac_addr,
                              transmit_mode="continuous",
                              mac_dst=d1_mac_addr,
                              l2_encap='ethernet_ii_vlan',
                              l3_protocol="ipv4",
                              ip_dst_addr=data.t2d1_ip_addr,
                              ip_src_addr=data.t1d1_ip_addr)

    tg.tg_traffic_control(action="run",
                          stream_handle=[s1['stream_id'], s2['stream_id']])

    # Adding wait for traffic to flow.
    st.wait(5)

    # Issuing sonic-clear arp command and veryfying the entries behavior.
    arp_obj.clear_arp_table(dut1)

    # Adding wait for traffic to flow.
    st.wait(5)

    # Verify static and dynamic arp entries after clear arp
    st.log(
        "Verifying the arp entries on the DUT after issuing sonic-clear arp command with traffic flowing."
    )
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_delete_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_delete_fail", dut1)

    # Stop the traffic
    tg.tg_traffic_control(action="stop",
                          stream_handle=[s1['stream_id'], s2['stream_id']])

    st.log("Verifying the TG stats")

    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P2],
            'tx_obj': [tg],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D1P1],
            'rx_obj': [tg],
        }
    }
    if not tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                       mode='aggregate',
                                       comp_type='packet_count'):
        st.report_fail("traffic_verification_failed")
    else:
        st.log("traffic verification passed")

    st.banner(
        "End - Verified dynamic and static arp entries behavior on issuing sonic-clear arp command *WITH* traffic flowing"
    )

    st.banner(
        "Start - Verifying dynamic and static arp entries behavior on issuing sonic-clear arp command *WITHOUT* traffic flowing"
    )
    # Issuing sonic-clear arp command and veryfying the entries behavior.
    arp_obj.clear_arp_table(dut1)

    # Verify static and dynamic arp entries after clear arp
    st.log(
        "Verifying the arp entries on the DUT after issuing sonic-clear arp command"
    )
    if arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                          vars.D1T1P1):
        st.report_fail("ARP_dynamic_entry_clear_arp_fail", data.t1d1_ip_addr,
                       dut1)
    if arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                          vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_dynamic_entry_clear_arp_fail", data.t2d1_ip_addr,
                       dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_delete_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_delete_fail", dut1)

    st.banner(
        "End - Verified dynamic and static arp entries behavior on issuing sonic-clear arp command *WITHOUT* traffic flowing"
    )

    st.report_pass("test_case_passed")
def dut2_config():

    result = True
    st.log('On DUT2 configure loopback')
    result = ip_obj.configure_loopback(data.dut2,
                                       config='yes',
                                       loopback_name=[
                                           data.dut2_loopback[0],
                                           data.dut2_loopback[1],
                                           data.dut2_loopback[2]
                                       ])

    st.log('On DUT2 configure vlan')
    result = vlan_obj.create_vlan(data.dut2, data.dut1_dut2_vlan[0])
    result = vlan_obj.add_vlan_member(data.dut2, data.dut1_dut2_vlan[0],
                                      data.d2_d1_ports[1], True, True)

    st.log('On DUT2 configure portchannel')
    result = pc_obj.create_portchannel(data.dut2, data.portchannel)
    result = pc_obj.add_portchannel_member(
        data.dut2, data.portchannel,
        [data.d2_d1_ports[2], data.d2_d1_ports[3]])

    st.log(
        'On DUT2 configure OSPF router ID, ospf networks and add all the ospf interfaces'
    )
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[0],
                                             data.dut2_loopback_ipv6[0],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[0],
                                             data.dut2_loopback_ip[0],
                                             data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[1],
                                             data.dut2_loopback_ipv6[1],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[1],
                                             data.dut2_loopback_ip[1],
                                             data.ip_loopback_prefix, 'ipv4')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[2],
                                             data.dut2_loopback_ipv6[2],
                                             data.ipv6_loopback_prefix, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_loopback[2],
                                             data.dut2_loopback_ip[2],
                                             data.ip_loopback_prefix, 'ipv4')

    st.log(
        'On DUT2 configure OSPF router ID, ospf networks and add all the ospf interfaces'
    )
    result = ospf_obj.config_ospf_router_id(data.dut2,
                                            data.dut2_ospf_router_id,
                                            'default', '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut2, data.dut2_loopback_ip[0] + '/' + data.ip_loopback_prefix, 0,
        'default', '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut2, data.dut2_loopback_ip[1] + '/' + data.ip_loopback_prefix, 0,
        'default', '', 'yes')
    result = ospf_obj.config_ospf_network(
        data.dut2, data.dut2_loopback_ip[2] + '/' + data.ip_loopback_prefix, 0,
        'default', '', 'yes')
    result = ospf_obj.config_ospf_network(data.dut2, data.dut2_tg1_network_v4,
                                          0, 'default', '', 'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut2, data.d2_d1_ports[0], 'point-to-point', 'default', 'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut2, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point',
        'default', 'yes')
    result = ospf_obj.config_interface_ip_ospf_network_type(
        data.dut2, data.portchannel, 'point-to-point', 'default', 'yes')

    st.log('On DUT2 configure IP addresses on DUT2 - TG interfaces')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_tg_ports[0],
                                             data.dut2_tg_ipv6[0],
                                             data.tg_ipv6_subnet, 'ipv6')
    result = ip_obj.config_ip_addr_interface(data.dut2, data.dut2_tg_ports[0],
                                             data.dut2_tg_ip[0],
                                             data.tg_ip_subnet, 'ipv4')
    result = arp_obj.add_static_arp(data.dut2, data.tg_dut2_ip[0],
                                    '00:00:33:33:33:01', data.dut2_tg_ports[0])

    return result
Ejemplo n.º 6
0
def acl_v4_module_hooks(request):
    # initialize topology
    initialize_topology()

    # apply module configuration
    apply_module_configuration()

    acl_config1 = acl_data.acl_json_config_v4_l3_traffic
    add_port_to_acl_table(acl_config1, 'L3_IPV4_INGRESS', vars.D1T1P1)


    acl_config2 = acl_data.acl_json_config_v6_l3_traffic
    add_port_to_acl_table(acl_config2, 'L3_IPV6_INGRESS', vars.D2T1P1)


    # creating ACL tables and rules
    print_log('Creating ACL tables and rules')
    utils.exec_all(True, [
        utils.ExecAllFunc(acl_obj.apply_acl_config, vars.D1, acl_config1),
        utils.ExecAllFunc(acl_obj.apply_acl_config, vars.D2, acl_config2),
    ])

    # create streams
    data.mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    data.mac2 = basic_obj.get_ifconfig_ether(vars.D2, vars.D2T1P1)
    print_log('Creating streams')
    create_streams("tg1", "tg2", acl_config1['ACL_RULE'], "L3_IPV4_INGRESS", \
                   mac_src="00:0a:01:00:00:01", mac_dst=data.mac1)
    create_streams("tg1", "tg2", acl_config2['ACL_RULE'], "L3_IPV6_EGRESS", \
                   mac_src="00:0a:01:00:00:01", mac_dst="00:0a:01:00:11:02")
    create_streams("tg2", "tg1", acl_config2['ACL_RULE'], "L3_IPV6_INGRESS", \
                   mac_src="00:0a:01:00:11:02", mac_dst=data.mac2)
    create_streams("tg2", "tg1", acl_config1['ACL_RULE'], "L3_IPV4_EGRESS", \
                   mac_src="00:0a:01:00:11:02", mac_dst="00:0a:01:00:00:01")
    print_log('Completed module configuration')

    st.log("Configuring ipv4 address on ixia connected interfaces and portchannels present on both the DUTs")
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.ipv4_address_D1, 24, family="ipv4", config='add')
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2T1P1, data.ipv4_address_D2, 24, family="ipv4", config='add')
    ip_obj.config_ip_addr_interface(vars.D1, data.portChannelName, data.ipv4_portchannel_D1, 24, family="ipv4",
                                    config='add')
    ip_obj.config_ip_addr_interface(vars.D2, data.portChannelName, data.ipv4_portchannel_D2, 24, family="ipv4",
                                    config='add')

    st.log("Configuring ipv6 address on ixia connected interfaces and portchannels present on both the DUTs")
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.ipv6_address_D1, 64, family="ipv6", config='add')
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2T1P1, data.ipv6_address_D2, 64, family="ipv6", config='add')
    ip_obj.config_ip_addr_interface(vars.D1, data.portChannelName, data.ipv6_portchannel_D1, 64, family="ipv6",
                                    config='add')
    ip_obj.config_ip_addr_interface(vars.D2, data.portChannelName, data.ipv6_portchannel_D2, 64, family="ipv6",
                                    config='add')

    st.log("configuring ipv4 static routes on both the DUTs")
    ip_obj.create_static_route(vars.D1, data.ipv4_portchannel_D2, data.ipv4_network_D2, shell="vtysh",
                               family="ipv4")
    ip_obj.create_static_route(vars.D2, data.ipv4_portchannel_D1, data.ipv4_network_D1, shell="vtysh",
                               family="ipv4")

    st.log("configuring ipv6 static routes on both the DUTs")
    ip_obj.create_static_route(vars.D1, data.ipv6_portchannel_D2, data.ipv6_network_D2, shell="vtysh",
                               family="ipv6")
    ip_obj.create_static_route(vars.D2, data.ipv6_portchannel_D1, data.ipv6_network_D1, shell="vtysh",
                               family="ipv6")

    st.log("configuring static arp entries")
    arp_obj.add_static_arp(vars.D1, "1.1.1.2", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.2", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.4", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.4", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.5", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.5", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.6", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.6", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.show_arp(vars.D1)
    arp_obj.show_arp(vars.D2)

    st.log("configuring static ndp entries")
    arp_obj.config_static_ndp(vars.D1, "1001::2", "00:0a:01:00:00:01", vars.D1T1P1, operation="add")
    arp_obj.config_static_ndp(vars.D2, "2001::2", "00:0a:01:00:11:02", vars.D2T1P1, operation="add")
    arp_obj.show_ndp(vars.D1)
    arp_obj.show_ndp(vars.D2)

    yield
    clear_module_configuration()
Ejemplo n.º 7
0
def common_config(request):
    global dut1, r1_tg_ports1, r1_tg_ports2
    global tg_r1_hw_port1, tg_r1_hw_port2
    global tg1, tg2, tg_dut1_p1_handle, tg_dut1_p2_handle
    global r1tg1_1_ipAddr, r1tg2_1_ipAddr
    global nextHop_ip, nextHop_ipv6
    global static_macAdd
    global r1tg1_1_ipv6Addr, r1tg2_1_ipv6Addr
    global subnetMask, subnetMaskv6
    global Vlan, maskACL
    global acl_table_name, acl_table_namev6
    global description, descriptionv6
    global type, typev6
    global stage, expCount, pktrate, pktAction
    global srpIP, dstIP, srpIPv6, dstIPv6
    global rule_list, priority_list
    vars = st.ensure_min_topology("D1T1:2")
    dut1 = vars.D1
    r1_tg_ports1 = vars.D1T1P1
    r1_tg_ports2 = vars.D1T1P2
    tg_r1_hw_port1 = vars.T1D1P1
    tg_r1_hw_port2 = vars.T1D1P2
    tg1, tg_dut1_p1_handle = tgapi.get_handle_byname("T1D1P1")
    tg2, tg_dut1_p2_handle = tgapi.get_handle_byname("T1D1P2")
    r1tg1_1_ipAddr = '30.30.30.1'
    r1tg2_1_ipAddr = '20.20.20.1'
    nextHop_ip = '20.20.20.100'
    nextHop_ipv6 = '3001::100'
    static_macAdd = '00:0a:01:00:11:02'
    r1tg1_1_ipv6Addr = '2001::10'
    r1tg2_1_ipv6Addr = '3001::10'
    subnetMask = '24'
    subnetMaskv6 = '64'
    Vlan = '100'
    maskACL = '32'
    acl_table_name = 'ACL0'
    acl_table_namev6 = 'ACL1'
    description = 'IPv4_ACL_redirect_port'
    descriptionv6 = 'IPv6_ACL_redirect_port'
    type = 'L3'
    typev6 = 'L3V6'
    stage = 'INGRESS'
    expCount = '1000'
    pktrate = '1000'
    pktAction = 'redirect:'
    srpIP = '1.1.1.3'
    dstIP = '3.3.3.1'
    srpIPv6 = '1234::1'
    dstIPv6 = '5001::1'
    rule_list = [
        'rule_1', 'rule_2', 'rule_3', 'rule_4', 'rule_5', 'rule_6', 'rule_7',
        'rule_8', 'rule_9', 'rule_10'
    ]
    priority_list = ['10', '9', '8', '7', '6', '5', '4', '3', '2', '1']

    st.log("Bring Up the required topology for the test to run")
    port.noshutdown(dut1, [r1_tg_ports1, r1_tg_ports2])
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports1,
                                       ip_address=r1tg1_1_ipAddr,
                                       subnet=subnetMask,
                                       family="ipv4")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports2,
                                       ip_address=r1tg2_1_ipAddr,
                                       subnet=subnetMask,
                                       family="ipv4")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports1,
                                       ip_address=r1tg1_1_ipv6Addr,
                                       subnet=subnetMaskv6,
                                       family="ipv6")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports2,
                                       ip_address=r1tg2_1_ipv6Addr,
                                       subnet=subnetMaskv6,
                                       family="ipv6")

    st.log("Create static arp on dut1")
    arp_obj.add_static_arp(dut1, nextHop_ip, static_macAdd)
    st.log("Create static ndp on dut1")
    arp_obj.config_static_ndp(dut1, nextHop_ipv6, static_macAdd, r1_tg_ports2)

    st.log("Get the device MAC- dut1")
    routing_mac = mapi.get_sbin_intf_mac(dut1, r1_tg_ports1)

    st.log("Create host on the Traffic generator")
    create_trafficStreams(tg1,
                          tg2,
                          tg_dut1_p1_handle,
                          tg_dut1_p2_handle,
                          rate=pktrate,
                          rule='forward',
                          dstMAC=routing_mac)

    yield
    # add things at the end of this module"
    arp_obj.delete_static_arp(dut1, nextHop_ip, static_macAdd)
    arp_obj.clear_ndp_table(dut1)
    st.log("Delete  interface config on dut1")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports1,
                                  ip_address=r1tg1_1_ipAddr,
                                  subnet=subnetMask,
                                  family="ipv4")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports2,
                                  ip_address=r1tg2_1_ipAddr,
                                  subnet=subnetMask,
                                  family="ipv4")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports1,
                                  ip_address=r1tg1_1_ipv6Addr,
                                  subnet=subnetMaskv6,
                                  family="ipv6")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports2,
                                  ip_address=r1tg2_1_ipv6Addr,
                                  subnet=subnetMaskv6,
                                  family="ipv6")
    port.shutdown(dut1, [r1_tg_ports1, r1_tg_ports2])