Exemplo n.º 1
0
def config_ip_topology(config='yes'):
    st.banner("{}Config IP Addresses on interfaces".format(
        'Un' if config != 'yes' else ''))
    config = 'add' if config == 'yes' else 'remove'
    thread_info = list()
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_ip_addr_interface,
                          vars.D1,
                          vars.D1D2P1,
                          eh_data.ipv4_addr,
                          eh_data.ipv4_mask_len,
                          family=eh_data.af_ipv4,
                          config=config))
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_ip_addr_interface,
                          vars.D2,
                          vars.D2D1P1,
                          eh_data.ipv4_nbr,
                          eh_data.ipv4_mask_len,
                          family=eh_data.af_ipv4,
                          config=config))
    thread_call(thread_info)

    thread_info = list()
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_ip_addr_interface,
                          vars.D1,
                          vars.D1D2P1,
                          eh_data.ipv6_addr,
                          eh_data.ipv6_mask_len,
                          family=eh_data.af_ipv6,
                          config=config))
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_ip_addr_interface,
                          vars.D2,
                          vars.D2D1P1,
                          eh_data.ipv6_nbr,
                          eh_data.ipv6_mask_len,
                          family=eh_data.af_ipv6,
                          config=config))
    thread_call(thread_info)

    if config == 'add':
        if not check_ip_ping(vars.D1,
                             ipv4=eh_data.ipv4_nbr,
                             ipv6=eh_data.ipv6_nbr,
                             retry=eh_data.ping_retry,
                             time_delay=eh_data.ping_delay):
            st.error("Ping Operation failed between DUT and Partner")
            st.report_fail('operation_failed')
Exemplo n.º 2
0
def config_stp_vlan_parameters_parallel(dut_list, thread=True, **kwargs):
    """
    Author : chaitanya lohith bollapragada
    This will configure the "config_stp_vlan_parameters" in parallel to all DUTs mentioned.
    :param dut_list:
    :param vlan: list of vlans
    :param priority: list of STP priorities
    :param thread: True | False
    :return:
    """
    st.log("Configuring STP vlan parameters in paraller on all DUT's ... ")
    dut_li = list(dut_list) if isinstance(dut_list, list) else [dut_list]
    vlan_li = list(kwargs['vlan']) if isinstance(kwargs['vlan'],
                                                 list) else [kwargs['vlan']]
    priority_li = list(kwargs['priority']) if isinstance(
        kwargs['priority'], list) else [kwargs['priority']]
    if not len(dut_li) == len(vlan_li) == len(priority_li):
        return False
    params = list()
    for i, each in enumerate(dut_list):
        params.append(
            utility.ExecAllFunc(config_stp_vlan_parameters,
                                each,
                                vlan_li[i],
                                priority=priority_li[i]))
    [out, exceptions] = exec_all(thread, params)
    st.log(exceptions)
    return False if False in out else True
Exemplo n.º 3
0
def config_bgp_route_map(config='yes'):
    st.banner("{}Config BGP Route Map".format('Un' if config != 'yes' else ''))
    thread_info = list()
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_route_map_global_nexthop,
                          vars.D1,
                          route_map=eh_data.route_map_name,
                          sequence='10',
                          config=config))
    thread_info.append(
        utils.ExecAllFunc(ipapi.config_route_map_global_nexthop,
                          vars.D2,
                          route_map=eh_data.route_map_name,
                          sequence='10',
                          config=config))
    thread_call(thread_info)
Exemplo n.º 4
0
def apply_module_configuration():
    print_log("Applying module configuration")

    data.dut1_lag_members = [vars.D1D2P1, vars.D1D2P2]
    data.dut2_lag_members = [vars.D2D1P1, vars.D2D1P2]

    # create portchannel
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.create_portchannel, vars.D1, data.portChannelName),
        utils.ExecAllFunc(pc_obj.create_portchannel, vars.D2, data.portChannelName),
    ])

    # add portchannel members
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.add_portchannel_member, vars.D1, data.portChannelName, data.dut1_lag_members),
        utils.ExecAllFunc(pc_obj.add_portchannel_member, vars.D2, data.portChannelName, data.dut2_lag_members),
    ])
Exemplo n.º 5
0
def clear_module_configuration():
    print_log("Clearing module configuration")
    # delete Ipv4 address
    print_log("Delete ip address configuration:")
    ip_obj.clear_ip_configuration([vars.D1, vars.D2], family='ipv4')
    # delete Ipv6 address
    ip_obj.clear_ip_configuration([vars.D1, vars.D2], family='ipv6')
    # delete ipv4 static routes
    ip_obj.delete_static_route(vars.D1, data.ipv4_portchannel_D2, data.ipv4_network_D2, shell="vtysh",
                               family="ipv4")
    ip_obj.delete_static_route(vars.D2, data.ipv4_portchannel_D1, data.ipv4_network_D1, shell="vtysh",
                               family="ipv4")
    # delete ipv6 static routes
    ip_obj.delete_static_route(vars.D1, data.ipv6_portchannel_D2, data.ipv6_network_D2, shell="vtysh",
                               family="ipv6")
    ip_obj.delete_static_route(vars.D2, data.ipv6_portchannel_D1, data.ipv6_network_D1, shell="vtysh",
                               family="ipv6")
    # delete port channel members
    print_log("Deleting members from port channel:")
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.delete_portchannel_member, vars.D1, data.portChannelName, data.dut1_lag_members),
        utils.ExecAllFunc(pc_obj.delete_portchannel_member, vars.D2, data.portChannelName, data.dut2_lag_members),
    ])
    # delete port channel
    print_log("Deleting port channel configuration:")
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.delete_portchannel, vars.D1, data.portChannelName),
        utils.ExecAllFunc(pc_obj.delete_portchannel, vars.D2, data.portChannelName),
    ])
    # delete acl tables and rules
    print_log("Deleting ACLs:")

    [_, exceptions] = utils.exec_all(True, [[acl_obj.acl_delete, vars.D1], [acl_obj.acl_delete, vars.D2]])
    ensure_no_exception(exceptions)
    #Clear static arp entries
    print_log("Clearing ARP entries")
    arp_obj.clear_arp_table(vars.D1)
    arp_obj.clear_arp_table(vars.D2)
    #Clear static ndp entries
    print_log("Clearing NDP entries")
    arp_obj.clear_ndp_table(vars.D1)
    arp_obj.clear_ndp_table(vars.D2)
Exemplo n.º 6
0
def config_stp_root_bridge_by_vlan(stp_data):
    """
    :param stp_data: {dut1: {"vlan":10, "priority": "0"}, dut2: {"vlan":20, "priority": "0"}, dut3: {"vlan":30, "priority": "0"}}
    """
    params = list()
    for dut, data in stp_data.items():
        params.append(
            utility.ExecAllFunc(config_stp_vlan_parameters,
                                dut,
                                data["vlan"],
                                priority=data["priority"]))
    [out, exceptions] = exec_all(True, params)
    ensure_no_exception(exceptions)
Exemplo n.º 7
0
def qos_save_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1T1:1")

    st.log("Configuring supported QoS features")
    wred_data = wred_config.init_vars(vars)
    st.log('Creating WRED and ECN table')
    utils.exec_all(True, [
        utils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                          wred_data['wred_ecn_json_config'])
    ])
    st.log("Checking for wred config before save and reboot")
    wred_verify()
    st.log("checking for ecn config before save and reboot")
    ecn_verify()
    st.log("Configuring IPV4 ACL with rule")
    ipv4_acl_config()
    st.log("Configuring IPV6 ACL with rule")
    ipv6_acl_config()
    st.log("Checking for IPV4 ACL config before save and reboot")
    ipv4_acl_verify()
    st.log("Checking for IPV6 ACL config before save and reboot")
    ipv6_acl_verify()
    st.log("Configuring COS")
    cos_config()
    st.log("Checking for COS config before save and reboot")
    cos_config_verify()

    yield
    # add things at the end of this module"
    #Below step will clear COS, WRED and ECN config from the device.
    qos_obj.clear_qos_config(vars.D1)
    #Below step will clear all ACL config from the device.
    acl_obj.clear_acl_config(vars.D1)
Exemplo n.º 8
0
def config_bgp_topology(config='yes'):
    st.banner(
        "{}Config BGP on devices".format('Un' if config != 'yes' else ''))
    if config == 'yes':
        thread_info = list()
        thread_info.append(
            utils.ExecAllFunc(bgpapi.config_bgp_multi_neigh_use_peergroup,
                              vars.D1,
                              local_asn=eh_data.local_asn,
                              peer_grp_name=eh_data.peer_gp_namev4,
                              remote_asn=eh_data.remote_asn,
                              neigh_ip_list=eh_data.ipv4_nbr,
                              family=eh_data.af_ipv4,
                              activate=1))
        thread_info.append(
            utils.ExecAllFunc(bgpapi.config_bgp_multi_neigh_use_peergroup,
                              vars.D2,
                              local_asn=eh_data.remote_asn,
                              peer_grp_name=eh_data.peer_gp_namev4,
                              remote_asn=eh_data.local_asn,
                              neigh_ip_list=eh_data.ipv4_addr,
                              family=eh_data.af_ipv4,
                              activate=1))
        thread_call(thread_info)

        thread_info = list()
        thread_info.append(
            utils.ExecAllFunc(bgpapi.config_bgp_multi_neigh_use_peergroup,
                              vars.D1,
                              local_asn=eh_data.local_asn,
                              peer_grp_name=eh_data.peer_gp_namev6,
                              remote_asn=eh_data.remote_asn,
                              neigh_ip_list=eh_data.ipv6_nbr,
                              family=eh_data.af_ipv6,
                              activate=1,
                              routemap=eh_data.route_map_name,
                              routemap_dir='in'))
        thread_info.append(
            utils.ExecAllFunc(bgpapi.config_bgp_multi_neigh_use_peergroup,
                              vars.D2,
                              local_asn=eh_data.remote_asn,
                              peer_grp_name=eh_data.peer_gp_namev6,
                              remote_asn=eh_data.local_asn,
                              neigh_ip_list=eh_data.ipv6_addr,
                              family=eh_data.af_ipv6,
                              activate=1,
                              routemap=eh_data.route_map_name,
                              routemap_dir='in'))
        thread_call(thread_info)

        if config == 'yes':
            if not utils.poll_wait(bgpapi.verify_bgp_summary,
                                   30,
                                   vars.D1,
                                   family='ipv4',
                                   neighbor=[eh_data.ipv4_nbr],
                                   state='Established'):
                st.error(
                    "BGP Neighbor failed to Establish between DUT and Partner")
                st.report_fail('operation_failed')
            if not utils.poll_wait(bgpapi.verify_bgp_summary,
                                   30,
                                   vars.D1,
                                   family='ipv6',
                                   neighbor=[eh_data.ipv6_nbr],
                                   state='Established'):
                st.error(
                    "BGP Neighbor failed to Establish between DUT and Partner")
                st.report_fail('operation_failed')
    else:
        bgpapi.cleanup_router_bgp(st.get_dut_names())
Exemplo n.º 9
0
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)
Exemplo n.º 10
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()