def snmp_pre_config(): """ SNMP pre config """ global ipaddress ipaddress_list = basic_obj.get_ifconfig_inet(vars.D1, data.mgmt_int) st.log("Checking Ip address of the Device ") if not ipaddress_list: st.report_env_fail("ip_verification_fail") ipaddress = ipaddress_list[0] st.log("Device ip addresse - {}".format(ipaddress)) snmp_obj.set_snmp_config(vars.D1, snmp_rocommunity=data.ro_community, snmp_location=data.location) if not st.is_community_build(): ipfeature.configure_loopback(vars.D1, loopback_name="Loopback0", config="yes") ipfeature.config_ip_addr_interface(vars.D1, data.loopback0, data.loopback_addr, 32, family=data.af_ipv4) if not ipfeature.ping(vars.D1, ipaddress, family='ipv4', external=True): st.error("Ping reachability is failed between SNMP server and Device.") if not snmp_obj.poll_for_snmp(vars.D1, data.wait_time, 1, ipaddress=ipaddress, oid=data.oid_sysName, community_name=data.ro_community): st.log("Post SNMP config , snmp is not working") st.report_fail("operation_failed")
def ceta_31902_fixture(request, ip_module_hooks): vlan_obj.create_vlan(vars.D1, [data.host1_vlan, data.host2_vlan]) vlan_obj.add_vlan_member(vars.D1, data.host1_vlan, [vars.D1T1P3, vars.D1T1P4], tagging_mode=True) vlan_obj.add_vlan_member(vars.D1, data.host2_vlan, [vars.D1T1P3, vars.D1T1P4], tagging_mode=True) ipfeature.config_ip_addr_interface(vars.D1, "Vlan" + data.host1_vlan, data.vlan1_ip, 24, family=data.af_ipv4) ipfeature.config_ip_addr_interface(vars.D1, "Vlan" + data.host2_vlan, data.vlan2_ip, 24, family=data.af_ipv4) yield ipfeature.delete_ip_interface(vars.D1, "Vlan" + data.host1_vlan, data.vlan1_ip, "24", family="ipv4") ipfeature.delete_ip_interface(vars.D1, "Vlan" + data.host2_vlan, data.vlan2_ip, "24", family="ipv4") vlan_obj.delete_vlan_member(vars.D1, data.host1_vlan, [vars.D1T1P3, vars.D1T1P4], True) vlan_obj.delete_vlan_member(vars.D1, data.host2_vlan, [vars.D1T1P3, vars.D1T1P4], True) vlan_obj.delete_vlan(vars.D1, [data.host1_vlan, data.host2_vlan])
def ztp_module_hooks(request): st.add_prevent("ztp") initialize_variables() pre_config_ztp() path_list = [ztp_params.home_path+ztp_params.config_path, ztp_params.home_path+ztp_params.provision_script_path] ztp_obj.create_required_folders(ssh_conn_obj, path_list) basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml", "/etc/sonic/snmp.yml.bkp") source_path = "{}{}".format(config_params.local_provision_scripts_folder, config_params.snmp_filename) st.upload_file_to_dut(vars.D1, source_path, "/home/admin/snmp.yml") basic_obj.copy_file_to_local_path(vars.D1, "/home/admin/snmp.yml", "/etc/sonic/snmp.yml") if ztp_params.breakout: if breakout(vars.D1, ztp_params.breakout, cli_type="klish", skip_error=True): intf_details = get_interface_details_by_alt_name(vars.D1, ztp_params.inband_port) if isinstance(intf_details, dict): inband_port = intf_details["interface"] else: inband_port = intf_details interface_noshutdown(vars.D1, inband_port) config_ip_addr_interface(vars.D1, inband_port, ztp_params.dhcp6.client_ip_inband, ztp_params.dhcp6.inband_v6_subnet, family="ipv6") # enable_dhcp_on_interface(vars.D1, ztp_params.inband_port) if not ping(vars.D1, ztp_params.dhcp6.inband_static_ip, family="ipv6"): st.log("Pinging to DHCP server failed from DUT, issue either with DUT or server") # config_save(vars.D1) yield ztp_cfg = {"admin-mode": True, "restart-ztp-interval": 30, "feat-console-logging": feat_logging_console} ztp_obj.config_ztp_backdoor_options(vars.D1, ztp_cfg) reset_module_config() basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml.bkp", "/etc/sonic/snmp.yml")
def erspan_pre_config(): """ Author: Lakshminarayana D ([email protected]) Using this pre config at module level. So, applicable for all test cases which includes in this module. :return: None """ # IP address configuration on DUT-1 for port, ip_addr, in zip(data.port_list_d1, data.ip_list_d1): ip.config_ip_addr_interface(vars.D1, port, ip_addr, data.subnet_mask) # IP address configuration on DUT-2 for port, ip_addr in zip(data.port_list_d2, data.ip_list_d2): ip.config_ip_addr_interface(vars.D2, port, ip_addr, data.subnet_mask) # Create static route _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D2P1, data.subnet_mask)) ip.create_static_route(vars.D1, data.ip_D2D1P1, network) _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D1P1, data.subnet_mask)) ip.create_static_route(vars.D2, data.ip_D1D2P1, network) # creation and verification of Monitor session mirror.create_session(vars.D1, session_name=data.session_name, src_ip=data.ip_D1T1P1, dst_ip=data.ip_T1D2P1, gre_type=data.gre_type, dscp=data.dscp, ttl=data.ttl, queue=data.queue) # creation and verification of ACL Policy acl_dscp.config_policy_table(vars.D1, enable='create', policy_name=data.acl_table_name, policy_type=data.type) acl_dscp.config_service_policy_table(vars.D1, policy_kind="bind", interface_name=vars.D1T1P1, stage='in', service_policy_name=data.acl_table_name, policy_type=data.type) acl_dscp.config_service_policy_table(vars.D1, policy_kind="bind", interface_name=vars.D1T1P2, stage='in', policy_type=data.type, service_policy_name=data.acl_table_name) acl.create_acl_table(vars.D1, name="L3_IPV6_INGRESS", stage=data.stage, type="L3V6", description="L3_IPV6_INGRESS", ports=[vars.D1T1P1])
def f4(): ip_obj.config_ip_addr_interface(data.d4, data.d4_d3_intf_1, data.d4_d3_intf_1_ip, data.def_mask_ip, 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d4, 'Vlan343', data.d4_d3_vlan_1_ip, data.def_mask_ip, 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d4, data.d4_d1_pc_1, data.d4_d1_pc_1_ip, data.def_mask_ip, 'ipv4',config='remove') #ip_obj.config_ip_addr_interface(data.d4, data.d4_d3_intf_1, data.d4_d3_intf_1_ip6, data.def_mask_ip6, 'ipv6',config='remove') ip_obj.config_ip_addr_interface(data.d4, 'Loopback1', '4.4.4.1', '32', 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d4, 'Loopback2', '4.4.4.2', '32', 'ipv4',config='remove')
def test_mgmt_vrf_static_dhcp(): config_ip_addr_interface(vars.D1, "eth0", mgmt_vrf.staticip, 20, mgmt_vrf.af_ipv4) if not poll_wait(verify_interface_ip_address, 10, vars.D1, "eth0", mgmt_vrf.staticip + '/20', family="ipv4", vrfname='mgmt'): st.log("IP Address not matched") delete_ip_interface(vars.D1, "eth0", mgmt_vrf.staticip, 20, mgmt_vrf.af_ipv4) st.report_fail("mgmt_vrf_static_dhcp", "failed") output = get_ifconfig(vars.D1, "eth0") if output[0]['broadcast'][0] == '0.0.0.0': st.log("Broadcast IP address not assigned") delete_ip_interface(vars.D1, "eth0", mgmt_vrf.staticip, 20, mgmt_vrf.af_ipv4) st.report_fail("test_case_failed") delete_ip_interface(vars.D1, "eth0", mgmt_vrf.staticip, 20, mgmt_vrf.af_ipv4) if not poll_wait(get_ifconfig_inet, 30, vars.D1, 'eth0'): st.log("IP Address not assigned to eth0 after dhcp") st.report_fail("mgmt_vrf_static_dhcp", "failed") st.report_pass("mgmt_vrf_static_dhcp", "successful")
def ztp_module_hooks(request): st.add_prevent("ztp") initialize_config_params() pre_config_ztp() initialize_data_variables() path_list = [ztp_params.home_path+ztp_params.config_path, ztp_params.home_path+ztp_params.firmware_path, ztp_params.home_path+ztp_params.provision_script_path, ztp_params.home_path+ztp_params.xml_path] ztp_obj.create_required_folders(ssh_conn_obj, path_list) basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml", "/etc/sonic/snmp.yml.bkp") source_path = "{}{}".format(config_params.local_provision_scripts_folder, config_params.snmp_filename) st.upload_file_to_dut(vars.D1, source_path, "/home/admin/snmp.yml") basic_obj.copy_file_to_local_path(vars.D1, "/home/admin/snmp.yml", "/etc/sonic/snmp.yml") if ztp_params.breakout: if breakout(vars.D1, ztp_params.breakout, cli_type="klish", skip_error=True): intf_details = get_interface_details_by_alt_name(vars.D1, ztp_params.inband_port) if isinstance(intf_details, dict): inband_port = intf_details["interface"] else: inband_port = intf_details interface_noshutdown(vars.D1, inband_port) config_ip_addr_interface(vars.D1, inband_port, ztp_params.dhcp.client_ip_inband, ztp_params.dhcp.inband_v4_subnet) # enable_dhcp_on_interface(vars.D1, ztp_params.inband_port) if not ping(vars.D1, ztp_params.dhcp.inband_static_ip): st.log("Pinging to DHCP server failed from DUT, issue either with DUT or server") # config_save(vars.D1) # write_config_db(vars.D1, interface_data) yield reset_module_config() basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml.bkp", "/etc/sonic/snmp.yml")
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 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 ndp_module_hooks(request): vars = st.ensure_min_topology("D1T1:2") # Initialize TG and TG port handlers tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2") tg = tg_handler["tg"] # Test setup details data.my_dut_list = st.get_dut_names() dut1 = data.my_dut_list[0] # NDP module configuration st.log("NDP module configuration.") ip_obj.config_ip_addr_interface(dut1, vars.D1T1P1, data.local_ip6_addr[0], 64, family=data.af_ipv6) vlan_obj.create_vlan(dut1, data.vlan_1) vlan_obj.add_vlan_member(dut1, data.vlan_1, vars.D1T1P2, True) ip_obj.config_ip_addr_interface(dut1, data.vlan_int_1, data.local_ip6_addr[1], 64, family=data.af_ipv6) # TG ports reset st.log("Resetting the TG ports") tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) # TG protocol interface creation st.log("TG protocol interface creation") h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', ipv6_intf_addr=data.neigh_ip6_addr_gw[0], ipv6_prefix_length='64', ipv6_gateway=data.local_ip6_addr[0], src_mac_addr=data.tg_mac1, arp_send_req='1', count=data.count) st.log("INTFCONF: " + str(h1)) h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', ipv6_intf_addr=data.neigh_ip6_addr_gw[1], ipv6_prefix_length='64', ipv6_gateway=data.local_ip6_addr[1], src_mac_addr=data.tg_mac2, arp_send_req='1', vlan_id=data.vlan_1, vlan=1, count=data.count) st.log("INTFCONF: " + str(h2)) yield # NDP module cleanup st.log("NDP module cleanup.") ip_obj.clear_ip_configuration(dut1, family="ipv6", thread=data.clear_parallel) vlan_obj.clear_vlan_configuration(dut1, thread=data.clear_parallel)
def test_ft_port_fn_verify_shut_noshut(): if not ipapi.config_ip_addr_interface(vars.D1, interface_name=vars.D1D2P1, ip_address=intf_data.ip_address, subnet=intf_data.mask, family="ipv4", config='add'): st.report_fail("operation_failed") if not ipapi.config_ip_addr_interface(vars.D2, interface_name=vars.D2D1P1, ip_address=intf_data.ip_address1, subnet=intf_data.mask, family="ipv4", config='add'): st.report_fail("operation_failed") if not ipapi.ping(vars.D1, intf_data.ip_address1, family='ipv4', count=1): st.report_fail("ping_fail", intf_data.ip_address, intf_data.ip_address1) if not ipapi.ping(vars.D2, intf_data.ip_address, family='ipv4', count=1): st.report_fail("ping_fail", intf_data.ip_address1, intf_data.ip_address) for _ in range(3): intfapi.interface_shutdown(vars.D1, [vars.D1D2P1], skip_verify=True) intfapi.interface_noshutdown(vars.D1, [vars.D1D2P1], skip_verify=True) if not ipapi.ping(vars.D1, intf_data.ip_address1, family='ipv4', count=5): st.report_fail("ping_fail", intf_data.ip_address, intf_data.ip_address1) if not ipapi.ping(vars.D2, intf_data.ip_address, family='ipv4', count=1): st.report_fail("ping_fail", intf_data.ip_address1, intf_data.ip_address) rbapi.config_save_reload(vars.D1) if not ipapi.config_ip_addr_interface(vars.D1, interface_name=vars.D1D2P1, ip_address=intf_data.ip_address, subnet=intf_data.mask, family="ipv4", config='remove'): st.report_fail("operation_failed") if not ipapi.config_ip_addr_interface(vars.D2, interface_name=vars.D2D1P1, ip_address=intf_data.ip_address1, subnet=intf_data.mask, family="ipv4", config='remove'): st.report_fail("operation_failed") for _ in range(3): intfapi.interface_shutdown(vars.D1, [vars.D1D2P1], skip_verify=True) intfapi.interface_noshutdown(vars.D1, [vars.D1D2P1], skip_verify=True) if not st.poll_wait(intfapi.verify_interface_status, 15, vars.D1, vars.D1D2P1, "oper", "up"): st.report_fail("interface_is_down_on_dut", [vars.D1D2P1]) if not st.poll_wait(intfapi.verify_interface_status, 15, vars.D2, vars.D2D1P1, "oper", "up"): st.report_fail("interface_is_down_on_dut", [vars.D2D1P1]) st.report_pass("test_case_passed")
def f3(): ip_obj.config_ip_addr_interface(data.d3, data.d3_d4_intf_1, data.d3_d4_intf_1_ip, data.def_mask_ip, 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d3, 'Vlan343', data.d3_d4_vlan_1_ip, data.def_mask_ip, 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d3, data.d3_d2_pc_1, data.d3_d2_pc_1_ip, data.def_mask_ip, 'ipv4',config='remove') #ip_obj.config_ip_addr_interface(data.d3, data.d3_d4_intf_1, data.d3_d4_intf_1_ip6, data.def_mask_ip6, 'ipv6',config='remove') ip_obj.config_ip_addr_interface(data.d3, 'Loopback1', '3.3.3.1', '32', 'ipv4',config='remove') ip_obj.config_ip_addr_interface(data.d3, 'Loopback2', '3.3.3.2', '32', 'ipv4',config='remove')
def connected_port_ip_address_config(): st.log("About to add IP address on port connected to DHCP server") ip_obj.config_ip_addr_interface(vars.D2, data.dhcp_relay_params, data.RA_ipaddress_1, data.subnet, family=data.family, config='add')
def arp_module_hooks(request): global vars, tg_handler, tg, dut1, d1_mac_addr, h1, h2 # Min topology verification vars = st.ensure_min_topology("D1T1:2") # Initialize TG and TG port handlers tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2") tg = tg_handler["tg"] # Test setup details data.my_dut_list = st.get_dut_names() dut1 = data.my_dut_list[0] # Test variables d1_mac_addr = mac.get_sbin_intf_mac(dut1, "eth0") # ARP module configuration st.log("ARP module configuration.") ip_obj.config_ip_addr_interface(dut1, vars.D1T1P1, data.d1t1_ip_addr, data.mask) vlan_obj.create_vlan(dut1, data.vlan_1) vlan_obj.add_vlan_member(dut1, data.vlan_1, vars.D1T1P2, True) ip_obj.config_ip_addr_interface(dut1, data.vlan_int_1, data.d1t2_ip_addr, data.mask) # TG ports reset st.log("Resetting the TG ports") tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) # TG protocol interface creation st.log("TG protocol interface creation") h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.t1d1_ip_addr, gateway=data.d1t1_ip_addr, src_mac_addr=data.t1d1_mac_addr, arp_send_req='1') st.log("INTFCONF: " + str(h1)) h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', intf_ip_addr=data.t2d1_ip_addr, gateway=data.d1t2_ip_addr, src_mac_addr=data.t2d1_mac_addr, arp_send_req='1', vlan_id=data.vlan_1, vlan=1) st.log("INTFCONF: " + str(h2)) yield # ARP module cleanup st.log("ARP module cleanup.") ip_obj.clear_ip_configuration(dut1, family="ipv4", thread=data.clear_parallel) vlan_obj.clear_vlan_configuration(dut1, thread=data.clear_parallel)
def pre_test_l3_fwding(): # override from testbed vars = st.get_testbed_vars() data.my_dut_list = st.get_dut_names() ipfeature.clear_ip_configuration(st.get_dut_names()) ipfeature.clear_ip_configuration(st.get_dut_names(),'ipv6') vapi.clear_vlan_configuration(st.get_dut_names()) ipfeature.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.d1t1_5_x_ip_addr, data.mask) ipfeature.config_ip_addr_interface(vars.D1, vars.D1T1P2, data.d1t2_5_x_ip_addr, data.mask)
def nat_pre_config(): global vars vars = st.ensure_min_topology("D1D2:1", "D2D3:1") platform = basic_obj.get_hwsku(vars.D2) common_constants = st.get_datastore(vars.D2, "constants", "default") if platform.lower() in common_constants['TH3_PLATFORMS']: st.error("NAT is not supported for this platform {}".format(platform)) st.report_unsupported('NAT_unsupported_platform',platform) ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.d1d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4) ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.d2d1_ip_addr, data.ip_addr_mask, family=data.af_ipv4) ip_obj.config_ip_addr_interface(vars.D2, vars.D2D3P1, data.d2d3_ip_addr, data.ip_addr_mask, family=data.af_ipv4) ip_obj.config_ip_addr_interface(vars.D3, vars.D3D2P1, data.d3d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4) ip_obj.create_static_route(vars.D1, data.d2d1_ip_addr,"{}/{}".format(data.d1_static_nw, data.ip_addr_mask), shell=data.shell_vtysh, family=data.af_ipv4) ip_obj.create_static_route(vars.D3, data.d2d3_ip_addr, "{}/{}".format(data.d3_static_nw, data.ip_addr_mask), shell=data.shell_vtysh, family=data.af_ipv4) st.log("NAT Configuration") nat_obj.config_nat_feature(vars.D2, 'enable') util_nat_zone_config(vars.D2, [vars.D2D1P1, vars.D2D3P1], [data.zone_1, data.zone_2], config=data.config_add) st.log("Creating NAT Pool") nat_obj.config_nat_pool(vars.D2, pool_name=data.pool_name[0], global_ip_range=data.d2d1_ip_addr, global_port_range=data.global_port_range, config=data.config_add) st.log("Creating NAT Pool binding") nat_obj.config_nat_pool_binding(vars.D2, binding_name=data.bind_name[0], pool_name=data.pool_name[0], config=data.config_add) utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1], [ip_obj.show_ip_route, vars.D2]]) ip_obj.show_ip_route(vars.D3)
def dhcp_relay_module_config(request): initialize_variables() vars = st.ensure_min_topology("D1D2:1", "D2D3:2") bind_class_action_copp_policy(vars.D3, classifier='copp-system-dhcpl2', action_group='copp-system-dhcp') response = basic_obj.dhcp_server_config( vars.D1, dhcp_files_path=data.dhcp_files_path, server_port=vars.D1D2P1, server_ipv4=data.dhcp_server_ip, route_list=data.route_list, ipv4_relay_agent_ip=data.RA_ipaddress_1) if not response: st.report_fail("service_operation_status", "isc-dhcp-server", "installation", "failed") connected_port_ip_address_config() if not basic_obj.check_interface_status(vars.D2, data.dhcp_relay_params, "up"): basic_obj.ifconfig_operation(vars.D2, data.dhcp_relay_params, "up") if not ip_obj.ping(vars.D2, data.dhcp_server_ip): st.log( "Pinging to DHCP server failed from DUT, issue either with DUT or server" ) st.report_fail("ping_fail", data.dhcp_server_ip) basic_dhcp_relay_config_addition() yield response = basic_obj.dhcp_server_config( vars.D1, action="unconfig", dhcp_files_path=data.dhcp_files_path, server_port=vars.D1D2P1, server_ipv4=data.dhcp_server_ip, route_list=data.route_list, ipv4_relay_agent_ip=data.RA_ipaddress_1) if not response: st.report_fail("service_operation_status", "isc-dhcp-server", "uninstallation", "failed") dhcp_relay_obj.dhcp_relay_config_remove(vars.D2, vlan=data.vlan_int, IP=data.dhcp_server_ip) ip_obj.config_ip_addr_interface(vars.D2, data.dhcp_relay_params, data.RA_ipaddress_1, data.subnet, family=data.family, config='remove') ip_obj.clear_ip_configuration(st.get_dut_names()) ip_obj.clear_ip_configuration(st.get_dut_names(), 'ipv6') vlan_obj.clear_vlan_configuration(st.get_dut_names())
def copp_fixture_igmp(request, copp_module_hooks): # copp fixture for igmp ip_obj.delete_ip_interface(dut=vars.D1, interface_name=d1_p1, ip_address='1.1.1.2', subnet='24') vlan_obj.add_vlan_member(vars.D1, vlan_igmp, [vars.D1T1P1]) yield st.log("### CLEANUP for copp igmp ###") vlan_obj.delete_vlan_member(vars.D1, vlan_igmp, [vars.D1T1P1], "access") ip_obj.config_ip_addr_interface(dut=vars.D1, interface_name=d1_p1, ip_address='1.1.1.2', subnet='24')
def dut2_ipv6_addr_config(): st.log("config IPv6 address in DUT2") ip.config_ip_addr_interface( dut=acl_dict["dut_list"][1], interface_name=acl_dict["dut2"]["intf_list_dut1"][0], ip_address=acl_dict["dut2"]["ipv6_addr_list"][0], subnet=acl_dict["dut2"]["ipv6_mask_list"][0], family="ipv6") ip.config_ip_addr_interface( dut=acl_dict["dut_list"][1], interface_name=acl_dict["dut2"]["intf_list_dut1"][1], ip_address=acl_dict["dut2"]["ipv6_addr_list"][1], subnet=acl_dict["dut2"]["ipv6_mask_list"][1], family="ipv6") ip.config_ip_addr_interface( dut=acl_dict["dut_list"][1], interface_name=acl_dict["dut2"]["intf_list_dut3"][0], ip_address=acl_dict["dut2"]["ipv6_addr_list"][2], subnet=acl_dict["dut2"]["ipv6_mask_list"][2], family="ipv6") ip.config_ip_addr_interface( dut=acl_dict["dut_list"][1], interface_name=acl_dict["dut2"]["intf_list_dut3"][1], ip_address=acl_dict["dut2"]["ipv6_addr_list"][3], subnet=acl_dict["dut2"]["ipv6_mask_list"][3], family="ipv6")
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 tg_vrf_bind2(**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_vlan2[i]], [vlan_obj.create_vlan, vars.D2, data.dut1_tg1_vlan2[i]]]) utils.exec_all(True,[[vlan_obj.add_vlan_member,vars.D1,data.dut1_tg1_vlan2[i],vars.D1T1P2,True,True], [vlan_obj.add_vlan_member,vars.D2,data.dut1_tg1_vlan2[i],vars.D2T1P2,True,True]]) ''' vlan_obj.create_vlan(vars.D1, data.dut1_tg1_vlan2[i]) # Vlan-1, VRF-101, port1 vlan_obj.add_vlan_member(vars.D1, data.dut1_tg1_vlan2[i], vars.D1T1P2, True, True) vlan_obj.create_vlan(vars.D2, data.dut1_tg1_vlan2[i]) vlan_obj.add_vlan_member(vars.D2, data.dut1_tg1_vlan2[i], vars.D2T1P2, True, True) ''' st.log('######------Bind DUT1 <--> tg1 vlans to vrf, assign v4 and v6 address------######') for vrf, vlan, ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan2[0:3], data.dut1_tg1_vrf_ipv6_2[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, ipv6, data.dut1_tg1_vrf_ipv6_subnet, 'ipv6') st.log('######------Bind DUT2 <--> tg1 vlans to vrf, assign v4 and v6 address------######') for vrf, vlan,ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan2[0:3], data.dut2_tg1_vrf_ipv6_2[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, 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, ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan2[0:3], data.dut1_tg1_vrf_ipv6_2[0:3]): vrf_api.bind_vrf_interface(dut = dut1, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True, config = 'no') ipfeature.delete_ip_interface(dut1, 'Vlan'+vlan, ipv6, data.dut1_tg1_vrf_ipv6_subnet, 'ipv6') st.log('######------Unbind DUT2 <--> tg1 vlans to vrf, assign v4 and v6 address------######') for vrf, vlan,ipv6 in zip(data.vrf_name[0:3], data.dut1_tg1_vlan2[0:3], data.dut2_tg1_vrf_ipv6_2[0:3]): vrf_api.bind_vrf_interface(dut = dut2, vrf_name = vrf, intf_name = 'Vlan'+vlan, skip_error = True, config = 'no') ipfeature.delete_ip_interface(dut2, 'Vlan'+vlan, ipv6, data.dut2_tg1_vrf_ipv6_subnet, 'ipv6') st.log('######------Unconfigure vlans on the PE--CE side -------######') for i in range(3): vlan_obj.delete_vlan_member(dut1, data.dut1_tg1_vlan2[i], vars.D1T1P2, tagging_mode=True) vlan_obj.delete_vlan(dut1, data.dut1_tg1_vlan2[i]) # Vlan-1, VRF-101, port1 vlan_obj.delete_vlan_member(dut2, data.dut1_tg1_vlan2[i], vars.D2T1P2, tagging_mode=True) vlan_obj.delete_vlan(dut2, data.dut1_tg1_vlan2[i])
def adding_static_route(): st.log("About to add ipv4 address on TGen connected interface") ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.ipv4_address, data.mask, family="ipv4", config='add') st.log("Enabling docker routing config mode to split") bgp_obj.enable_docker_routing_config_mode(vars.D1) st.log("configuring static route via vtysh mode") ip_obj.create_static_route(vars.D1, data.ipv4_address_tgen, data.ipv4_address_network, shell="vtysh", family="ipv4")
def test_ft_verify_static_portchannel_del_from_ip_assigned_vlan(): ''' Author: Venkatesh Terli <*****@*****.**> Scenario - 3.2.1 Verify that deletion of a Static Port Channel which is member of vlan with an IP address is assigned on it is not Successful. ''' st.log( 'Scenario - 3.2.1 Verify that deletion of a Static Port Channel which is member of vlan with an IP address is assigned on it is not Successful' ) portchannelobj.delete_portchannel_member(vars.D1, static_data.portchannel_name, static_data.members_dut1) ipobj.config_ip_addr_interface(vars.D1, 'Vlan{}'.format(static_data.vid), static_data.ip41, static_data.ip_mask) portchannelobj.delete_portchannel(vars.D1, static_data.portchannel_name) st.report_pass('portchannel_delete_with_ip_configured_vlan', static_data.portchannel_name, 'Vlan{}'.format(static_data.vid))
def test_ft_del_ip_assigned_portchannel(): ''' Author: Venkatesh Terli <*****@*****.**> Scenario - 3.2.2 Verify that deletion of a Static Port Channel with IP address is assigned on it is not Successful. ''' st.log( 'Scenario - 3.2.2 Verify that deletion of a Static Port Channel with IP address is assigned on it is not Successful.' ) portchannelobj.delete_portchannel_member(vars.D1, static_data.portchannel_name, static_data.members_dut1) exceptions = exec_all(True, [ ExecAllFunc(delete_vlan_member, vars.D1, static_data.vid, static_data.portchannel_name, tagging_mode=True), ExecAllFunc(delete_vlan_member, vars.D2, static_data.vid, static_data.portchannel_name, tagging_mode=True) ])[1] ensure_no_exception(exceptions) ipobj.config_ip_addr_interface(vars.D1, static_data.portchannel_name, static_data.ip41, static_data.ip_mask) result = portchannelobj.delete_portchannel(vars.D1, static_data.portchannel_name, skip_error=True) cli_type = st.get_ui_type(vars.D1) if cli_type == 'click': if result: st.report_fail( 'msg', 'Allowed to delete PortChannel which is configured with IP address' ) else: if not result: st.report_fail( 'msg', 'Delete PortChannel which is configured with IP address is not allowed' ) st.report_pass('portchannel_delete_with_ip_configured_portchannel')
def basic_dhcp_relay_config_addition(): data.vlan1 = "Vlan{}".format(data.vlan) st.log("Create VLAN and participate client connected interface in vlan") vlan_obj.create_vlan_and_add_members([{ "dut": [vars.D2], "vlan_id": data.vlan, "untagged": [vars.D2D3P1] }]) st.log("About to add IP address in RA DUT") ip_obj.config_ip_addr_interface(vars.D2, data.vlan1, data.RA_ipaddress_2, data.subnet, family=data.family, config='add') st.log("Add DHCP server address to vlan") dhcp_relay_obj.dhcp_relay_config_add(vars.D2, vlan=data.vlan1, IP=data.dhcp_server_ip)
def fixture_unnumvrf_test_donar(request, prologue_epilogue): yield port_obj.noshutdown( data.dut1, [data.d1_d2_ports[1], data.d1_d2_ports[2], data.d1_d2_ports[3]]) ip_obj.config_unnumbered_interface(data.dut1, family='ipv4', action='del', interface=data.d1_d2_ports[0], loop_back=data.dut1_loopback[0]) ospf_obj.config_ospf_network( data.dut1, data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, 0, data.dut1_vrf[0], '', 'no') ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[0], data.dut1_loopback_ip[0], data.ip_loopback_prefix, "ipv4") ospf_obj.config_ospf_network( data.dut1, data.dut1_loopback_ip[0] + '/' + data.ip_loopback_prefix, 0, data.dut1_vrf[0], '', 'yes') loc_lib.dut1_config_unnumbered('phy', '') loc_lib.verify_ospf()
def ipv6_address_config(dut): if dut == vars.D1: st.log("Creating the ipv6 routing interfaces in {}".format( vars.D1D2P1), dut=dut) ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.local_ip6_addr, 96, family=data.af_ipv6) else: st.log("Creating the ipv6 routing interfaces in {}".format( vars.D2D1P1), dut=dut) ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.neigh_ip6_addr, 96, family=data.af_ipv6) if dut == vars.D1: st.log( "Creating the ipv6 routing interfaces on TG2 interface {}".format( vars.D1T1P2), dut=dut) ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P2, data.d1t1_ip6_addr, data.d1t1_ip6_addr_mask, family=data.af_ipv6)
def ipv4_ip_address_config(dut): st.log("Creating the ipv4 routing interfaces", dut=dut) if dut == vars.D1: ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.local_ip_addr, 30, family=data.af_ipv4) else: ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.neigh_ip_addr, 30, family=data.af_ipv4) if dut == vars.D1: st.log("Creating the ipv4 routing interfaces on TG1 {}".format( vars.D1T1P1), dut=dut) ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.d1t1_ip_addr, data.d1t1_ip_addr_mask, family=data.af_ipv4)
def dut_bgpv6(local_asn, remote_asn, data=[]): st.log("Creating the ipv6 routing interfaces in {}".format(vars.D1)) ipfeature.config_ip_addr_interface(data.D1, data.dut_p2_interface, data.dut_p2_ipaddr, data.dut_p2_ipaddr_subnet, family="ipv6") if not ipfeature.verify_interface_ip_address( data.D1, data.dut_p2_interface, data.dut_p2_ipaddr + '/' + str(data.dut_p2_ipaddr_subnet), family="ipv6"): st.report_fail('ip6_routing_int_create_fail', data.dut_p2_ipaddr) bgp_obj.create_bgp_router(data.D1, data.local_asn, data.router_id_1) bgp_obj.create_bgp_neighbor(dut=data.D1, local_asn=data.local_asn, neighbor_ip=data.dut_p2_ipaddr_peer, remote_asn=data.remote_asn, family="ipv6") st.log("Waiting for the ecrm_bgp_config_v6 neighbors to get Established") st.wait(10)
def config_ip_loopback(config='yes'): st.banner("{}Config Loopback Addresses on interfaces on D2".format( 'Un' if config != 'yes' else '')) config = 'add' if config == 'yes' else 'remove' if config == 'add': ipapi.configure_loopback(vars.D2, loopback_name='Loopback1', config='yes') ipapi.config_ip_addr_interface(vars.D2, 'Loopback1', eh_data.loopback4_1, 32, family=eh_data.af_ipv4, config=config) ipapi.config_ip_addr_interface(vars.D2, "Loopback1", eh_data.loopback6_1, 128, family=eh_data.af_ipv6, config=config) if config == 'remove': ipapi.configure_loopback(vars.D2, loopback_name='Loopback1', config='no')