Esempio n. 1
0
def get_mac_agetime(dut, cli_type=""):
    """
    :param dut:
    :type dut:
    :return:
    :rtype:
    """
    command = ''
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    if cli_type == 'click':
        if st.is_feature_supported("show-mac-aging-time-command", dut):
            command = "show mac aging-time"
        elif st.is_feature_supported("show-mac-aging_time-command", dut):
            command = "show mac aging_time"
        else:
            st.community_unsupported("show mac aging-time", dut)
            return 300
    elif cli_type == 'klish':
        command = "show mac address-table aging-time"
    elif cli_type in ['rest-patch', 'rest-put']:
        rest_urls = st.get_datastore(dut, 'rest_urls')
        url = rest_urls["mac_aging"].format(name='default')
        out = get_rest(dut, rest_url= url)
        if isinstance(out, dict) and out.get('output') and 'openconfig-network-instance:mac-aging-time' in out['output']:
            return int(out['output']['openconfig-network-instance:mac-aging-time'])

    else:
        st.error("Unsupported CLI_TYPE: {}".format(cli_type))
        return False

    if command:
        output = st.show(dut, command, type=cli_type)
        return int(output[0]["aging_time"])
    return True
Esempio n. 2
0
def test_ft_system_config_mgmt_verifying_config_with_save_fast_reboot():
    st.log("performing Config save")
    rb_obj.config_save(vars.D1)
    st.log("performing fast-reboot")
    st.reboot(vars.D1, 'fast')
    st.log(
        "Checking whether config is loaded to running config from config_db after fast-reboot"
    )
    st.log("Checking CRM config after save and fast-reboot")
    crm_config_verify()
    if st.is_feature_supported("interface-mtu", vars.D1):
        st.log("Checking the configured MTU value after save and fast-reboot")
        mtu_verify()
    if st.is_feature_supported("threshold", vars.D1):
        st.log("configured threshold values verification")
        threshold_verify()
    st.log("Checking ERSPAN config after fast-reboot")
    mirror_action_verify()
    if st.is_feature_supported("span-mirror-session", vars.D1):
        st.log("Checking SPAN config after save and reboot")
        port_mirror_verify()
    st.log(
        "configuration is successfully stored to config_db file after save and fast-reboot"
    )
    st.report_pass("test_case_passed")
Esempio n. 3
0
def extend(dut):
    st.log("Extend base config if needed", dut=dut)
    if not st.is_feature_supported("nat-default-enabled", dut):
        st.config(dut, "config feature state nat enabled")
    if not st.is_feature_supported("sflow-default-enabled", dut):
        st.config(dut, "config feature state sflow enabled")
    st.config(dut, "configure lldp status disabled", type='lldp')
    remove_vlan_1(dut, "base config")
Esempio n. 4
0
def system_fast_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    vars = st.ensure_min_topology("D1T1:2", 'D1D2:2', 'D2T1:1')
    initialize_variables()
    st.log("Configuring CRM")
    crm_config()
    st.log("Checking CRM config before save and fast-reboot")
    crm_config_verify()
    if st.is_feature_supported("interface-mtu", vars.D1):
        st.log("Configuring MTU on interface")
        mtu_config()
        st.log("Checking the configured MTU value before save and fast-reboot")
        mtu_verify()
    if st.is_feature_supported("threshold", vars.D1):
        st.log("configuring threshold values on interface")
        threshold_config()
        st.log("configured threshold values verification")
        threshold_verify()
    st.log("configure mirror session values")
    mirror_action_config()
    st.log("configured mirror session verification")
    mirror_action_verify()
    if st.is_feature_supported("span-mirror-session", vars.D1):
        st.log("Configuring port mirroring values")
        port_mirror_config()
        st.log("Checking port mirroring before save and reboot")
        port_mirror_verify()
    st.log("Configuring Port-Channel")
    config_portchannel()
    st.log("Configuring VLAN related configuration")
    dut_vlan_config()
    st.log("Configuring TGEN handlers and streams")
    tgen_config()
    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 steps will clear all threshold values configured on the device
    tf_obj.clear_threshold(vars.D1, breach='all')
    tf_obj.clear_threshold(vars.D1,
                           threshold_type='priority-group',
                           buffer_type='all')
    tf_obj.clear_threshold(vars.D1, threshold_type='queue', buffer_type='all')
    mirror.delete_session(vars.D1, "Mirror_Ses")
    mirror.delete_session(vars.D1, mirror_session=data.session_name_port)
    rb_obj.config_save(vars.D1)
Esempio n. 5
0
def clear_mac(dut,port=None,vlan=None,**kwargs):
    """
    This proc is to clear mac address/fdb entries of the dut.
    :param dut: DUT Number
    :return:
    """
    cli_type = st.get_ui_type(dut, **kwargs)
    cli_type = 'klish' if cli_type in ['rest-patch', 'rest-put'] else cli_type
    if cli_type == "click":
        if not st.is_feature_supported("sonic-clear-fdb-type-command", dut):
            command = "sonic-clear fdb all"
        elif port:
            command = "sonic-clear fdb port {}".format(port)
        elif vlan:
            command = "sonic-clear fdb vlan Vlan{}".format(vlan)
        else:
            command = "sonic-clear fdb all"
        st.config(dut, command, type=cli_type)
    elif cli_type == "klish":
        if 'address' in kwargs:
            command = "clear mac address-table dynamic address  {}".format(kwargs['address'])
        elif vlan:
            command = "clear mac address-table dynamic Vlan {}".format(vlan)
        elif port:
            intf_data = get_interface_number_from_name(port)
            command = "clear mac address-table dynamic interface {} {}".format(intf_data["type"],intf_data["number"])
        else:
            command = "clear mac address-table dynamic all"

        st.config(dut, command,type=cli_type)
    else:
        st.error("Unsupported CLI: {}".format(cli_type))
        return False
    return True
Esempio n. 6
0
def get_mac_count(dut, cli_type=""):
    """
    To get the MAC count using - 'show mac count' command.
    :param dut:
    :type dut:
    :return:
    :rtype:
    """
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    if cli_type == 'click':
        field = "mac_count"
        command = "show mac count"
        if not st.is_feature_supported("show-mac-count-command", dut):
            st.community_unsupported(command, dut)
            return 0
        output = st.show(dut, command, type=cli_type)
    elif cli_type == 'klish':
        field =  "count"
        command = "show mac address-table count"
        output = st.show(dut, command, type=cli_type)
    elif cli_type in ["rest-patch", "rest-put"]:
        result = get_mac(dut, cli_type=cli_type)
        mac_count = len(result)
        return  mac_count
    else:
        st.log("Unsupported cli")
        return False
    if not output:
        ### When MAC table is empty, klish doesn't display output so return 0
        return 0
    return int(output[0][field])
Esempio n. 7
0
def test_ft_vlan_delete_with_member():
    """
    Author: Surendra Kumar Vella ([email protected])

    Verify that user is not able to delete a valn till its members are deleted

    """
    vlan_data = [{"dut": [vars.D1], "vlan_id": sc_data.vlan_id, "tagged": [sc_data.free_port]}]
    st.log("checking whether vlan with member is deleted or not ")
    if not vlan.create_vlan_and_add_members(vlan_data):
        st.report_fail("vlan_tagged_member_fail", sc_data.free_port, sc_data.vlan_id)
    if st.is_feature_supported("prevent-delete-vlans-with-members", vars.D1):
        if sc_data.cli_type == "click":
            if vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_deletion_successfull_albiet_having_member", sc_data.vlan_id)
            if not vlan.delete_vlan_member(vars.D1, sc_data.vlan_id, sc_data.free_port, tagging_mode=True):
                st.report_fail("vlan_tagged_member_fail", sc_data.free_port, sc_data.vlan_id)
            if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_delete_fail", sc_data.vlan_id)
        else:
            if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_delete_fail", sc_data.vlan_id)
    else:
        if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
            st.report_fail("vlan_delete_fail", sc_data.vlan_id)
    st.report_pass("test_case_passed")
Esempio n. 8
0
def config_mac_agetime(dut, agetime, cli_type="", config= "add", **kwargs):
    """
    This proc is to config mac aging and setting it back to default.
    :param dut: DUT Number
    :param agetime: fdb age time in seconds
    :return:
    """
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    skip_error_check = kwargs.get('skip_error', False)
    command = ''
    if cli_type == 'click':
        command = "config mac aging_time {}".format(int(agetime))
        if not st.is_feature_supported("config-mac-aging_time-command", dut):
            st.community_unsupported(command, dut)
            skip_error_check=True
    elif cli_type == 'klish':
        if config == 'add':
            command = "mac address-table aging-time {}".format(int(agetime))
        else:
            command = "no mac address-table aging-time"
    elif cli_type in ['rest-patch', 'rest-put']:
        rest_urls = st.get_datastore(dut, 'rest_urls')
        url = rest_urls['mac_aging'].format(name='default')
        config_data = {"openconfig-network-instance:mac-aging-time": int(agetime)}
        if not config_rest(dut, rest_url=url, http_method=cli_type, json_data=config_data):
              st.error("Failed to configure aging as {}".format(agetime))
              return False
    if command:
        st.config(dut, command, skip_error_check=skip_error_check, type=cli_type)
    return True
Esempio n. 9
0
def config_mac(dut, mac, vlan, intf, cli_type=""):
    """
    :param dut:
    :type dut:
    :return:
    :rtype:
    """
    #st.log("config mac add <mac> <vlan> <intf>")
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    if cli_type == 'click':
        command = "config mac add {} {} {}".format(mac, vlan, intf)
        if not st.is_feature_supported("config-mac-add-command", dut):
            st.community_unsupported(command, dut)
            _json_mac_add(dut, mac, vlan, intf)
        else:
            st.config(dut, command, type='click')
    elif cli_type == 'klish':
        interface = get_interface_number_from_name(intf)
        command = "mac address-table {} vlan {} {} {}".format(
            mac, vlan, interface["type"], interface["number"])
        st.config(dut, command, type=cli_type)
    elif cli_type in ["rest-patch", "rest-put"]:
        rest_urls = st.get_datastore(dut, "rest_urls")
        url = rest_urls['static_mac_config']
        json = {
            "openconfig-network-instance:network-instances": {
                "network-instance": [{
                    "name": "default",
                    "fdb": {
                        "mac-table": {
                            "entries": {
                                "entry": [{
                                    "mac-address": mac,
                                    "vlan": int(vlan),
                                    "config": {
                                        "mac-address": mac,
                                        "vlan": int(vlan)
                                    },
                                    "interface": {
                                        "interface-ref": {
                                            "config": {
                                                "interface": intf,
                                                "subinterface": 0
                                            }
                                        }
                                    }
                                }]
                            }
                        }
                    }
                }]
            }
        }
        if not config_rest(
                dut, http_method=cli_type, rest_url=url, json_data=json):
            return False
    else:
        st.log("Unsupported cli")
        return False
    return True
Esempio n. 10
0
def delete_mac(dut, mac, vlan, cli_type=""):
    """
    :param dut:
    :type dut:
    :return:
    :rtype:
    """
    #st.log("config mac del <mac> <vlan>")
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    if cli_type == 'click':
        command = "config mac del {} {}".format(mac, vlan)
        if not st.is_feature_supported("config-mac-add-command", dut):
            st.community_unsupported(command, dut)
            _json_mac_del(dut, mac, vlan)
        else:
            st.config(dut, command, type=cli_type)
    elif cli_type == 'klish':
        command = "no mac address-table {} vlan {}".format(mac, vlan)
        st.config(dut, command, type=cli_type)
    elif cli_type in ["rest-patch", "rest-put"]:
        network_instance_name = 'default'
        rest_urls = st.get_datastore(dut, "rest_urls")
        url = rest_urls['mac_entry_based_vlan_interface'].format(
            network_instance_name, mac, vlan)
        delete_rest(dut, rest_url=url)
    else:
        st.log("Unsupported cli")
        return False

    return True
Esempio n. 11
0
def set_crm_clear_config(dut, cli_type=""):
    """
    API to clear CRM configuration.
    Author : Prudvi Mangadu ([email protected])
    :param dut:
    :param cli_type: click or klish designation:
    :return: Command output
    """
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    if cli_type == "click":
        command = "crm config clear"
        if not st.is_feature_supported("crm-config-clear-command", dut):
            st.community_unsupported(command, dut)
            command = "crm config polling interval 9999999"
    elif cli_type == "klish":
        command = "no crm all"
    elif cli_type in ["rest-patch", "rest-put"]:
        rest_urls = st.get_datastore(dut, "rest_urls")
        url = rest_urls['crm_all']
        if not delete_rest(dut, rest_url=url):
            return False
        return True
    else:
        st.error("Unsupported cli type: {}".format(cli_type))
        return False
    return st.config(dut, command, type=cli_type)
def security_module_prolog():
    tacacs_config()
    tacacs_config_verify()
    if st.is_feature_supported("radius", vars.D1):
        radius_config()
        st.log("Verifying radius server details")
        checking_radius_config(security_data.radius_host_ip)
Esempio n. 13
0
def vlan_module_prolog():
    """
    Module prolog for module configuration
    :return:
    """
    st.log("Creating vlan in device and adding members ...")
    vlan.create_vlan_and_add_members(sc_data.vlan_data)
    if st.is_feature_supported("strom-control", vars.D1):
        st.banner("Configuring BUM Storm control on interfaces")
        interface_list = [vars.D1T1P1, vars.D1T1P2]
        storm_control_type = [
            "broadcast", "unknown-multicast", "unknown-unicast"
        ]
        for interface in interface_list:
            for stc_type in storm_control_type:
                scapi.config(vars.D1,
                             type=stc_type,
                             action="add",
                             interface_name=interface,
                             bits_per_sec=sc_data.kbps)
                if not scapi.verify_config(vars.D1,
                                           interface_name=interface,
                                           type=stc_type,
                                           rate=sc_data.kbps):
                    st.report_fail("storm_control_config_verify_failed",
                                   stc_type, interface)
Esempio n. 14
0
def bgp_fast_reboot_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:1", "D1T1:2")
    if not st.is_feature_supported("bgp-neighbotship-performance", vars.D1):
        data.neighborship_wait = 30

    st.log("Enabling IPv6 mode globally")
    ip_obj.config_ipv6(vars.D1, action='enable')
    ip_obj.config_ipv6(vars.D2, action='enable')

    st.log("Configuring ipv4 addresses on routing interfaces")
    ipv4_ip_address_config()

    st.log("Verifying ipv4 addresses on routing interfaces")
    verify_ipv4_address_config()

    if data.ipv6_support:
        st.log("Configuring ipv6 addresses on routing interfaces")
        ipv6_address_config()
        st.log("Verifying ipv6 addresses on routing interfaces")
        verify_ipv6_address_config()
        st.log(
            "Configuring IPV6 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG2"
        )
        ipv6_bgp_config()

    st.log(
        "Configuring IPV4 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG1"
    )
    ipv4_bgp_config()

    if data.ipv6_support:
        st.log("Configuring TG2 V6 iBGP config")
        tg_bgpv6_config(vars, data.local_asn4, data.remote_asn4)

    st.log("Configuring TG1 V4 iBGP config")
    tg_bgp_config(vars, data.local_asn4, data.remote_asn4)

    st.log(
        "Verify IPV4 eBGP neighborship between D1 and D2 and iBGP neighborship between D1 and TG1"
    )
    verify_v4_bgp_neigborship()

    if data.ipv6_support:
        st.log(
            "Verify IPV6 eBGP neighborship between D1 and D2 and iBGP neighborship between D1 and TG2"
        )
        verify_v6_bgp_neigborship()

    yield

    bgp_obj.cleanup_router_bgp(st.get_dut_names())
    ip_obj.clear_ip_configuration(st.get_dut_names())

    if data.ipv6_support:
        ip_obj.clear_ip_configuration(st.get_dut_names(), 'ipv6')

    vlan_obj.clear_vlan_configuration(st.get_dut_names())
    portchannel_obj.clear_portchannel_configuration(st.get_dut_names())
Esempio n. 15
0
def get_crm_thresholds(dut, family, cli_type=""):
    """
    GET CRM Threshold w.r.t family.
    Author : Prudvi Mangadu ([email protected])
    :param dut:
    :param family:
    :param cli_type: click or klish designation:
    :return:
    """
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    family = family.lower()
    # Handling few show crm family cli commands
    if family in ['acl_group_entry', 'acl_group_counter', 'acl_table_stats']:
        if st.is_feature_supported("crm-all-families", dut):
            family = 'all'
            cli_type = 'klish'
    family_list = crm_get_family_list(dut)
    if family not in family_list:
        log = "family:'{}' is invalid , use any of valid family from - {}".format(
            family, ','.join(family_list))
        st.error(log)
        return False
    if cli_type == "click":
        command = 'crm show thresholds {}'.format(family.replace('_', ' '))
        output = st.show(dut, command, type=cli_type)
    elif cli_type == "klish":
        command = 'show crm thresholds {}'.format(family.replace('_', ' '))
        output = st.show(dut, command, type=cli_type)
    elif cli_type in ["rest-patch", "rest-put"]:
        output = list()
        rest_urls = st.get_datastore(dut, "rest_urls")
        url = rest_urls['crm_thresholds']
        result = get_rest(
            dut, rest_url=url)["output"]["openconfig-system-crm:threshold"]
        family_mapping = {
            "nexthop_group_member": "nexthop_group-member",
            "nexthop_group_object": "nexthop_group-object"
        }
        families = make_list(family)
        if "all" in families:
            families = family_list
            families.remove("all")
        for family2 in families:
            crm_threshold = {}
            crm_threshold["resourcename"] = family2
            family2 = family_mapping.get(family2, family2).split("_")
            for each in family2:
                result = result[each]
            if result["state"].get("type", ""):
                crm_threshold["thresholdtype"] = result["state"]["type"].lower(
                )
                crm_threshold["highthreshold"] = result["state"]["high"]
                crm_threshold["lowthreshold"] = result["state"]["low"]
                output.append(crm_threshold)
    else:
        st.error("Unsupported cli type: {}".format(cli_type))
        return False
    return output
Esempio n. 16
0
def crm_get_family_list(dut):
    retval = list(g_family_list)
    if not st.is_feature_supported("crm-all-families", dut):
        exclude = ["dnat", "ipmc", "snat"]
        exclude.extend(['acl_group_entry', 'acl_group_counter'])
        exclude.extend(['acl_table_stats'])
        for exc in exclude:
            retval.remove(exc)
    return retval
def security_module_prolog():
    tacacs_config()
    tacacs_config_verify()
    if not st.is_feature_supported("radius"):
        return
    config_global_radius()
    radius_config()
    st.log("Verifying radius server details before save-reboot")
    checking_radius_config(security_data.radius_host_ip)
Esempio n. 18
0
def vlan_module_epilog():
    if st.is_feature_supported("strom-control", vars.D1):
        interface_list = [vars.D1T1P1, vars.D1T1P2]
        storm_control_type = ["broadcast", "unknown-multicast", "unknown-unicast"]
        for interface in interface_list:
            for stc_type in storm_control_type:
                scapi.config(vars.D1, type=stc_type, action="del", interface_name=interface, bits_per_sec=sc_data.kbps)
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)
    portchannel.clear_portchannel_configuration(st.get_dut_names(),thread=True)
Esempio n. 19
0
 def f(dut, scope):
     if st.get_device_type(dut) in ["sonic", "vsonic"]:
         st.banner("apis_instrument: {}".format(scope), dut=dut)
         st.show(dut, "show version", skip_error_check=True,
                  skip_tmpl=True)
         st.show(dut, "show runningconfiguration all",
                  skip_error_check=True, skip_tmpl=True)
         if st.is_feature_supported("system-status", dut):
             st.show(dut, "show system status", skip_error_check=True,
                      skip_tmpl=True)
Esempio n. 20
0
def set_speed(dut, data, cli_type=""):
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    cli_type = 'klish' if cli_type in ['rest-patch', 'rest-put'] else cli_type
    platform = basic.get_hwsku(dut)
    ports_per_pg = 12 if platform in ["Accton-AS7326-56X"] else 4
    non_portgroup_platforms = [
        "Accton-AS7712-32X", "Quanta-IX8A-BWDE-56X", "AS5835-54X"
    ]

    if not st.is_feature_supported("port-group", dut):
        non_portgroup_platforms.append(platform)

    ports_dict = dict()
    port_name_dict = dict()
    for index in range(0, len(data), 2):
        port = st.get_other_names(
            dut, [data[index]])[0] if "/" in data[index] else data[index]
        port_name_dict[port] = data[index + 1]
        id = re.search(r"\d+", port).group(0)
        id = (int(int(id) / ports_per_pg)) + 1
        ports_dict[str(id)] = data[index + 1]
    st.debug("port-group speed data: {}".format(ports_dict))
    commands = list()
    if cli_type == 'click':
        if platform not in non_portgroup_platforms:
            commands = [
                "config portgroup speed {} {}".format(index, speed)
                for index, speed in ports_dict.items()
            ]
        else:
            commands = [
                "portconfig -p {} -s {}".format(port, speed)
                for port, speed in port_name_dict.items()
            ]
    elif cli_type == 'klish':
        if platform not in non_portgroup_platforms:
            commands = [
                "port-group {} speed {}".format(index, speed)
                for index, speed in ports_dict.items()
            ]
        else:
            for port, speed in port_name_dict.items():
                intf_details = get_interface_number_from_name(port)
                if not intf_details:
                    st.error("Interface data not found for {} ".format(port))
                    continue
                commands.append("interface {} {}".format(
                    intf_details["type"], intf_details["number"]))
                commands.append("speed {}".format(speed))
                commands.append("exit")
    else:
        st.error("Unsupported CLI_TYPE: {}".format(cli_type))
    if commands:
        st.config(dut, commands, type=cli_type)
    return True
Esempio n. 21
0
def vlan_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:2", "D1T1:2", "D2T1:2")
    sc_data.version_data = basic_obj.show_version(vars.D1)
    vlan_variables()
    if not st.is_feature_supported("vlan-range", vars.D1):
        sc_data.max_vlan = 100
    [_, exceptions] = exec_all(True, [[config_tg_stream], [vlan_module_prolog]], first_on_main=True)
    ensure_no_exception(exceptions)
    yield
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)
def security_module_epilog():
    tacacs.set_tacacs_server(vars.D1, 'delete', security_data.tacacs_host_ip)
    if not st.is_feature_supported("radius", vars.D1):
        return
    radius.config_server(vars.D1, ip_address=security_data.radius_host_ip, action="delete")
    radius.config_global_server_params(vars.D1, skip_error_check=False,
                                       params={"key": {"value": security_data.global_diff_passkey, "no_form": True},
                                               "timeout": {"value": security_data.global_timeout, "no_form": True},
                                               "auth_type": {"value": security_data.global_auth_type, "no_form": True},
                                               "retransmit": {"value": security_data.global_retransmit,
                                                              "no_form": True}})
def test_ft_security_config_mgmt_verifying_config_with_save_reboot():
    '''
    Author: Sai Durga <*****@*****.**>
       FtOpSoScRaFn006:   Verify that radius config retained after config save and reboot
    '''
    st.log("performing Config save and reloading the device")
    reboot.config_save_reload(vars.D1)
    tacacs_config_verify()
    if st.is_feature_supported("radius", vars.D1):
        checking_radius_config(security_data.radius_host_ip)
    st.report_pass("security_config_retained_after_save_reboot")
def test_ft_security_config_mgmt_verifying_config_with_save_fast_reboot():
    '''
     Author: Sai Durga <*****@*****.**>
     FtOpSoScRaFn007:   Verify that radius config retained after config save and fast boot
    '''
    reboot.config_save(vars.D1)
    st.reboot(vars.D1, 'fast')
    st.wait(security_data.delay)
    tacacs_config_verify()
    if st.is_feature_supported("radius", vars.D1):
        checking_radius_config(security_data.radius_host_ip)
    st.report_pass("security_config_retained_after_fast_reboot")
Esempio n. 25
0
def test_ft_enable_kdump():

    vars = st.get_testbed_vars()

    if not st.is_feature_supported("show-kdump-status-command", vars.D1):
        st.report_unsupported('test_case_unsupported')

    result = perform_test(vars)
    clean_up(vars)
    st.config(vars.D1, 'rm -rf /var/crash/20*')
    if result: st.report_fail("msg", result)
    st.report_pass("operation_successful")
Esempio n. 26
0
def bgp_save_reboot_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:1", "D1T1:2")
    data.shell_vtysh = st.get_ui_type()
    if data.shell_vtysh == "click":
        data.shell_vtysh = "vtysh"
    if not st.is_feature_supported("bgp-neighbotship-performance", vars.D1):
        data.neighborship_wait = 30

    st.log("Enabling IPv6 mode globally")
    st.exec_each([vars.D1, vars.D2], ip_obj.config_ipv6, action='enable')

    st.log("Configuring ipv4 addresses on routing interfaces")
    st.exec_each([vars.D1, vars.D2], ipv4_ip_address_config)

    st.log("Verifying ipv4 addresses on routing interfaces")
    st.exec_each([vars.D1, vars.D2], verify_ipv4_address_config)

    if data.ipv6_support:
        st.log("Configuring ipv6 addresses on routing interfaces")
        st.exec_each([vars.D1, vars.D2], ipv6_address_config)
        st.log("Verifying ipv6 addresses on routing interfaces")
        st.exec_each([vars.D1, vars.D2], verify_ipv6_address_config)
        st.log(
            "Configuring IPV6 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG2"
        )
        st.exec_each([vars.D1, vars.D2], ipv6_bgp_config)

    st.log(
        "Configuring IPV4 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG1"
    )
    st.exec_each([vars.D1, vars.D2], ipv4_bgp_config)

    if data.ipv6_support:
        st.log("Configuring TG2 V6 iBGP config")
        tg_bgpv6_config(vars, data.local_asn4, data.remote_asn4)

    st.log("Configuring TG1 V4 iBGP config")
    tg_bgp_config(vars, data.local_asn4, data.remote_asn4)

    yield

    bgp_obj.cleanup_router_bgp(st.get_dut_names())
    ip_obj.clear_ip_configuration(st.get_dut_names())

    if data.ipv6_support:
        ip_obj.clear_ip_configuration(st.get_dut_names(),
                                      'ipv6',
                                      skip_error_check=True)

    vlan_obj.clear_vlan_configuration(st.get_dut_names())
    portchannel_obj.clear_portchannel_configuration(st.get_dut_names())
Esempio n. 27
0
def test_cli_validation_ip_address():
    vlan.config_vlan_range(dut,
                           vlan_range="101 121",
                           config="add",
                           skip_verify=False)
    st.banner("click cli validation for ip address config")
    start_time = datetime.datetime.now()
    st.log("IP address config on 20 vlan routing interface using click")
    for each in range(101, 121):
        cmd = [
            "config interface ip add Vlan{} 192.168.{}.1/31".format(
                each, each)
        ]
        st.config(dut, cmd, type="click")
    end_time = datetime.datetime.now()
    time_diff = end_time - start_time
    st.banner(
        "time taken for IP address config on 20 vlan routing interface using click: {}"
        .format(time_diff))

    st.log("IP address unconfig on 20 vlan routing interface using click")
    for each in range(101, 121):
        cmd = [
            "config interface ip remove Vlan{} 192.168.{}.1/31".format(
                each, each)
        ]
        st.config(dut, cmd, type="click")
    st.report_tc_pass("FtOpSoRtPerfFn054", "test_case_passed")

    if st.is_feature_supported("klish"):
        st.banner("klish cli validation for ip address config")
        start_time = datetime.datetime.now()
        for each in range(101, 121):
            cmd = [
                "interface Vlan {}".format(each),
                'ip address 192.168.{}.1/31'.format(each), 'exit'
            ]
            st.config(dut, cmd, type="klish")
            end_time = datetime.datetime.now()
        time_diff = end_time - start_time
        st.banner(
            "time taken for IP address config on 20 vlan routing interface using klish: {}"
            .format(time_diff))
        for each in range(101, 121):
            cmd = [
                "interface Vlan {}".format(each),
                'no ip address 192.168.{}.1/31'.format(each), 'exit'
            ]
            st.config(dut, cmd, type="klish")
        st.report_tc_pass("FtOpSoRtPerfFn055", "test_case_passed")
    st.report_pass("test_case_passed")
Esempio n. 28
0
def verify_vrf_verbose(dut, **kwargs):
    """
    verify_vrf_verbose(dut1,vrfname="Vrf-103",interface='Ethernet2')
    """
    cli_type = kwargs.pop('cli_type', st.get_ui_type(dut))
    #cli_type = "klish" if cli_type in ["rest-put", "rest-patch"] else cli_type
    vrfname = kwargs['vrfname']
    interface = kwargs['interface']
    if not isinstance(vrfname, list):
        vrfname = [vrfname]
    if cli_type == 'click':
        cmd = "show vrf --verbose"
        if not st.is_feature_supported("show-vrf-verbose-command", dut):
            st.community_unsupported(cmd, dut)
            cmd = "show vrf"
        st.log("verify {} output".format(cmd))
        output = st.show(dut, cmd)
        for vname, intf in zip(vrfname, interface):
            match = {"vrfname": vname, "interfaces": intf}
            entries = filter_and_select(output, ["vrfname"], match)
            if not bool(entries):
                return bool(entries)
        return True
    elif cli_type == 'klish':
        cmd = "show ip vrf"
        output = st.show(dut, cmd, type=cli_type)
        for vname, intf in zip(vrfname, interface):
            match = {"vrfname": vname, "interfaces": intf}
            entries = filter_and_select(output, ["vrfname"], match)
            if not bool(entries):
                return bool(entries)
        return True
    elif cli_type in ['rest-patch', 'rest-put']:
        rest_urls = st.get_datastore(dut, 'rest_urls')
        for vname, intf in zip(vrfname, interface):
            rest_url = rest_urls['vrf_config'].format(vname)
            payload = get_rest(
                dut, rest_url=rest_url
            )['output']['openconfig-network-instance:network-instance']
            for item in payload:
                if item['state'][
                        'type'] != 'openconfig-network-instance-types:L3VRF':
                    return False
                if item['state']['name'] != str(vname):
                    return False
                for intface in item['interfaces']['interface']:
                    if intface['state']['id'] == intf:
                        return False
        return True
    else:
        st.log("Unsupported cli")
Esempio n. 29
0
def clear_interface_counters(dut, **kwargs):
    cli_type = st.get_ui_type(dut, **kwargs)
    interface_name = kwargs.get("interface_name", "")
    interface_type = kwargs.get("interface_type", "all")
    if cli_type == "klish":
        confirm = kwargs.get("confirm") if kwargs.get("confirm") else "y"
        if interface_type != "all":
            interface_type = get_interface_number_from_name(
                str(interface_name))
            if interface_type["type"] and interface_type["number"]:
                interface_val = "{} {}".format(interface_type.get("type"),
                                               interface_type.get("number"))
            else:
                interface_val = ""
        else:
            interface_val = "all"
        if not interface_val:
            st.log("Invalid interface type")
            return False
        command = "clear counters interface {}".format(interface_val)
        st.config(dut,
                  command,
                  type=cli_type,
                  confirm=confirm,
                  conf=False,
                  skip_error_check=True)
    elif cli_type == "click":
        command = "show interfaces counters -c"
        if not st.is_feature_supported(
                "show-interfaces-counters-clear-command", dut):
            st.community_unsupported(command, dut)
            return st.config(dut, "sonic-clear counters")
        return st.show(dut, command)
    elif cli_type in ["rest-patch", "rest-put"]:
        rest_urls = st.get_datastore(dut, "rest_urls")
        url = rest_urls['clear_interface_counters']
        clear_type = 'all' if interface_type == 'all' else interface_name
        clear_counters = {
            "sonic-interface:input": {
                "interface-param": clear_type
            }
        }
        if not config_rest(
                dut, http_method='post', rest_url=url,
                json_data=clear_counters):
            st.error("Failed to clear interface counters")
            return False
    else:
        st.log("Unsupported CLI TYPE {}".format(cli_type))
        return False
    return True
Esempio n. 30
0
def get_vrf_verbose(dut, **kwargs):
    """
    get_vrf_verbose(dut1,vrfname="Vrf-1")
    """
    match_dict = {}
    if 'vrfname' in kwargs:
        match_dict['vrfname'] = kwargs['vrfname']
    else:
        st.error("Mandatory parameter peeraddress is not found")
        return False

    cli_type = kwargs.pop('cli_type', st.get_ui_type(dut))
    #cli_type = "klish" if cli_type in ["rest-put", "rest-patch"] else cli_type
    if cli_type == 'click':
        cmd = "show vrf --verbose"
        if not st.is_feature_supported("show-vrf-verbose-command", dut):
            st.community_unsupported(cmd, dut)
            cmd = "show vrf"
        st.log("get {} output".format(cmd))
        output = st.show(dut, cmd)
        if len(output) == 0:
            st.error("OUTPUT is Empty")
            return []
        entries = filter_and_select(output, None, match_dict)
        return entries[0]
    elif cli_type == 'klish':
        cmd = "show ip vrf"
        output = st.show(dut, cmd, type=cli_type)
        entries = filter_and_select(output, None, match_dict)
        if len(output) == 0:
            st.error("OUTPUT is Empty")
            return []
        return entries[0]
    elif cli_type in ['rest-patch', 'rest-put']:
        rest_urls = st.get_datastore(dut, 'rest_urls')
        vname = kwargs['vrfname']
        vrf_info = {}
        interfaces = []
        rest_url = rest_urls['vrf_config'].format(vname)
        payload = get_rest(
            dut, rest_url=rest_url
        )['output']['openconfig-network-instance:network-instance']
        #klish output = {u'interfaces': ['PortChannel10', 'Vlan3'], u'vrfname': 'Vrf-103'}
        for item in payload:
            vrf_info['vrfname'] = item['state']['name']
            for interface in item['interfaces']['interface']:
                interfaces.append(interface['state']['id'])
        vrf_info['interfaces'] = interfaces
        return vrf_info