def create_glob_vars(): global vars vars = st.ensure_min_topology("D1D2:2", "D2D3:2", "D1T1:1", "D3T1:1") tg_dict["tg"], tg_dict["d1_tg_ph1"] = tgapi.get_handle_byname("T1D1P1") tg_dict["tg"], tg_dict["d3_tg_ph1"] = tgapi.get_handle_byname("T1D3P1") tg_dict["d1_tg_port1"], tg_dict["d3_tg_port1"] = vars.T1D1P1, vars.T1D3P1 tg_dict["tgen_rate_pps"] = '1000' tg_dict["l3_len"] = '512' tg_dict["duration"] = 5 acl_dict["dut_list"] = [vars.D1, vars.D2, vars.D3] acl_dict["dut1"]["intf_list_tg"] = [vars.D1T1P1] acl_dict["dut1"]["intf_list_dut2"] = [vars.D1D2P1, vars.D1D2P2] acl_dict["dut2"]["intf_list_tg"] = [vars.D2T1P1] acl_dict["dut2"]["intf_list_dut1"] = [vars.D2D1P1, vars.D2D1P2] acl_dict["dut2"]["intf_list_dut3"] = [vars.D2D3P1, vars.D2D3P2] acl_dict["dut3"]["intf_list_tg"] = [vars.D3T1P1] acl_dict["dut3"]["intf_list_dut2"] = [vars.D3D2P1, vars.D3D2P2] acl_dict["dut1_gw_mac"] = basic.get_ifconfig(vars.D1, vars.D1T1P1)[0]['mac'] acl_dict["dut3_gw_mac"] = basic.get_ifconfig(vars.D3, vars.D3T1P1)[0]['mac'] d1_out = st.get_credentials(vars.D1) d3_out = st.get_credentials(vars.D3) acl_dict["d1_uname"] = d1_out[0] acl_dict["d3_uname"] = d3_out[0] acl_dict["d1_pwd"] = d1_out[3] acl_dict["d3_pwd"] = d3_out[3] tg_dict["live_stream"] = ""
def interface_module_hooks(request): global vars vars = st.ensure_min_topology("D1D2:2", "D1T1:2") initialize_variables() if not vlanapi.create_vlan(vars.D1, intf_data.vlan_id): st.report_fail("vlan_create_fail", intf_data.vlan_id) if not vlanapi.add_vlan_member(vars.D1, intf_data.vlan_id, [vars.D1T1P1, vars.D1T1P2]): st.report_fail("vlan_untagged_member_fail", [vars.D1T1P1, vars.D1T1P2], intf_data.vlan_id) st.log("Getting TG handlers") _, intf_data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") _, intf_data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2") intf_data.tg = tgapi.get_chassis(vars) st.log("Reset and clear statistics of TG ports") intf_data.tg.tg_traffic_control(action='reset', port_handle=[intf_data.tg_ph_1, intf_data.tg_ph_2]) intf_data.tg.tg_traffic_control(action='clear_stats', port_handle=[intf_data.tg_ph_1, intf_data.tg_ph_2]) st.log("Creating TG streams") intf_data.streams = {} stream = intf_data.tg.tg_traffic_config(port_handle=intf_data.tg_ph_1, mode='create', port_handle2=intf_data.tg_ph_2, length_mode='fixed', rate_pps=100, frame_size=intf_data.mtu1, l2_encap='ethernet_ii_vlan', transmit_mode='single_burst', pkts_per_burst=100, vlan_id=intf_data.vlan_id, mac_src=intf_data.source_mac, mac_dst=intf_data.destination_mac, vlan="enable") st.log('Stream output:{}'.format(stream)) intf_data.streams['mtu1'] = stream['stream_id'] stream = intf_data.tg.tg_traffic_config(port_handle=intf_data.tg_ph_1, mode='create', port_handle2=intf_data.tg_ph_2, length_mode='fixed', rate_pps=100, frame_size=intf_data.mtu2, l2_encap='ethernet_ii_vlan', transmit_mode='single_burst', pkts_per_burst=100, vlan_id=intf_data.vlan_id, mac_src=intf_data.source_mac, mac_dst=intf_data.destination_mac, vlan="enable") st.log('Stream output:{}'.format(stream)) intf_data.streams['mtu2'] = stream['stream_id'] stream = intf_data.tg.tg_traffic_config(port_handle=intf_data.tg_ph_1, mode='create', length_mode='fixed', frame_size='5000', transmit_mode='continuous') st.log('Stream output:{}'.format(stream)) intf_data.streams['traffic_tg1'] = stream['stream_id'] stream = intf_data.tg.tg_traffic_config(port_handle=intf_data.tg_ph_2, mode='create', length_mode='fixed', frame_size='5000', transmit_mode='continuous') st.log('Stream output:{}'.format(stream)) intf_data.streams['traffic_tg2'] = stream['stream_id'] yield vlanapi.clear_vlan_configuration(st.get_dut_names(), thread=True) # intf_data.tg.tg_traffic_control(action='stop', port_handle=[intf_data.tg_ph_1, intf_data.tg_ph_2]) intf_data.tg.tg_traffic_control(action='reset', port_handle=[intf_data.tg_ph_1, intf_data.tg_ph_2])
def static_port_channel_tg_config(): st.log("Getting TG handlers") static_data.tg1, static_data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") static_data.tg3, static_data.tg_ph_3 = tgapi.get_handle_byname("T1D2P1") static_data.tg = static_data.tg1 st.log("Reset and clear statistics of TG ports") static_data.tg.tg_traffic_control( action='reset', port_handle=[static_data.tg_ph_1, static_data.tg_ph_3]) static_data.tg.tg_traffic_control( action='clear_stats', port_handle=[static_data.tg_ph_1, static_data.tg_ph_3]) st.log("Creating TG streams") static_data.streams = {} stream = static_data.tg.tg_traffic_config(port_handle=static_data.tg_ph_1, mode='create', length_mode='fixed', frame_size=72, mac_src='00:00:01:00:00:01', mac_src_step='00:00:00:00:00:01', mac_src_mode='increment', mac_src_count=100, mac_dst='00:00:02:00:00:02', mac_dst_step='00:00:00:00:00:01', mac_dst_mode='increment', mac_dst_count=100, rate_percent=100, l2_encap='ethernet_ii_vlan', vlan="enable", vlan_id=static_data.vid, transmit_mode='continuous') static_data.streams['D1T1_SD_Mac_Hash1'] = stream['stream_id'] stream = static_data.tg.tg_traffic_config(port_handle=static_data.tg_ph_3, mode='create', length_mode='fixed', frame_size=72, mac_src='00:01:00:00:00:01', mac_src_step='00:00:00:00:00:01', mac_src_mode='increment', mac_src_count=100, mac_dst='00:02:00:00:00:02', mac_dst_step='00:00:00:00:00:01', mac_dst_mode='increment', mac_dst_count=100, rate_percent=100, l2_encap='ethernet_ii_vlan', vlan="enable", vlan_id=static_data.vid, transmit_mode='continuous') static_data.streams['D2T1_SD_Mac_Hash1'] = stream['stream_id']
def create_glob_vars(): global vars, tg, tg_ph_1, tg_ph_2, tg_ph_3, tg_ph_4 global d1_p1, d1_p2, d2_p1, d2_p2, d1_d2_p1, d2_d1_p1 vars = st.ensure_min_topology("D1T1:2", "D2T1:2", "D1D2:1") tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg2, tg_ph_2 = tgapi.get_handle_byname("T1D1P2") tg3, tg_ph_3 = tgapi.get_handle_byname("T1D2P1") tg4, tg_ph_4 = tgapi.get_handle_byname("T1D2P2") tg = tg1 st.unused(tg2, tg3, tg4) d1_p1, d1_p2 = vars.D1T1P1, vars.D1T1P2 d2_p1, d2_p2 = vars.D2T1P1, vars.D2T1P2 d1_d2_p1, d2_d1_p1 = vars.D1D2P1, vars.D2D1P1
def erspan_module_hooks(request): # add things at the start of this module global vars, h1, h2, h3, h1_ipv6, h2_ipv6, dut_mac # Ensure Min topology and read the port details. vars = st.ensure_min_topology("D1D2:1", "D1T1:2", "D2T1:1") data.tg1, data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") data.tg2, data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2") data.tg3, data.tg_ph_3 = tgapi.get_handle_byname("T1D2P1") data.port_list_d1 = [vars.D1T1P1, vars.D1T1P2, vars.D1D2P1] data.port_list_d2 = [vars.D2D1P1, vars.D2T1P1] # Applying Module configuration erspan_pre_config() st.log("######Verifying Pre_Configurtion on DUT#######") if not erspan_pre_config_verify(): st.report_fail("module_config_verification_failed") dut_mac = basic.get_ifconfig_ether(vars.D1, vars.D1T1P1) if not dut_mac: st.log("Unable to get MAC address of {}".format(vars.D1T1P1)) st.report_fail("module_config_failed"," for erspan") # Creating IPv4 routing interfaces on TG ports h1=data.tg1.tg_interface_config(port_handle=data.tg_ph_1, mode='config', intf_ip_addr=data.ip_T1D1P1, gateway=data.ip_D1T1P1, netmask=data.sub_mask, count=3, arp_send_req='1') h2=data.tg2.tg_interface_config(port_handle=data.tg_ph_2, mode='config', intf_ip_addr=data.ip_T1D1P2, gateway=data.ip_D1T1P2, netmask=data.sub_mask, count=3, arp_send_req='1') h3=data.tg3.tg_interface_config(port_handle=data.tg_ph_3, mode='config', intf_ip_addr=data.ip_T1D2P1, gateway=data.ip_D2T1P1, netmask=data.sub_mask, count=3, arp_send_req='1') # Creating IPv6 routing interfaces on TG ports h1_ipv6 = data.tg1.tg_interface_config(port_handle=data.tg_ph_1, mode='config', ipv6_intf_addr='2001:1::100', ipv6_prefix_length='64', ipv6_gateway='2001:1::1', src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') h2_ipv6 = data.tg2.tg_interface_config(port_handle=data.tg_ph_2, mode='config', ipv6_intf_addr='2001:2::100', ipv6_prefix_length='64', ipv6_gateway='2001:2::1', src_mac_addr='00:0b:01:00:00:01', arp_send_req='1') yield # add things at the end of this module" erspan_post_config() data.tg1.tg_interface_config(port_handle=data.tg_ph_1, handle=h1['handle'], mode='destroy') data.tg2.tg_interface_config(port_handle=data.tg_ph_2, handle=h2['handle'], mode='destroy') data.tg3.tg_interface_config(port_handle=data.tg_ph_3, handle=h3['handle'], mode='destroy') data.tg1.tg_interface_config(port_handle=data.tg_ph_1, handle=h1_ipv6['handle'], mode='destroy') data.tg2.tg_interface_config(port_handle=data.tg_ph_2, handle=h2_ipv6['handle'], mode='destroy')
def tg_bgp_config(vars, local_asn, remote_asn): tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) h1 = tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr=data.t1d1_ip_addr, gateway=data.d1t1_ip_addr, src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') st.log("INTFCONF: " + str(h1)) # Configuring BGP device on top of interface. bgp_conf = tg1.tg_emulation_bgp_config(handle=h1['handle'], mode='enable', active_connect_enable='1', local_as=data.local_asn4, remote_as=data.local_asn4, remote_ip_addr=data.d1t1_ip_addr, enable_4_byte_as='1') st.log("BGPCONF: " + str(bgp_conf)) # Adding routes to BGP device. bgp_route = tg1.tg_emulation_bgp_route_config(handle=bgp_conf['handle'], mode='add', num_routes='100', prefix='172.168.1.0') st.log("BGPROUTE: " + str(bgp_route))
def copp_module_hooks(request): global vars, tg, tg_ph_1, d1_p1, hw_constants, deviation_percentage, d1_p1_mac, copp_data, vlan_igmp, copp_data_pir vars = st.ensure_min_topology("D1T1:1") hw_constants = st.get_datastore(vars.D1, "constants", "default") st.debug("hw_constants: {}".format(hw_constants)) tg, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") d1_p1 = vars.D1T1P1 vlan_igmp = 3188 vlan_obj.create_vlan(vars.D1, vlan_igmp) deviation_percentage = 0.05 ret_val = copp_obj.get_copp_config(dut=vars.D1, table_name='all') if ret_val: copp_data = ret_val else: st.report_fail('module_config_failed', 'show copp config command failed') copp_data_pir = copp_obj.set_copp_pir_config(vars.D1, config='get') # Get the DUT mac address d1_p1_mac = basic_obj.get_ifconfig(vars.D1, d1_p1)[0]['mac'] # Config the routing interface ip_obj.config_ip_addr_interface(dut=vars.D1, interface_name=d1_p1, ip_address='1.1.1.2', subnet='24') yield # Un-configure the routing interface ip_obj.delete_ip_interface(dut=vars.D1, interface_name=d1_p1, ip_address='1.1.1.2', subnet='24') vlan_obj.delete_vlan(vars.D1, vlan_igmp)
def tg_links_status_1(): results = dict() for dut in st.get_dut_names(): for local, partner, remote in st.get_tg_links(dut): (tg, ph) = tgapi.get_handle_byname(None, tg=partner, port=remote) name = "{}--{}".format(partner, remote) results[name] = get_link_status(tg, ph) return results
def tg_links_status_using_hltapi(): results = dict() for dut in st.get_dut_names(): for _, partner, remote in st.get_tg_links(dut, native=use_native): (tg, ph) = tgapi.get_handle_byname(None, tg=partner, port=remote) name = "{}--{}".format(partner, remote) results[name] = get_tg_link_status(tg, ph) return results
def erspan_long_run_module_hooks(request): # add things at the start of this module global vars, h1, h2, h3 vars = st.ensure_min_topology("D1D2:1", "D1T1:2", "D2T1:1") data.dut1 = vars.D1 data.dut2 = vars.D2 data.tg1, data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") data.tg2, data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2") data.tg3, data.tg_ph_3 = tgapi.get_handle_byname("T1D2P1") data.port_list_d1 = [vars.D1T1P1, vars.D1T1P2, vars.D1D2P1] data.port_list_d2 = [vars.D2D1P1, vars.D2T1P1] st.log("Configuring ERSPAN") erspan_pre_config() h1 = data.tg1.tg_interface_config(port_handle=data.tg_ph_1, mode='config', intf_ip_addr=data.ip_T1D1P1, gateway=data.ip_D1T1P1, netmask=data.sub_mask) h2 = data.tg2.tg_interface_config(port_handle=data.tg_ph_2, mode='config', intf_ip_addr=data.ip_T1D1P2, gateway=data.ip_D1T1P2, netmask=data.sub_mask) h3 = data.tg3.tg_interface_config(port_handle=data.tg_ph_3, mode='config', intf_ip_addr=data.ip_T1D2P1, gateway=data.ip_D2T1P1, netmask=data.sub_mask) st.log("ERSPAN verification") erspan_pre_config_verify() tg_stream_config() yield # add things at the end of this module" erspan_post_config() data.tg1.tg_interface_config(port_handle=data.tg_ph_1, handle=h1['handle'], mode='destroy') data.tg2.tg_interface_config(port_handle=data.tg_ph_2, handle=h2['handle'], mode='destroy') data.tg3.tg_interface_config(port_handle=data.tg_ph_3, handle=h3['handle'], mode='destroy')
def get_handles(): ''' ######################## Topology ############################ +---------+ +-------+ | +------------------+ | TG1 -----| DUT1 | portchannel | DUT2 +----- TG2 | +------------------+ | +---------+ +-------+ ############################################################## ''' global vars vars = st.ensure_min_topology("D1D2:2", "D1T1:1", "D2T1:1") tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg2, tg_ph_2 = tgapi.get_handle_byname("T1D2P1") if tg1.tg_type == 'stc': data.tg_type = 'stc' tg1.tg_traffic_control(action="reset", port_handle=tg_ph_1) tg2.tg_traffic_control(action="reset", port_handle=tg_ph_2) return (tg1, tg2, tg_ph_1, tg_ph_2)
def tg_links_status_using_native_calls(): # build port list per tgen tg_port_dict = {} for dut in st.get_dut_names(): for _, partner, remote in st.get_tg_links(dut, native=use_native): tg_port_dict.setdefault(partner, []).append(remote) results = dict() for partner, port_list in tg_port_dict.items(): # get tgen handle using first port (tg, _) = tgapi.get_handle_byname(None, tg=partner, port=port_list[0]) # get all ports status rv = tg.get_port_status(port_list) # fill the results for port in port_list: name = "{}--{}".format(partner, port) results[name] = rv[port] return results
def tg_bgpv6_config(vars, local_asn, remote_asn): tg2, tg_ph_2 = tgapi.get_handle_byname("T1D1P2") tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2) h1 = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', ipv6_intf_addr=data.t1d1_ip6_addr,\ ipv6_prefix_length='64',ipv6_gateway=data.d1t1_ip6_addr, src_mac_addr='00:0a:01:00:00:01',\ arp_send_req='1') st.log("INTFCONF: " + str(h1)) st.log("Configuring BGP device on top of interface") bgp_conf = tg2.tg_emulation_bgp_config(handle=h1['handle'], mode='enable', ip_version='6',\ active_connect_enable='1', local_as= data.local_asn4,\ remote_as=data.local_asn4, remote_ipv6_addr=data.d1t1_ip6_addr, enable_4_byte_as='1') st.log("BGPCONF: " + str(bgp_conf)) st.log("Adding routes to BGP device") bgp_route = tg2.tg_emulation_bgp_route_config(handle=bgp_conf['handle'], mode='add', ip_version='6', num_routes='100', prefix='1001::0') st.log("BGPROUTE: " + str(bgp_route))
def get_handles_2(): tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg2, tg_ph_2 = tgapi.get_handle_byname("T1D2P1") return (tg1, tg_ph_1, tg2, tg_ph_2)
def get_handles_1(): tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg2, tg_ph_2 = tgapi.get_handle_byname("T1D1P2") tg3, tg_ph_3 = tgapi.get_handle_byname("T1D1P3") tg4, tg_ph_4 = tgapi.get_handle_byname("T1D1P4") return (tg1, tg_ph_1, tg2, tg_ph_2, tg3, tg_ph_3, tg4, tg_ph_4)
def get_handles(): tg1, tg_ph_1 = tgapi.get_handle_byname("T1D1P3") tg2, tg_ph_2 = tgapi.get_handle_byname("T1D1P4") return (tg1, tg_ph_1, tg2, tg_ph_2)
def verify_topology(check_type, threads=True): if check_type in ["status", "status2", "status3", "status4"]: return links_status(threads, check_type) retval = True results = [] header = ['DUT', 'Local', "Partner", "Remote", "Status"] check_oneway = True exclude = [] for dut in st.get_dut_names(): alias = st.get_device_alias(dut) for local, partner, remote in st.get_dut_links(dut): palias = st.get_device_alias(partner) # check if the port is verified from other direction skip = False for ex in exclude: #print("CMP", dut, local, ex[0], ex[1]) if dut == ex[0] and local == ex[1]: skip = True break if skip: log_info("{}/{} is already verified".format(alias, local)) continue result = [alias, local, palias, remote, "Fail"] # shutdown local link and get remote link stats in partner portapi.shutdown(dut, [local]) wait() status1 = portapi.get_interface_status(partner, remote) trace(alias, local, palias, remote, status1) # noshutdown local link and get remote link stats in partner portapi.noshutdown(dut, [local]) wait() status2 = portapi.get_interface_status(partner, remote) trace(alias, local, palias, remote, status2) # log the result on fail if not check_status(status1, "down", status2, "up"): warn("1. port %s/%s is not connected to %s/%s\n", alias, local, palias, remote) results.append(result) exclude.append([partner, remote]) retval = False continue if not check_oneway: # shutdown remote link and get local link status portapi.shutdown(partner, [remote]) wait() status3 = portapi.get_interface_status(dut, local) trace(alias, local, palias, remote, status3) # noshutdown remote link and get local link status portapi.noshutdown(partner, [remote]) wait() status4 = portapi.get_interface_status(dut, local) trace(alias, local, palias, remote, status4) # log the result on fail if not check_status(status3, "down", status4, "up"): warn("2. port %s/%s is not connected to %s/%s\n", alias, local, palias, remote) results.append(result) retval = False continue # log the result on pass result[4] = "OK" results.append(result) exclude.append([partner, remote]) for local, partner, remote in st.get_tg_links(dut): palias = st.get_device_alias(partner) (tg, ph) = tgapi.get_handle_byname(None, tg=partner, port=remote) result = [alias, local, palias, remote, "Fail"] tgen_link_status_supported = False if tgen_link_status_supported: # shutdown local link and get remote link stats in partner portapi.shutdown(dut, [local]) wait() status1 = get_link_status(tg, ph) trace(alias, local, palias, remote, status1) # no shutdown local link and get remote link stats in partner portapi.noshutdown(dut, [local]) wait() status2 = get_link_status(tg, ph) trace(alias, local, palias, remote, status2) # log the result on fail if tgen_link_status_supported and (status1 or not status2): warn("3. port %s/%s is not connected to %s/%s\n", alias, local, palias, remote) results.append(result) retval = False continue # shutdown remote link and get local link status tg.tg_interface_control(mode="break_link", port_handle=ph) wait() status3 = portapi.get_interface_status(dut, local) trace(alias, local, palias, remote, status3) # noshutdown remote link and get local link status tg.tg_interface_control(mode="restore_link", port_handle=ph) wait() status4 = portapi.get_interface_status(dut, local) trace(alias, local, palias, remote, status4) # log the result on fail if not check_status(status3, "down", status4, "up"): warn("4. port %s/%s is not connected to %s/%s\n", alias, local, palias, remote) results.append(result) retval = False continue # log the result on pass result[4] = "OK" results.append(result) return [retval, header, results]
def qos_module_hooks(request): # add things at the start of this module global vars vars = dict() vars = st.ensure_min_topology("D1D2:1", "D1T1:2", "D2T1:2") intf_show = interface_status_show(vars.D1, interfaces=[vars.D1T1P1, vars.D1D2P1]) port_speed_info = dict() for port in [vars.D1T1P1, vars.D1D2P1]: filter_data = filter_and_select(intf_show, ['speed'], {'interface': port}) if filter_data and 'speed' in filter_data[0]: port_speed_info[port] = int(filter_data[0]['speed'].replace( 'G', '000')) if port_speed_info[vars.D1D2P1] != port_speed_info[vars.D1T1P1]: st.debug("The TG connected port speed: {}".format( port_speed_info[vars.D1T1P1])) st.debug("The DUT interconnected port speed: {}".format( port_speed_info[vars.D1D2P1])) st.report_unsupported( "msg", "The TG connected port and the DUT interconnected port speeds are not equal" ) scheduling_vars() scheduling_data.pmap_details = asicapi.get_intf_pmap( vars.D1, interface_name=[vars.D1D2P1]) if not scheduling_data.pmap_details: st.debug("PMAP details are: {}".format(scheduling_data.pmap_details)) st.report_fail('no_data_found') scheduling_module_config(config='yes') st.debug("Getting TG handlers") tg1, scheduling_data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") tg2, scheduling_data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2") tg3, scheduling_data.tg_ph_3 = tgapi.get_handle_byname("T1D2P1") tg4, scheduling_data.tg_ph_4 = tgapi.get_handle_byname("T1D2P2") scheduling_data.tg = tg1 st.unused(tg2, tg3, tg4) st.debug("Reset and clear statistics of TG ports") scheduling_data.tg.tg_traffic_control(action='reset', port_handle=[ scheduling_data.tg_ph_1, scheduling_data.tg_ph_2, scheduling_data.tg_ph_3, scheduling_data.tg_ph_4 ]) scheduling_data.tg.tg_traffic_control(action='clear_stats', port_handle=[ scheduling_data.tg_ph_1, scheduling_data.tg_ph_2, scheduling_data.tg_ph_3, scheduling_data.tg_ph_4 ]) st.debug("Creating TG streams") scheduling_data.streams = {} stream = scheduling_data.tg.tg_traffic_config( port_handle=scheduling_data.tg_ph_3, mode='create', length_mode='fixed', frame_size=64, pkts_per_burst=10, l2_encap='ethernet_ii_vlan', transmit_mode='single_burst', vlan_id=scheduling_data.vlan, mac_src=scheduling_data.mac_egress_1, mac_dst='00:0a:12:00:00:01', vlan="enable") scheduling_data.streams['vlan_tagged_egress_port1'] = stream['stream_id'] stream = scheduling_data.tg.tg_traffic_config( port_handle=scheduling_data.tg_ph_4, mode='create', length_mode='fixed', frame_size=64, pkts_per_burst=10, l2_encap='ethernet_ii_vlan', transmit_mode='single_burst', vlan_id=scheduling_data.vlan, mac_src=scheduling_data.mac_egress_2, mac_dst='00:0a:12:00:00:02', vlan="enable") scheduling_data.streams['vlan_tagged_egress_port2'] = stream['stream_id'] stream = scheduling_data.tg.tg_traffic_config( port_handle=scheduling_data.tg_ph_1, mode='create', transmit_mode='continuous', length_mode='fixed', rate_percent=100, l2_encap='ethernet_ii_vlan', frame_size=1024, vlan_id=scheduling_data.vlan, vlan="enable", vlan_user_priority=scheduling_data.dwrr_queue1, mac_src="00:00:00:00:00:11", mac_dst=scheduling_data.mac_egress_1) scheduling_data.streams['scheduling_port_dwrr_ingress1'] = stream[ 'stream_id'] stream = scheduling_data.tg.tg_traffic_config( port_handle=scheduling_data.tg_ph_2, mode='create', transmit_mode='continuous', length_mode='fixed', rate_percent=100, l2_encap='ethernet_ii_vlan', frame_size=1024, vlan_id=scheduling_data.vlan, vlan="enable", vlan_user_priority=scheduling_data.dwrr_queue2, mac_src="00:00:00:00:00:22", mac_dst=scheduling_data.mac_egress_2) scheduling_data.streams['scheduling_port_dwrr_ingress2'] = stream[ 'stream_id'] yield st.debug('Module config Cleanup') scheduling_module_config(config='no')
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])
def verify_topology(hooks, check_type, threads=True): if check_type in ["module", "function"]: return links_status(hooks, threads, check_type) retval = True results, exclude = [], [] header = ['DUT', 'DId', 'Local', "Partner", "PDId", "Remote", "Status"] dids, _ = fill_dev_ids() for dut in st.get_dut_names(): did = dids[dut] for local, partner, remote in st.get_dut_links(dut, native=use_native): pdid = dids[dut] # check if the port is verified from other direction skip = False for ex in exclude: #print("CMP", dut, local, ex[0], ex[1]) if dut == ex[0] and local == ex[1]: skip = True break if skip: log_info("{}({})/{} is already verified".format( dut, did, local)) continue result = [dut, did, local, partner, pdid, remote, "Fail"] # shutdown local link and get remote link stats in partner hooks.shutdown(dut, [local]) wait() status1 = hooks.get_interface_status(partner, remote) trace(dut, did, local, partner, pdid, remote, status1) # noshutdown local link and get remote link stats in partner hooks.noshutdown(dut, [local]) wait() status2 = hooks.get_interface_status(partner, remote) trace(dut, did, local, partner, pdid, remote, status2) # log the result on fail if not check_status(status1, "down", status2, "up"): warn("1. port %s(%s)/%s is not connected to %s(%s)/%s\n", dut, did, local, partner, pdid, remote) results.append(result) exclude.append([partner, remote]) retval = False continue if not check_oneway: # shutdown remote link and get local link status hooks.shutdown(partner, [remote]) wait() status3 = hooks.get_interface_status(dut, local) trace(dut, did, local, partner, pdid, remote, status3) # noshutdown remote link and get local link status hooks.noshutdown(partner, [remote]) wait() status4 = hooks.get_interface_status(dut, local) trace(dut, did, local, partner, pdid, remote, status4) # log the result on fail if not check_status(status3, "down", status4, "up"): warn("2. port %s(%s)/%s is not connected to %s(%s)/%s\n", dut, did, local, partner, pdid, remote) results.append(result) retval = False continue # log the result on pass result[6] = "OK" results.append(result) exclude.append([partner, remote]) for local, partner, remote in st.get_tg_links(dut, native=use_native): pdid = dids[partner] (tg, ph) = tgapi.get_handle_byname(None, tg=partner, port=remote) result = [dut, did, local, partner, pdid, remote, "Fail"] if tg.tg_type in ["scapy"]: result[6] = "OK" results.append(result) continue if tgen_link_status_supported: # shutdown local link and get remote link stats in partner hooks.shutdown(dut, [local]) wait() status1 = get_tg_link_status(tg, ph) trace(dut, did, local, partner, pdid, remote, status1) # no shutdown local link and get remote link stats in partner hooks.noshutdown(dut, [local]) wait() status2 = get_tg_link_status(tg, ph) trace(dut, did, local, partner, pdid, remote, status2) # log the result on fail if tgen_link_status_supported and (status1 or not status2): warn("3. port %s(%s)/%s is not connected to %s/%s(%s)\n", dut, did, local, partner, pdid, remote) results.append(result) retval = False continue # shutdown remote link and get local link status tg.tg_interface_control(mode="break_link", port_handle=ph) wait() status3 = hooks.get_interface_status(dut, local) trace(dut, did, local, partner, pdid, remote, status3) # noshutdown remote link and get local link status tg.tg_interface_control(mode="restore_link", port_handle=ph) wait() status4 = hooks.get_interface_status(dut, local) trace(dut, did, local, partner, pdid, remote, status4) # log the result on fail if not check_status(status3, "down", status4, "up"): warn("4. port %s(%s)/%s is not connected to %s/%s(%s)\n", dut, did, local, partner, pdid, remote) results.append(result) retval = False continue # log the result on pass result[6] = "OK" results.append(result) return [retval, header, results, False, False]
def wred_module_hooks(request): # add things at the start of this module global vars vars = st.ensure_min_topology("D1T1:3") wred_data = wred_config.init_vars(vars, apply_wred=True) st.log('Creating WRED table') utils.exec_all(True, [ utils.ExecAllFunc(apply_wred_ecn_config, vars.D1, wred_data['wred_config_json']) ]) st.log("Getting TG handlers") data.tg1, data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1") data.tg2, data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2") data.tg3, data.tg_ph_3 = tgapi.get_handle_byname("T1D1P3") data.tg = data.tg1 st.log("Reset and clear statistics of TG ports") data.tg.tg_traffic_control( action='reset', port_handle=[data.tg_ph_1, data.tg_ph_2, data.tg_ph_3]) data.tg.tg_traffic_control( action='clear_stats', port_handle=[data.tg_ph_1, data.tg_ph_2, data.tg_ph_3]) st.log("Creating TG streams") data.streams = {} stream = data.tg.tg_traffic_config(port_handle=data.tg_ph_3, mode='create', length_mode='fixed', frame_size=64, pkts_per_burst=10, l2_encap='ethernet_ii_vlan', transmit_mode='single_burst', vlan_id=data.vlan, mac_src=data.dscp_dest_mac, mac_dst='00:0a:12:00:00:01', vlan="enable") data.streams['vlan_tagged_egress'] = stream['stream_id'] stream = data.tg.tg_traffic_config( port_handle=data.tg_ph_1, mode='create', transmit_mode='continuous', length_mode='fixed', rate_percent=10, l2_encap='ethernet_ii_vlan', vlan_id=data.vlan, vlan="enable", mac_src=data.dscp_src1, mac_dst=data.dscp_dest_mac, l3_protocol='ipv4', ip_src_addr='1.1.1.1', ip_dst_addr='5.5.5.5', ip_dscp="8", high_speed_result_analysis=0, track_by='trackingenabled0 ipv4DefaultPhb0', ip_dscp_tracking=1) data.streams['dscp1'] = stream['stream_id'] stream = data.tg.tg_traffic_config( port_handle=data.tg_ph_1, mode='create', transmit_mode='continuous', length_mode='fixed', rate_percent=10, l2_encap='ethernet_ii_vlan', vlan_id=data.vlan, vlan="enable", mac_src=data.dscp_src2, mac_dst=data.dscp_dest_mac, l3_protocol='ipv4', ip_src_addr='1.1.1.1', ip_dst_addr='5.5.5.5', ip_dscp="24", high_speed_result_analysis=0, track_by='trackingenabled0 ipv4DefaultPhb0', ip_dscp_tracking=1) data.streams['dscp2'] = stream['stream_id'] yield #clearing WRED config qos_obj.clear_qos_config(vars.D1) vlan_obj.clear_vlan_configuration(vars.D1, thread=True)