def bcmcmd_l3_entry_only_config(dut, **kwargs): if "action" not in kwargs: st.error("Mandatory params num, action are not provided") return False valid = 1 if kwargs["action"] == "delete": valid = 0 output = bcmcmd_get_l3_entry(dut) name_list = utils.dicts_list_values(output, "names") if "L3_ENTRY_ONLY" in name_list: num = int( utils.filter_and_select( output, [], {"names": "L3_ENTRY_ONLY"})[0]['entries']) - 1 command = "bcmcmd 'mod L3_ENTRY_ONLY 1 {} VALID={}'".format(num, valid) elif "L3_ENTRY_ONLY_SINGLE" in name_list: num = int( utils.filter_and_select( output, [], {"names": "L3_ENTRY_ONLY_SINGLE"})[0]['entries']) - 1 command = "bcmcmd 'mod L3_ENTRY_ONLY_SINGLE 1 {} BASE_VALID={}'".format( num, valid) elif "L3_ENTRY_SINGLE" in name_list: num = int( utils.filter_and_select( output, [], {"names": "L3_ENTRY_SINGLE"})[0]['entries']) - 1 command = "bcmcmd 'mod L3_ENTRY_SINGLE 1 {} BASE_VALID={}'".format( num, valid) else: st.error( "L3_ENTRY_ONLY | L3_ENTRY_ONLY_SINGLE | L3_ENTRY_SINGLE not found in - listmem l3_entry" ) return False st.config(dut, command) return True
def verify_arp_entry( dut, port,ipaddr): """ :param port: :type port: :param ipaddr: :type ipaddr: :param dut: :type dut: :return:bool """ result = False output = get_arp_entries(dut, ipaddr) entries = filter_and_select(output, None, {"address": ipaddr}) if not filter_and_select(entries, None, {"address": ipaddr, "vlan": port}): result = False else: result = True #entries = filter_and_select(output, ['Address'], {'Vlan': port}) #for addr in entries: # if addr['Address'] == ipaddr: # result = True # break return result
def get_mac_address_count(dut, vlan=None, port=None, type=None, mac_search=None, cli_type=""): """ To verify the MAC count after applying given filters vlan/port/type/mac_pattern :param dut: :param vlan: vlan id which needs to be filtered :param port: port which needs to be filtered like Ethernet4/PortChannel1 :param type: mac type to be filtered, Values can be Static/Dynamic :param mac_search: mac_pattern to be grepped from show mac output :return: """ cli_type = st.get_ui_type(dut, cli_type=cli_type) dec_flag = 0 if mac_search: entries = get_mac_entries_by_mac_address(dut, mac_search, cli_type=cli_type) else: entries = get_mac(dut, cli_type=cli_type) ###Decrement by 1 as output has "Total number of entries" as one list element in click output if cli_type == 'click': dec_flag = 1 if entries == list or entries is None: ### If entries is null, no need to apply filter, return 0 return 0 if vlan: entries = filter_and_select(entries, None, {"vlan": str(vlan)}) dec_flag = 0 if port: entries = filter_and_select(entries, None, {"port": port}) dec_flag = 0 if type: type = type if cli_type == 'click' else type.upper() entries = filter_and_select(entries, None, {"type": type}) dec_flag = 0 return len(entries)-1 if dec_flag==1 else len(entries)
def dut_links_status(dut): local_list = [] for local, partner, remote in st.get_dut_links(dut): local_list.append(local) for local, partner, remote in st.get_tg_links(dut): local_list.append(local) output = portapi.get_status(dut, ",".join(local_list)) results = dict() for local, partner, remote in st.get_dut_links(dut): match = {"interface": local} entries = utils.filter_and_select(output, ["admin", "oper"], match) name = "{}--{}".format(dut, local) if entries: results[name] = "{}/{}".format(entries[0]["admin"], entries[0]["oper"]) else: results[name] = "----" for local, partner, remote in st.get_tg_links(dut): match = {"interface": local} entries = utils.filter_and_select(output, ["admin", "oper"], match) name = "{}--{}".format(dut, local) if entries: results[name] = "{}/{}".format(entries[0]["admin"], entries[0]["oper"]) else: results[name] = "----" return results
def show_interfaces_counters(dut, interface=None, property=None, cli_type="click"): """ show interface counter Author : Prudvi Mangadu ([email protected]) :param dut: :param interface: :param property: :param cli_type: :return: """ if cli_type == "click": command = 'show interfaces counters' output = st.show(dut, command) if interface: if property: output = filter_and_select(output, [property], {'iface': interface}) else: output = filter_and_select(output, None, {'iface': interface}) return output elif cli_type == "klish": command = "show interface counters" interface = make_list(interface) if interface: command += " | grep \"{}\"".format("|".join(interface)) return st.show(dut, command, type=cli_type) else: st.log("Unsupported CLI TYPE {}".format(cli_type)) return False
def verify_vlan_brief(dut, vid, tagged=None, untagged=None, ip_address=None, dhcp_helper_add=None, cli_type=''): cli_type = st.get_ui_type(dut, cli_type=cli_type) """ Verify vlan config using 'show vlan brief' Author : Prudvi Mangadu ([email protected]) :param dut: :param vid: :param tagged: :param untagged: :param ip_address: :param dhcp_helper_add: :return: """ vid = str(vid) output = show_vlan_brief(dut, cli_type=cli_type) entries = filter_and_select(output, None, {"vid": vid}) if not entries: st.log("Provided VLAN {} entry is not exist in table".format(vid)) return False if tagged and not filter_and_select(entries, None, { "ports": tagged, "porttagging": "tagged" }): st.log( "Provided interface {} is not a tagged member of Valn {}".format( tagged, vid)) return False if untagged and not filter_and_select(entries, None, { "ports": untagged, "porttagging": "untagged" }): st.log( "Provided interface {} is not a untagged member of Valn {}".format( untagged, vid)) return False if dhcp_helper_add and not filter_and_select( entries, None, { "vid": vid, "dhcphelperadd": dhcp_helper_add }): st.log("Provided and configured vlan {} DHCPHelperAdd {} in not match". format(vid, dhcp_helper_add)) return False if ip_address and not filter_and_select(entries, None, { "vid": vid, "ipadd": ip_address }): st.log("Provided and configured vlan {} IpAdd {} in not match".format( vid, ip_address)) return False return True
def show_ndp(dut, inet6_address=None, **kwargs): """ to get ndp table info Author: Chaitanya Vella ([email protected]) :param dut: :param inet6_address: :return: """ cli_type = st.get_ui_type(dut, **kwargs) if cli_type == "click": if 'vrf' not in kwargs: command = "show ndp" if inet6_address: command += " {}".format(inet6_address) elif "interface" in kwargs and kwargs["interface"]: command += " -if {}".format(kwargs["interface"]) elif 'vrf' in kwargs: vrf = kwargs['vrf'] command = "show ndp -vrf {}".format(vrf) if inet6_address: command += " {}".format(inet6_address) elif "interface" in kwargs and kwargs["interface"]: command += " -if {}".format(kwargs["interface"]) elif cli_type == "klish": if 'vrf' not in kwargs: command = "show ipv6 neighbors" if inet6_address: command += " {}".format(inet6_address) elif kwargs.get("interface"): intf = get_interface_number_from_name(kwargs.get("interface")) command += " interface {} {}".format(intf["type"], intf["number"]) elif 'vrf' in kwargs: vrf = kwargs['vrf'] command = "show ipv6 neighbors vrf {}".format(vrf) if inet6_address: command += " {}".format(inet6_address) elif cli_type in ["rest-patch", "rest-put"]: output = list() if kwargs.get('vrf'): interfaces = _get_rest_l3_interfaces(dut, vrf=kwargs['vrf']) else: interfaces = _get_rest_l3_interfaces(dut) for interface in interfaces: output.extend( _get_rest_neighbor_entries(dut, interface, is_arp=False)) st.debug(output) if inet6_address: return filter_and_select(output, None, {'address': inet6_address}) elif kwargs.get('interface'): return filter_and_select(output, None, {'interface': kwargs['interface']}) else: return output else: st.error("Unsupported CLI Type: {}".format(cli_type)) return False return st.show(dut, command, type=cli_type)
def show_arp(dut, ipaddress=None, interface=None, vrf="", cli_type=""): """ To get arp table info Author: Prudvi Mangadu ([email protected]) :param dut: :param ipaddress: :param interface: :return: """ cli_type = st.get_ui_type(dut, cli_type=cli_type) if cli_type == "click": if vrf == "": command = "show arp" if ipaddress: command += " {}".format(ipaddress) elif interface: command += " -if {}".format(interface) elif vrf != "": command = "show arp -vrf {}".format(vrf) if ipaddress: command = "show arp {}".format(ipaddress) elif interface: command = "show arp -if {}".format(interface) elif cli_type == "klish": if vrf == "": command = "show ip arp" if ipaddress: command += " {}".format(ipaddress) elif interface: intf = get_interface_number_from_name(interface) command += " interface {} {}".format(intf["type"], intf["number"]) elif vrf != "": command = "show ip arp vrf {}".format(vrf) if ipaddress: command += " {}".format(ipaddress) elif cli_type in ['rest-patch', 'rest-put']: output = list() if vrf: interfaces = _get_rest_l3_interfaces(dut, vrf=vrf) else: interfaces = _get_rest_l3_interfaces(dut) for intf in interfaces: output.extend(_get_rest_neighbor_entries(dut, intf)) st.debug(output) if ipaddress: return filter_and_select(output, None, {'address': ipaddress}) elif interface: return filter_and_select(output, None, {'iface': interface}) else: return output else: st.error("Unsupported CLI_TYPE: {}".format(cli_type)) return False return st.show(dut, command, type=cli_type)
def verify_vlan_config(dut, vlan_list, tagged=None, untagged=None, name=None): """ Verify vlan config using 'show vlan config' Author : Prudvi Mangadu ([email protected]) :param dut: :param vlan_list: :param tagged: :param untagged: :param name: :return: """ vlan_li = map(str, vlan_list) if isinstance(vlan_list, list) else [vlan_list] output = show_vlan_config(dut) for each_vlan in vlan_li: entries = filter_and_select(output, None, {"vid": each_vlan}) if not entries: st.log("Provided VLAN {} entry is not exist in table".format( each_vlan)) return False if tagged: interface_list = list(tagged) if isinstance(tagged, list) else [tagged] for each_intr in interface_list: if not filter_and_select(entries, None, { "member": each_intr, "mode": "tagged" }): st.log( "Provided interface {} is not a tagged member of Vlan {}" .format(each_intr, each_vlan)) return False if untagged: interface_list = list(untagged) if isinstance( untagged, list) else [untagged] for each_intr in interface_list: if not filter_and_select(entries, None, { "member": each_intr, "mode": "untagged" }): st.log( "Provided interface {} is not a untagged member of Vlan {}" .format(each_intr, each_vlan)) return False if name and not filter_and_select(entries, None, {"name": name}): st.log("Provided and configured VLAN {} name in not match".format( each_vlan)) return False return True
def verify_counter_cpu_asic_bcm(dut, queue, value, tol): queue_mc = queue nooftimes = 3 queue = 'PERQ_PKT(' + queue + ').cpu0' queue_mc = 'MC_PERQ_PKT(' + queue_mc + ').cpu0' for itercountvar in range(nooftimes): if itercountvar != 0: st.wait(5) cli_out = asicapi.get_counters(dut) fil_out = filter_and_select(cli_out, ["time"], {"key": queue}) if not fil_out: fil_out = filter_and_select(cli_out, ["time"], {"key": queue_mc}) if not fil_out: st.error('queue: {} not found in output: {}'.format( queue, cli_out)) if itercountvar < (nooftimes - 1): continue return False else: if not fil_out[0]['time']: st.error('queue: {} value is null in the output: {}'.format( queue, fil_out)) if itercountvar < (nooftimes - 1): asicapi.clear_counters(dut) continue return False fil_out = fil_out[0] if not fil_out['time']: st.error('queue: {} value is null in the output: {}'.format( queue, cli_out)) if itercountvar < (nooftimes - 1): continue return False fil_out['time'] = re.sub(r'|'.join((',', '/s')), "", fil_out['time']) ob_value = int(fil_out['time']) start_value = int(value) - int(tol) end_value = int(value) + int(tol) if ob_value >= start_value and ob_value <= end_value: st.log('obtained value {} for queue: {} is in the range b/w ' '{} and {}'.format(ob_value, queue, start_value, end_value)) return True else: st.error('obtained value {} for queue: {} is NOT in the range b/w ' '{} and {}'.format(ob_value, queue, start_value, end_value)) if itercountvar < (nooftimes - 1): asicapi.clear_counters(dut) continue return False
def bcmcmd_l3_ip6route_show(dut, match={}, items=[]): """ :param dut: :param match: :param items: :return: vrf, route, nhpmac, intf """ command = "bcmcmd 'l3 ip6route show'" output = st.show(dut, command) st.debug(output) if match and items: return utils.filter_and_select(output, items, match) if match and not items: return utils.filter_and_select(output, None, match) return output
def verify_hardware_map_status(dut, queues, itter_count=30, delay=1): """ To verify the Queue init in hardware :param dut: :param queues: :param itter_count: :param delay: :return: """ command = redis.build(dut, redis.COUNTERS_DB, "keys *MAP*") queues_li = utils.make_list(queues) i = 1 while True: output = st.show(dut, command) output_list = utils.filter_and_select(output, ["name"], None) output_list = utils.dicts_list_values(output_list, "name") result = True for each_q in queues_li: if each_q not in output_list: st.log("{} not yet init.".format(each_q)) result = False if result: return True if i > itter_count: st.log("Max {} tries Exceeded.Exiting..".format(i)) return False i += 1 st.wait(delay)
def verify_ndp(dut, inet6_address, **kwargs): """ To Verify ndt table info Author: Chaitanya Vella ([email protected]) :param dut: :param inet6_address :param mac_address: :param interface: :param vlan: :param status: :return: """ if "interface" in kwargs and kwargs["interface"]: response = show_ndp(dut, inet6_address, interface=kwargs["interface"]) else: response = show_ndp(dut, inet6_address) st.log("Response {}".format(response)) if not response: return False st.log("Kwargs {}".format(kwargs)) entries = filter_and_select(response, None, kwargs) st.log("Entries {}".format(entries)) if not entries: return False return True
def get_port_tx_rate_in_bps(dut, port, **kwargs): """ This API is used to return the TX_BPS of a port :param dut: :type dut: :param port: :type port: """ cli_type = st.get_ui_type(dut, **kwargs) CMD = 'show interfaces counters | grep "{}"' cli_type = 'klish' if cli_type in ['rest-put', 'rest-patch'] else cli_type output = st.show(dut, CMD.format(port), cli_type=cli_type ) if cli_type == 'click' else get_interface_counters_all( dut, port, cli_type=cli_type) entry = filter_and_select(output, ['tx_bps'], {'iface': port}) rv = re.search(r"\d+\.\d+", entry[0]['tx_bps']) if entry and 'tx_bps' in entry[0] else 0 if cli_type == 'click': if rv: if 'GB/s' in entry[0]['tx_bps']: multiplier = 1000 * 1000 * 1000 elif 'MB/s' in entry[0]['tx_bps']: multiplier = 1000 * 1000 elif 'KB/s' in entry[0]['tx_bps']: multiplier = 1000 else: multiplier = 1 return round(float(rv.group()) * multiplier) if rv else 0 elif cli_type == 'klish': return round(float(rv.group()) * 1000 * 1000) if rv else 0 else: st.error("Unsupported CLI Type: {}".format(cli_type)) return False
def verify(dut, **kwargs): cli_type = st.get_ui_type(dut, **kwargs) """ Author : Kiran Vedula ([email protected]) :param :dut: :param :vrf_name: :param :interfaces: verify(vars.D1, vrf_name='management', interfaces=['eth0']) """ interface_li = utils.make_list(kwargs.get('interfaces')) output = show(dut, cli_type=cli_type) if cli_type == 'klish': if not output: st.error("Unable to get command output") return False else: if output[0]['interface'] != 'eth0': st.log("Mgmt VRF not bound to eth0") return False elif cli_type == 'click': if not output: st.error("Unable to get command output") return False if output['mvrfstate'] != kwargs.get('mvrfstate'): st.log("Management VRF state mismatch") return False if output['mvrfstate'] == "Enabled": match = list() for each in interface_li: match.append({'mvrf_interface': each}) intf_list = utils.filter_and_select(output["interfaces"], None, match) if kwargs.get('dataport'): if intf_list: st.log( "No match available for - {} in output".format(match)) return False else: if not intf_list: st.log( "No match available for - {} in output".format(match)) return False elif cli_type in ["rest-patch", "rest-put"]: if not output: st.log("Unable to get Rest operation Get output") return False if not rest_status(output["status"]): st.log("rest_call_failed", "GET") return False if output["output"]["openconfig-network-instance:state"][ "name"] != "mgmt": st.log("Mgmt VRF not bound to eth0") return False if not output["output"]["openconfig-network-instance:state"]["enabled"]: st.log("Management VRF state mismatch") return False else: st.error("Unsupported cli_type: {}".format(cli_type)) return False return True
def verify_mac_dampening_disabled_ports(dut, **kwargs): """ Author : :param dut: :param port_list: : :return: usage verify_mac_dampening_disabled_ports(data.dut1, port_list = ['Ethernet127','Ethernet126']) """ parsed_output = [] cli_type = kwargs.get("cli_type", st.get_ui_type(dut)) if cli_type in ['rest-patch', 'rest-put']: cli_type = 'klish' if cli_type == 'click': cmd = "show mac dampening_disabled_ports" else: cmd = "show mac dampening-disabled-ports" parsed_output = st.show(dut,cmd,type=cli_type) if len(parsed_output) == 0: ### Klish output empty when disabled ports are not there parsed_output = [{'port_list':['None']}] st.log("DEBUG==>{}".format(parsed_output)) if 'return_output' in kwargs: return parsed_output match = {"port_list": kwargs['port_list']} entries = filter_and_select(parsed_output, ["port_list"], match) return True if entries else False
def verify(dut, **kwargs): """ Call to verify - show ip igmp snooping Author : Prudvi Mangadu ([email protected]) :param :dut: :param :cli_type: default - klish :param :vlan :param :mrouter_interface :param :querier :param :igmp_operation_mode :param :fast_leave :param :query_max_response_time :param :last_member_query_interval :param :query_interval :return: """ result = True output = show(dut, **kwargs) match = { e: kwargs[e] for e in kwargs if e not in ['cli_type', 'mrouter_interface'] } entries = utils.filter_and_select(output, None, match) if not entries: st.log("match {} is not in output {}".format(match, entries)) result = False if "mrouter_interface" in kwargs: interface_li = utils.make_list(kwargs['mrouter_interface']) for each in interface_li: if each not in entries[0]['mrouter_interface'].split(', '): st.log( "Mrouter interface {} is not found under mentioned vlan". format(each)) result = False return result
def verify(dut, *argv, **kwargs): """ Generic verify API. Author : Prudvi Mangadu ([email protected]) :param dut: :param argv: :param kwargs: :Usage: verify(vars.D1, 'logged_users', verify_list=[{'user':'******'}, {'user':'******'user_list', verify_list=['admin', 'test1']) verify(vars.D1, 'group_list', verify_list=['admin','operator']) verify(vars.D1, user_group='admin', verify_list=[{'group':'admin'}]) """ result = True if not kwargs.get('verify_list'): st.error("Mandatory parameter -verify_list is missing") return False out = show(dut, *argv, **kwargs) if 'logged_users' in argv or kwargs.get('user_group'): for each in make_list(kwargs.get('verify_list')): if not filter_and_select(out, None, each): st.log("{} - {} is not match".format(each, out)) result = False if 'user_list' in argv or 'group_list' in argv: for each in make_list(kwargs.get('verify_list')): if each not in out: st.log("{} - is not found in {}".format(each, out)) result = False return result
def get_vlan_member(dut, vlan_list=[], cli_type=''): cli_type = st.get_ui_type(dut, cli_type=cli_type) """ To Get VLANs vs list of Members. Author : Prudvi Mangadu ([email protected]) :param dut: :param vlan_list: :param cli_type: :return: """ vlan_val = {} vlan_li = map(str, vlan_list) if isinstance(vlan_list, list) else [vlan_list] out = show_vlan_config(dut, cli_type=cli_type) if vlan_li: temp = [] for each in list(set(vlan_li)): temp += filter_and_select(out, None, {"vid": each}) out = temp for each in out: if each['member']: if each['vid'] not in vlan_val: vlan_val[each['vid']] = [each['member']] else: vlan_val[each['vid']].append(each['member']) return vlan_val
def verify_bcmcmd_routing_output(dut, command, **kwargs): """ :param dut: :param command: :type :show command: "l3 defip show", "l3 ip6route show", "l3 l3table show", "l3 ip6host show" :param :kwargs: :type :based on arguments passed: :return: """ if command == "l3_defip_show": output = bcmcmd_l3_defip_show(dut) elif command == "l3_ip6route_show": output = bcmcmd_l3_ip6route_show(dut) elif command == "l3_l3table_show": output = bcmcmd_l3_l3table_show(dut) elif command == "l3_ip6host_show": output = bcmcmd_l3_ip6host_show(dut) else: st.error("Invalid command = {}".format(command)) return False for each in kwargs.keys(): if not utils.filter_and_select(output, None, {each: kwargs[each]}): st.error("No match for {} = {} in table".format( each, kwargs[each])) return False return True
def verify_ntp_synch(dut, server): entries = show_ntp_server(dut) if filter_and_select(entries, None, {'remote': "*{}".format(server)}): st.debug("NTP synchronized with server: {}".format(server)) return True st.error("NTP not synchronized with server: {}".format(server)) return False
def get_ssh_server_vrf(dut, vrf_name=None, cli_type=''): """ To Get SSH server VRF Author : Prudvi Mangadu ([email protected]) :param dut: :param vrf_name: :param cli_type: :return: Usage: get_ssh_server_vrf(vars.D1) get_ssh_server_vrf(vars.D1, vrf_name='VRF_1') """ 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 command = "show ssh-server vrfs" output = st.show(dut, command, type=cli_type) if not vrf_name in output: return output else: out = filter_and_select(output, None, {'vrf_name': vrf_name}) if not out: return False else: return out[0]['status']
def verify_mac_dampening_threshold(dut, **kwargs): """ Author : :param dut: :param port: : :return: usage verify_mac_dampening_threshold(dut1,count=2) """ #cli_type = kwargs.get("cli_type", st.get_ui_type(dut)) #if cli_type in ['rest-patch', 'rest-put']: cli_type = 'klish' ## Changes in klish command as part of bug fix, fallback to click till fixing templates. cli_type = 'click' if cli_type == 'click': cmd = "show mac dampening_threshold" else: cmd = "show mac dampening" parsed_output = st.show(dut,cmd,type=cli_type) if len(parsed_output) == 0: st.error("OUTPUT is Empty") return False match = {"count": kwargs['count']} entries = filter_and_select(parsed_output, ["count"], match) return True if entries else False
def get_member_vlan(dut, interface_list=[], cli_type=''): cli_type = st.get_ui_type(dut, cli_type=cli_type) """ To Get Members vs list of VLANs. Author : Prudvi Mangadu ([email protected]) :param dut: :param interface_list: :param cli_type: :return: """ member_val = {} interface_li = list(interface_list) if isinstance( interface_list, list) else [interface_list] out = show_vlan_config(dut, cli_type=cli_type) if interface_li: temp = [] for each in list(set(interface_li)): temp += filter_and_select(out, None, {"member": each}) out = temp for each in out: if each['member']: if each['member'] not in member_val: member_val[each['member']] = [each['vid']] else: member_val[each['member']].append(each['vid']) return member_val
def verify_config(dut, interface_name=None, type=None, rate=None, cli_type=""): """ API to verify storm control configuration Author : Chaitanya Vella ([email protected]) :param dut: :param interface_name: :param type: :param bits_per_sec: :return: """ cli_type = st.get_ui_type(dut, cli_type=cli_type) output = show(dut, interface_name, type, cli_type=cli_type) if not output: st.log("Storm control data not found") return False match = dict() if interface_name: match["interface"] = interface_name if type: match["type"] = type if rate: match["rate"] = rate entries = utils_obj.filter_and_select(output, None, match) if match: st.log("MATCH : {}".format(match)) st.log("Entries: {}".format(entries)) if not entries: st.log("Entries not found ...") return False return True else: st.log("Type and rate not provided") return False
def get_interface_breakout_mode(dut, interface, *fields): """ Author: Naveen Nag email : [email protected] :param dut: :param interface: :param fields: :return: port,interface,supported_modes,default mode Usage: port.get_interface_breakout_mode(dut1, 'Ethernet4', 'port','supported_modes') :return - [{'supported_modes': '1x100G[40G], 4x25G[10G]', 'port': '1/2'}] """ if '/' not in interface: temp_vars = st.get_testbed_vars() if temp_vars.config.ifname_type == 'alias': interface = st.get_other_names(dut,[interface])[0] if '/' in interface: interface = '/'.join([interface.split('/')[0], interface.split('/')[1]]) output = st.show(dut, "show interface breakout modes | grep \"{} \"".format(interface), type='klish') entries = filter_and_select(output, fields, {'iface': interface}) if entries: return entries else: st.error("{} is not part of the output".format(interface)) return False
def test_ft_ipv6_neighbor_entry(): ################# Author Details ################ # Name: Raja Sekhar Uppara # Email: [email protected] ################################################# # Objective - 1.Verify that IPv6 neighbor entries are created successfully. # 2.Verify that Ipv6 Static neighbor entries are created successfully. # 3.'sudo sonic-clear ndp' flushes the existing dymanic entries ############### Test bed details ################ # TG1-----DUT-----TG2 ################################################# vars = st.get_testbed_vars() arp_obj.show_ndp(vars.D1) ndp_dut_count_initial = arp_obj.get_ndp_count(vars.D1) if ndp_dut_count_initial < 2 * data.count: st.report_fail("ndp_dynamic_entry_fail") arp_obj.clear_ndp_table(vars.D1) ndp_dut_count_post_clear = int(arp_obj.get_ndp_count(vars.D1)) if ndp_dut_count_post_clear > 2: out = arp_obj.show_ndp(vars.D1) entries = filter_and_select(out, [None], {'status': 'NOARP'}) if not len(out) == len(entries): st.report_fail("ndp_entries_clearing_failed") arp_obj.config_static_ndp(vars.D1, data.neigh_ip6_addr_gw[2], data.tg_mac3, vars.D1T1P1) ndp_dut_count_static = int(arp_obj.get_ndp_count(vars.D1)) if not ndp_dut_count_static: st.report_fail("static_ndp_create_fail") arp_obj.config_static_ndp(vars.D1, data.neigh_ip6_addr_gw[2], data.tg_mac3, vars.D1T1P1, 'del') st.report_pass("test_case_passed")
def verify_interface_status(dut, interface, property, value, cli_type="click"): """ Author: Chaitanya Vella ([email protected]) This API to verify the interface status :param dut: dut obj :param interface: Interface Name :param property: Interface property :param value: Property Value :param cli_type: :return: Boolean """ interface_list = make_list(interface) is_found = 1 for port in interface_list: interface_details = interface_status_show(dut, port, cli_type=cli_type) match = {"interface": port, property: value} entries = filter_and_select(interface_details, ["interface"], match) if not bool(entries): is_found = 0 break else: is_found = 1 if not is_found: return False return True
def bcm_cmd_l3_intf_show(dut, **kwargs): command = "bcmcmd 'l3 intf show'" output = st.show(dut, command) st.debug(output) for each in kwargs.keys(): if utils.filter_and_select(output, None, {each: kwargs[each]}): st.error("No match for {} = {} in table".format( each, kwargs[each])) return False return True
def verify_queue_drop(queue_list, port): global pkts_sec, sp_ratio_1 success = True cli_out = intf.show_queue_counters(vars.D1, port) fil_out1 = filter_and_select(cli_out, ['pkts_drop'], {"txq": queue_list[0]}) fil_out2 = filter_and_select(cli_out, ['pkts_drop'], {"txq": queue_list[1]}) if not fil_out1: st.error('queue name: {} not found in output: {}'.format( queue_list[0], cli_out)) return False else: fil_out1 = fil_out1[0] if not fil_out2: st.error('queue name: {} not found in output: {}'.format( queue_list[1], cli_out)) return False else: fil_out2 = fil_out2[0] try: fil_out1['pkts_drop'] = re.sub(",", "", fil_out1['pkts_drop']) fil_out2['pkts_drop'] = re.sub(",", "", fil_out2['pkts_drop']) q1_drop, q2_drop = int(fil_out1['pkts_drop']), int( fil_out2['pkts_drop']) except ValueError: st.error('cannot get integer value from obtained ' 'string: {} or {}'.format(fil_out1['pkts_drop'], fil_out2['pkts_drop'])) return False if q1_drop > q2_drop and q1_drop > (pkts_sec * sp_ratio_1): st.log('queue {} drop {} is more than queue {} drop {} as expected'. format(queue_list[0], q1_drop, queue_list[1], q2_drop)) else: st.error('queue {} drop {} is not more than queue {} drop {}'.format( queue_list[0], q1_drop, queue_list[1], q2_drop)) success = False return success