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)
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 portchannel_func_hooks(request): yield if st.get_func_name( request ) == 'test_ft_verify_static_portchannel_is_up_or_not_with_one_active_member': portchannelobj.add_del_portchannel_member(vars.D1, static_data.portchannel_name, static_data.members_dut1[1:]) if st.get_func_name( request ) == 'test_ft_verify_static_portchannel_is_up_with_active_members_when_no_lag_in_partner': portchannelobj.create_portchannel(vars.D2, static_data.portchannel_name, static=True) portchannelobj.add_del_portchannel_member(vars.D2, static_data.portchannel_name, static_data.members_dut2) add_vlan_member(vars.D2, static_data.vid, static_data.portchannel_name, tagging_mode=True) if st.get_func_name( request ) == 'test_ft_verify_fallback_is_configure_or_not_on_static_portchannel': if portchannelobj.get_portchannel(vars.D1, static_data.portchannel_name2): portchannelobj.delete_portchannel(vars.D1, static_data.portchannel_name2) if st.get_func_name( request ) == 'test_ft_verify_static_portchannel_del_from_ip_assigned_vlan': st.wait(2) ipobj.config_ip_addr_interface(vars.D1, 'Vlan{}'.format(static_data.vid), static_data.ip41, static_data.ip_mask, config='remove') portchannelobj.add_del_portchannel_member(vars.D1, static_data.portchannel_name, static_data.members_dut1) if st.get_func_name(request) == 'test_ft_del_ip_assigned_portchannel': if not portchannelobj.get_portchannel(vars.D1, static_data.portchannel_name): portchannelobj.create_portchannel(vars.D1, static_data.portchannel_name, static=True) ipobj.delete_ip_interface(vars.D1, static_data.portchannel_name, static_data.ip41, static_data.ip_mask, skip_error=True) portchannelobj.add_del_portchannel_member(vars.D1, static_data.portchannel_name, static_data.members_dut1) exceptions = exec_all(True, [[ add_vlan_member, vars.D1, static_data.vid, static_data.portchannel_name, True ], [ add_vlan_member, vars.D2, static_data.vid, static_data.portchannel_name, True ]])[1] ensure_no_exception(exceptions) if st.get_func_name( request ) == 'test_ft_verify_static_portchannel_l3_hash_sip_dip_l4port': arpobj.delete_static_arp(vars.D2, static_data.ip42, interface=vars.D2T1P1, mac=static_data.remote_mac2) ipobj.clear_ip_configuration([vars.D1, vars.D2], family='ipv4', thread=True) exceptions = exec_all( True, [[ add_vlan_member, vars.D1, static_data.vid, [static_data.portchannel_name, vars.D1T1P1], True ], [ add_vlan_member, vars.D2, static_data.vid, [static_data.portchannel_name, vars.D2T1P1], True ]])[1] ensure_no_exception(exceptions) if st.get_func_name( request ) == 'test_ft_verify_static_portchannel_vlan_routing_l3_traffic': arpobj.delete_static_arp(vars.D2, static_data.ip42, interface=vars.D2T1P1, mac=static_data.remote_mac2) ipobj.clear_ip_configuration([vars.D1, vars.D2], family='ipv4', thread=True) exceptions = exec_all(True, [[ add_vlan_member, vars.D1, static_data.vid, vars.D1T1P1, True ], [add_vlan_member, vars.D2, static_data.vid, vars.D2T1P1, True]])[1] ensure_no_exception(exceptions)
def fixture_ft_arp_clear_cache_static_and_dynamic_entries(request): yield arp_obj.delete_static_arp(dut1, data.static_arp_ip) arp_obj.delete_static_arp(dut1, data.static_arp_ip_1)
def dut2_unconfig(): result = 0 st.log('On Configure IP addresses on DUT2 - TG interfaces') result = ip_obj.delete_ip_interface(data.dut2, data.dut2_tg_ports[0], data.dut2_tg_ipv6[0], data.tg_ipv6_subnet, 'ipv6') result = ip_obj.delete_ip_interface(data.dut2, data.dut2_tg_ports[0], data.dut2_tg_ip[0], data.tg_ip_subnet, 'ipv4') result = arp_obj.config_static_ndp(data.dut2, data.tg_dut2_ipv6[0], '00:00:33:33:33:02', data.dut2_tg_ports[0], operation="del") result = arp_obj.delete_static_arp(data.dut2, data.tg_dut2_ip[0], '00:00:33:33:33:01') st.log( 'On DUT2 unconfigure OSPF router ID, ospf networks and add all the ospf interfaces' ) result = ospf_obj.config_interface_ip_ospf_network_type( data.dut2, data.d2_d1_ports[0], 'point-to-point', 'default', 'no') result = ospf_obj.config_interface_ip_ospf_network_type( data.dut2, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point', 'default', 'no') result = ospf_obj.config_interface_ip_ospf_network_type( data.dut2, data.portchannel, 'point-to-point', 'default', 'no') result = ospf_obj.config_ospf_network( data.dut2, data.dut2_loopback_ip[0] + '/' + data.ip_loopback_prefix, 0, 'default', '', 'no') result = ospf_obj.config_ospf_router_id(data.dut2, data.dut2_ospf_router_id, 'default', '', 'no') st.log( 'On DUT2 unconfigure loopback and remove IPv4 and IPv6 addresses on it' ) result = ip_obj.delete_ip_interface(data.dut2_server, data.dut2_loopback[0], data.dut2_loopback_ipv6[0], data.dut2_loopback_ipv6_subnet, 'ipv6') result = ip_obj.delete_ip_interface(data.dut2_server, data.dut2_loopback[0], data.dut2_loopback_ip[0], data.dut2_loopback_ip_subnet, 'ipv4') result = ip_obj.configure_loopback(data.dut2_server, config='no', loopback_name=data.dut2_loopback[0]) st.log( 'On DUT2 unconfigure portchannel and remove IPv4 and IPv6 addresses on it' ) result = ip_obj.delete_ip_interface(data.dut2_server, data.portchannel, data.dut2_dut1_ipv6[2], data.dut2_dut1_ipv6_subnet, 'ipv6') result = ip_obj.delete_ip_interface(data.dut2_server, data.portchannel, data.dut2_dut1_ip[2], data.dut2_dut1_ip_subnet, 'ipv4') result = pc_obj.add_del_portchannel_member( data.dut2_server, data.portchannel, [data.d2_d1_ports[2], data.d2_d1_ports[3]], 'del') result = pc_obj.delete_portchannel(data.dut2_server, data.portchannel) st.log('On DUT2 unconfigure vlan and remove IPv4 and IPv6 addresses on it') result = ip_obj.delete_ip_interface(data.dut2, 'Vlan' + data.dut1_dut2_vlan[0], data.dut2_dut1_ipv6[1], data.dut2_dut1_ipv6_subnet, 'ipv6') result = ip_obj.delete_ip_interface(data.dut2, 'Vlan' + data.dut1_dut2_vlan[0], data.dut2_dut1_ip[1], data.dut2_dut1_ip_subnet, 'ipv4') result = vlan_obj.delete_vlan_member(data.dut2, data.dut1_dut2_vlan[0], data.d2_d1_ports[1], True) result = vlan_obj.delete_vlan(data.dut2, data.dut1_dut2_vlan[0]) st.log('On DUT2 remove IPv4 and IPv6 addresses on physical interface') result = ip_obj.delete_ip_interface(data.dut2, data.d2_d1_ports[0], data.dut2_dut1_ipv6[0], data.dut2_dut1_ipv6_subnet, 'ipv6') result = ip_obj.delete_ip_interface(data.dut2, data.d2_d1_ports[0], data.dut2_dut1_ip[0], data.dut2_dut1_ip_subnet, 'ipv4') return result
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])