Exemplo n.º 1
0
def qos_fast_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    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')
    putils.exec_all(True, [
        putils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                           wred_data['wred_ecn_json_config'])
    ])
    st.log("Checking for wred config before save and fast-reboot")
    wred_verify()
    st.log("checking for ecn config before save and fast-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 fast-reboot")
    ipv4_acl_verify()
    st.log("Checking for IPV6 ACL config before save and fast-reboot")
    ipv6_acl_verify()
    st.log("Configuring COS")
    cos_config()
    st.log("Checking for COS config before save and fast-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.º 2
0
def clear_port_shaper(dut, port='', shaper_data='', **kwargs):
    """
    API to clear shaper and detach shaper from port
    :param dut:
    :type dut:
    :param port:
    :type port:
    :param shaper_data:
    :type shaper_data:
    :param cli_type:
    :type cli_type:
    :return:
    :rtype:
    """
    cli_type = st.get_ui_type(dut, **kwargs)
    skip_error = kwargs.get('skip_error', False)
    cli_type = 'klish' if skip_error and cli_type == 'click' else cli_type
    qos_clear = kwargs.get('qos_clear', False)
    remove_shaper = kwargs.get('remove_shaper', True)
    if (not qos_clear) and cli_type == 'click':
        cli_type = 'klish'
    if cli_type == 'click':
        clear_qos_config(dut)
    elif cli_type == 'klish':
        commands = list()
        if port:
            intf_data = get_interface_number_from_name(port)
            commands.append("interface {} {}".format(intf_data['type'],
                                                     intf_data['number']))
            commands.append("no scheduler-policy")
            commands.append("exit")
        if shaper_data and remove_shaper:
            commands.append("no qos scheduler-policy {}".format(shaper_data))
        response = st.config(dut,
                             commands,
                             type=cli_type,
                             skip_error_check=skip_error)
        if any(error in response.lower() for error in errors_list):
            st.error("The response is: {}".format(response))
            return False
    elif cli_type in ['rest-patch', 'rest-put']:
        rest_urls = st.get_datastore(dut, "rest_urls")
        if port:
            url = rest_urls['policy_apply_config'].format(port)
            if not delete_rest(dut, rest_url=url):
                st.error(
                    "Failed to remove scheduler-policy on port: {}".format(
                        port))
                return False
        if shaper_data and remove_shaper:
            url = rest_urls['scheduler_policy_config'].format(shaper_data)
            if not delete_rest(dut, rest_url=url):
                st.error("Failed to remove QOS scheduler-policy: {}".format(
                    shaper_data))
                return False
    else:
        st.error("Unsupported CLI Type: {}".format(cli_type))
        return False
    return True
Exemplo n.º 3
0
def config_mgmt_module_hooks(request):
    # add things at the start of this module
    yield
    # add things at the end of this module"
    #Setting the MTU value to default
    intf_obj.interface_properties_set(vars.D1, data.eth, data.property,
                                      data.mtu_default)
    #Below step will clear all CRM config from the device.
    crm_obj.set_crm_clear_config(vars.D1)
    #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)
    st.log("Deleting the vlan-{}".format(data.vlan))
    rv = vlan_obj.clear_vlan_configuration(st.get_dut_names())
    if not rv:
        st.report_fail("vlan_delete_fail", data.vlan)
Exemplo n.º 4
0
def qos_warm_reboot_module_hooks(request):
    # add things at the start of this module
    init_vars()
    initialize_variables()
    get_parms()

    st.log("Checking whether the platform supports warm-reboot")
    if not data.platform.lower(
    ) in data.constants['WARM_REBOOT_SUPPORTED_PLATFORMS']:
        st.report_unsupported('test_case_unsupported')

    st.log("Configuring supported QoS features")
    wred_data = wred_config.init_vars(vars)
    st.log('Creating WRED and ECN table')
    putils.exec_all(True, [
        putils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                           wred_data['wred_ecn_json_config'])
    ])
    st.log("Checking for wred config before save and warm-reboot")
    wred_verify()
    st.log("checking for ecn config before save and warm-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 warm-reboot")
    ipv4_acl_verify()
    st.log("Checking for IPV6 ACL config before save and warm-reboot")
    ipv6_acl_verify()
    st.log("Configuring COS")
    cos_config()
    st.log("Checking for COS config before save and warm-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.º 5
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)