<<

Netshow CLI / Netshow Library - Linux Provider Release 1.1.7+git.18.c727438

Jun 20, 2017

Contents

1 Netshow Linux Provider 1 1.1 Linux Provider API...... 1 1.1.1 Linux Provider API - Netshow Library...... 1 1.1.2 Linux Provider API - Netshow App...... 13 1.2 License...... 19 1.3 Credits...... 19

Python Module Index 21

i ii CHAPTER 1

Netshow Linux Provider

The Netshow Linux Provider is a plugin for the Netshow, a linux troubleshooting toolkit This site contains the API for this provider. For more details on how Netshow works, see the Netshow App Intro and Netshow Library Intro

Linux Provider API

Linux Provider API - Netshow Library netshowlib.linux.bond module

This module is responsible for finding properties related to bond interface and bond member interfaces class netshowlib.linux.bond.Bond(name, cache=None) Bases: netshowlib.linux.iface.Iface Linux Bond attributes •members: list of bond members/slaves. creates instances of BondMember •bond mode: options are –balance-rr ‘0’ –active-backup ‘1’ –balance-xor ‘2’ –balance-alb ‘3’ –802.3ad ‘4’ –balance-tlb ‘5’ –balance-alb ‘6’ •min_links: number of minimum links

1 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

•hash_policy: load balancing algorithm. options are –layer2 ‘0’ –layer3+4 ‘1’ •lacp: pointer to Lacp instance for this bond •system_mac: Bond system mac. Packets egressing bond use this mac address. bridge_masters Returns list of bridges associated with this port and its subinterfaces. hash_policy Returns bond load balancing policy / xmit hash policy lacp Returns linux.lacp class instance if bond is in LACP mode members Returns list of bond members min_links Returns number of minimum links required to keep the bond active mode Returns bond mode integer. Not the name. See linux kernel driver docs for more details stp Returns KernelStpBridgeMember instance system_mac Returns bond system mac class netshowlib.linux.bond.BondMember(name, cache=None, master=None) Bases: netshowlib.linux.iface.Iface Linux Bond Member Attributes •master: pointer to Bond instance that this interface belongs to. This can be provided in the __init__ function •linkfailures: bond driver reports number of times bond member flaps •bondstate: returns whether bond member is active (1) or inactive(0) in a bond irrespective of its car- rier/linkstate status. What this means is that the link can be up, but not in the bond. Examples:

import netshowlib.netshowlib as nn

# bond member info should be normally obtained from # first calling the bond and then running the members # property. bond0= nn.bond.Bond('bond0') print len(bond0.members.keys()) >>2

# on the case you know the bond member but want to get # bond master information you can.

2 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

bondmem= nn.bond_member.BondMember('eth1') print bondmem.master >> Linux Bond Interface'bond0'. Member Count:1

bondstate Returns state of interface in the bond. can be 0(inactive) or 1(active) linkfailures number of mii transitions bond member reports while the bond is active this counter cannot be cleared. will reset when the bond is reinitialized via the ifdown/ifup process Returns number of mii transitions master Returns pointer to Bond instance that this interface belongs to netshowlib.linux.bridge module

This module is responsible for finding properties related to linux bridge and bridge member interfaces class netshowlib.linux.bridge.Bridge(name, cache=None) Bases: netshowlib.linux.iface.Iface Linux Bridge interface attributes •tagged_members: list of tagged bridge members (part of a trunk) •untagged_members: list of untagged bridge members (access) •members: all bridge members •vlan_tag: vlan ID tag if applicable. empty string means no tag. •stp: pointer to KernelStpBridge instance. If set to None, then bridge has STP disabled. members Returns list of bridge port members stp Returns None if STP is disabled Returns KernelStpBridge instance if STP is enabled tagged_members Works for default/classic linux bridge driver Returns list of tagged bridge members. untagged_members Works for default/classic linux bridge driver Returns list of untagged bridge members vlan_tag For the classic/default bridge driver, if a tagged bridge member is provided then the function will use the tag as the vlan id Returns vlan ID if applicable. If multiple tags found,

1.1. Linux Provider API 3 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

possibly indicating vlan translation, then all tags are printed as a list Empty array means no tag class netshowlib.linux.bridge.BridgeMember(name, cache=None) Bases: netshowlib.linux.iface.Iface Linux Bridge Member attributes •cache: feature cache •stp: pointer to KernelStpBridgeMember instance bridge_masters Returns list of bridges associated with this port and its subinterfaces. stp Returns instance of KernelStpBridgeMember class netshowlib.linux.bridge.KernelStpBridge(bridge) Bases: object Attributes for STP for a bridge •bridge: instance of Bridge •member_state: return hash of basic stp attributes of bridge members. Example

iface= linux.bridge.Bridge('eth2') iface.stp.state >>{'stp_disabled':[list of bridge member instances] 'forwarding':[list of bridge member instances ] 'blocking':[list of bridge member instances ] 'intransition':[ list of bridge member instances ] 'disabled':[list of bridge member instances] 'root':[list of bridge member instances. should only be one] }

•root_priority: root priority for the spanning tree domain •bridge_priority: bridge priority

bridge_priority Returns return bridge priority number is_root() Returns True if bridge is STP root. member_state Returns dict of stp state of bridge members root_priority Returns return root priority number class netshowlib.linux.bridge.KernelStpBridgeMember(bridgemem, cache=None) Bases: object Attributes for Bridgemems using the Kernel STP •bridgemem: instance of BridgeMember •state: return hash of basic stp attributes of the port. Example

4 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

iface= linux.bridge.BridgeMember('eth2') iface.stp.state >>{'forwarding':[list of bridge instances ] 'blocking':[list of bridge instances ] 'intransition':[ list of bridge instances ] 'disabled':[list of bridge instances] 'root':[list of bridges instances with root ports ] 'stp_disabled':[ list of bridge instances where stp is disabled] }

•cache: feature cache that is used

state Returns dict of stp states with associated linux.bridge instances netshowlib.linux.bridge.update_stp_state(stp_hash, iface_to_add, iface_under_test) Updates stp state dict from BridgeMember and Bridge

netshowlib.linux.cache module

This module produces the cache info for Linux class netshowlib.linux.cache.Cache Bases: object This class produces the cache info for Linux networking such as ip addressing, lldp, QOS run(features=None) Parameters features – List of features to enable. If set to None cache from all features is obtained Returns returns Cache instance of appropriate OS type netshowlib.linux.common module

Linux common module exception netshowlib.linux.common.ExecCommandException Bases: exceptions.Exception Exception when a exec command fails netshowlib.linux.common.check_bit(int_type, offset) copied from wiki.python.org if testBit is not zero, return checkBit as True netshowlib.linux.common.clear_bit(int_type, offset) Returns integer with the bit at ‘offset’ cleared netshowlib.linux.common.create_range(rkey, rgroup) Parameters rkey – if rey is swp, rgroup is “swp2, swp3, swp10” create a range list given a list of ports with a common pattern netshowlib.linux.common.create_sort_tuple(result) returns tuple value used for sorting. Example (‘bond’, ‘0’, ‘.’ , ‘1’) converts it to (‘bond’, 0, 0, 1) for the sort another example (‘vlan’, ‘10’, ‘-v’, ‘0’) converts to (‘vlan’, 10, 0, 0) for the sort.

1.1. Linux Provider API 5 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

netshowlib.linux.common.dict_merge(list1, list2) merge two dicts by overriding content in first dict with content from 2nd dict. does not return a new merge dict. all merging takes place in the first dict. Parameters • list1 – original dict • list2 – dict to override original dict content netshowlib.linux.common.exec_command(cmd, cmdenv=None) execute a command netshowlib.linux.common.exec_commandl(cmdl, cmdenv=None) execute a command netshowlib.linux.common.generate_cidr_ip(addr) generate address in CIDR format Example: 10.1.1.1/24 instead of 10.1.1.1 mask 255.255.255.0 netshowlib.linux.common.group_iface(initial_list, group_func) groups iface values netshowlib.linux.common.group_ports(list_of_ports) create group list of ports given a list of ports. Example: ‘swp1, swp2, bond0, bond1, swp3.100, swp4.100’ becomes ‘swp1-2, swp3-4.100, bond0-1’ netshowlib.linux.common.grouping_func(xvar) group ports based on 2 criteria. If name is like so ‘bond0’, ‘swp22’, ‘br-vlan22’, ‘vlan33’, group it by name. So for example ‘bond0’, ‘bond1’, would be under the ‘bond’ group. 2nd criteria is by vlan number. If the ports are ‘swp1.100, swp2.100’ group it by ‘100’. So Dict entry would be ‘100’ -> ‘swp1.100’, ‘swp2.100’ netshowlib.linux.common.has_stats(ifacename) netshowlib.linux.common.munge_str(match0) sorting by string that is int, produces wrong sort..so change str that is int into a int type netshowlib.linux.common.netmask_dot_notation_to_cidr(netmask) Example: takes ‘255.255.225.0’ and returns ‘24’ :param netmask: netmask in decimal form :return: netmask in CIDR format netshowlib.linux.common.portname_list() Returns list of interface names from /sys/class/net netshowlib.linux.common.read_file(filename) read a file and return an array of lines netshowlib.linux.common.read_file_oneline(filename) reads one line files. returns content netshowlib.linux.common.read_from_sys(attr, iface_name, oneline=True) reads an attribute found in thev /sys/class/net/[iface_name]/ directory netshowlib.linux.common.read_symlink(filepath) read symlink. Parameters filepath – path to the directory, file to check netshowlib.linux.common.set_bit(int_type, offset) Returns an integer with the bit at ‘offset’ set to 1 netshowlib.linux.common.sort_ports(list_of_ports) Given a port list [’swp1’, ‘bond10.100’, ‘swp3.100’] sort it to it looks like this [’bond10.100’, ‘swp1’, ‘swp3.100’]

6 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438 netshowlib.linux.common.sys_path(attr, iface_name) Params attr attribute under /sys/class/net/name() Returns full path of the sysfs attribute netshowlib.linux.common.test_bit(int_type, offset) •from wiki.python.org *

Returns nonzero result, 2**offset, if the bit is ‘offset’ is one netshowlib.linux.iface module

Linux.iface module This module contains the linux.iface.Iface class that is responsible for collecting various informa- tion about a linux interface. class netshowlib.linux.iface.Iface(name, cache=None) Bases: object Linux Iface attributes •mac: mac address •mtu: port MTU •description: port description same as alias •speed: speed in KB •linkstate: It can be either 0(adminDown), 1(Down) or 2(Up). Difference between adminDown and Down is that the in adminDown state the carrier does not exist. To get into adminDown state is the state achieved when ip link set down is executed on an interface •ip_address: This provides a list of IPv4 and IPv6 addresses associated with the interface •ip_addr_assign: If the address is configured via DHCP this property is set to 1 •ip_address: pointer to linux.ip_address class instance •ip_neighbor: pointer to _address:class:linux.ip_neighbor class instance check_port_dhcp_assignment(leasesfile) sets self._ip_addr_assign to 1 if port is a DHCP enabled interface counters get basic counter info description Returns interface description / alias exists() Returns return true if port exists in /sys/class/net get_bridgemem_port_type() Returns 0 if port is not a bridge member Returns 1 if port is access port Returns 2 if port is a trunk port get_sub_interfaces()

1.1. Linux Provider API 7 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

Returns list of sub interfaces of port has_stats() Returns return true if iface has stats directory in /sys/class/net ip_addr_assign Returns 1 if port is DHCP enabled else returns 0 ip_address gets IP address from cache or system, depending on whether a cache is provided Returns Ipaddr instance specific to this interface ip_neighbor get list of IP neighbor entries from cache or from system associated with this interface Returns :class:‘linux.ip_neighbor instance ‘ is_access() Returns true if port is access port. That is a port in a bridge that is not a trunk is_bond() Returns true if port is a bond is_bond_initial_test()

sets port bitmap entry BOND_INT option if port is a bond port is_bondmem() Returns true if port is a bondmem is_bondmem_initial_test()

sets port bitmap entry BONDMEM_INT option if port is a bond member port is_bridge() Returns true if port is a bridge is_bridge_initial_test()

sets port bitmap entry BRIDGE_INT option if port is a bridge port is_bridgemem() Returns true if port is a bridge member is_bridgemem_initial_test()

sets port bitmap entry BRIDGEMEM_INT option if port is a bridge member port is_l2() Returns true if port is l2. That is part of a bridge domain is_l3() Returns True if iface has IP address

8 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

is_loopback() Returns true if port is a sub-interface is_loopback_initial_test() Returns sets port bitmap entry LOOPBACK_INT is_subint() Returns true if port is a sub-interface is_subint_initial_test() Returns sets port bitmap entry SUB_INT if port is a subinterface is_trunk() Returns true if port is a trunk. A trunk carries multiple LANs linkstate

“adminDown” means carrier does not exist. “Down” means carrier exist but L2 protocols are down. “Dormant” means that the port is UP but dormant.

Returns 0(adminDown), 1(Down), 2(Up), 3(Dormant) Return type int

lldp gets LLDP information from cache or system, depending if cache is provided. Example

here is my example TODO Returns array of hash entries that contain lldp information mac Returns port mac address mtu Returns port MTU name Returns interface name native_vlan Get the name of the native vlan of the trunk port read_from_sys(attr, oneline=True) reads an attribute found in the /sys/class/net/[iface_name]/ directory read_symlink(attr) :return symlink under a /sys/class/net iface config. speed Returns port speed in MB

1.1. Linux Provider API 9 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

stp_state() :return stp state of a particular bridge member. If not a bridge member returns None classmethod subint_port_regex(_ifacename=’.*’) regex to check if string is a subinterface port sys_path(attr, iface_name=None) Returns /sys/class/net/self.name/ vlan_list Returns list that first has the name of the untagged vlan followed by a list of vlans the trunk supports :return: empty list if no vlan list found. netshowlib.linux.iface.iface(name, cache=None) calls on checks to determine best interface type match for the named interface Returns regular linux.iface or linux bond or bond member or linux bridge or bridge member interface netshowlib.linux.iface.portname_list() netshowlib.linux.ip_address module

This module is responsible for getting IP address (ipv4 and ipv6) information from a linux system. It currently has one provider, i.e information from the ip addr show output class netshowlib.linux.ip_address.IpAddress(name, cache=None) Bases: object Ipaddr class attributes •ipv4: list of IPv4 addresses in CIDR format •ipv6: list of IPv6 addresses in CIDR format •cache: cache of all IP addresses •all_ips: Concatenation of ipv4 and ipv6 addresses allentries Returns list of all IPs found both ipv6 and ipv4 ipv4 = None list of IPv4 addresses in CIDR format ipv6 = None list of IPv6 addresses in CIDR format run() Run function for this feature. If cache is present, gets IP info it. if, not will collect it individually netshowlib.linux.ip_address.cacheinfo() Cacheinfo function for IP addresses. Collects all IP addresses from the system and in the return hash assigns IP addresses to particular interfaces :return: hash of ip addresses with iface names as keys. netshowlib.linux.ip_address.parse_ip_cache(fileio) text scrapes ip addr show info to get ipv4 and ipv6 info from each interface Returns has of ip addresses with iface names as keys

10 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

netshowlib.linux.ip_neighbor module

Linux ip neighbor module. IP neighbor relationships in IPv4 are handled by Address Resolution Protocol In IPv6 this process is just known as IP neighbor discovery. class netshowlib.linux.ip_neighbor.IpNeighbor(name, cache=None) Bases: object Linux IP neighbor attributes •name: name of interface •cache: pointer to netshowlib.linux.cache.Cache instance •ipv4: ipv4 neighbor entries •ipv6: ipv6 neighbor entries allentries Returns a list of all ip neighbors ipv4 + ipv6 run() This function checks the cache for ip neighbor information If it is not there, it grabs this info from the system and populates the necessary attributes netshowlib.linux.ip_neighbor.cacheinfo() :return hash of of IpNeighbor info by parsing ip neighbor show output. netshowlib.linux.ip_neighbor.parse_info(table, iptype, ip_neigh_dict) parse ip neighbor information from either ipv4 or ipv6 Params command can be ip neigh show or ip -6 neigh show Params iptype can be ipv4 or ipv6 Params ip_neigh_dict dict to update neighbor table netshowlib.linux.lacp module

This module contains the Lacp Class responsible for methods and attributes regarding Lacp support on Bond interfaces class netshowlib.linux.lacp.Lacp(name) Bases: object Lacp class attributes •sys_priority: LACP system priority. Used in conjunction with the system mac of a bond to create a system Ia •rate: LACP rate/timeout. •partner_mac: LACP partner mac. Collected but not used. May be useful in the future partner_mac Returns bond partner mac rate Returns lacp rate/timeout. Can be slow(0) or fast(1) sys_priority

1.1. Linux Provider API 11 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

Returns lacp system priority netshowlib.linux.lldp module

This module defines properties and functions for collecting LLDP information from a linux device using the lldpctl command class netshowlib.linux.lldp.Lldp(name, cache=None) Bases: object lldp option. run() netshowlib.linux.lldp.cacheinfo() Cacheinfo function for LLDP information. Only works for Debian based systems that default to using lldpd. Or Redhat based systems that user has installed lldpd. No current support for lldpad (redhat recommended lldp app) :return: hash of linux.lldp objects with interface name as their keys netshowlib.linux.provider_discovery module

This modules run a OS discovery check for Linux netshowlib.linux.provider_discovery.check() Linux Provider Check :return: name of OS found if check is true netshowlib.linux.provider_discovery.name_and_priority() name and priority for Linux provider name = Linux priority = 0. Lower priority means less likely candidate netshowlib.linux.system_summary module

System Overview: Uptime, OS Distribution and CPU Architecture class netshowlib.linux.system_summary.SystemSummary Bases: object Class provides some details regarding the system OS •uptime: uptime of the linux device •arch: CPU architecture •version: OS Distribution Version •os_name: OS Distribution Name •os_build: OS Build number if available. parse_lsb_release_exec() parse lsb release exec parse_lsb_release_file() parse /etc/lsb/file DISTRIB_ID=”Cumulus Networks” DISTRIB_RELEASE=2.5.3 DISTRIB_DESCRIPTION=2.5.3-c4e83ad-201506011818-build run() uptime Returns uptime of the linux device in seconds

12 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

Linux Provider API - Netshow App netshow.linux.common module netshow.linux.common.full_legend(show_legend=False) Returns print full legend at the bottom of the screen if legend option is enabled netshow.linux.common.legend() Returns print a legend explaining what the carrier state and bond information means netshow.linux.common.legend_wrapped_cli_output(_output, show_legend=False) Param _output - string from cli call before wrapping legend around it. Returns print cli output with legend wrapper netshow.linux.common.one_line_legend(show_legend=False) Returns string informing user where to find legend. only shown if legend option is not enabled netshow.linux.netjson_encoder module

Module for Converting python class attributes into JSON class netshow.linux.netjson_encoder.NetEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, sep- arators=None, encoding=’utf-8’, de- fault=None) NetEncoder is my custom JSONEncoder class that prints out the json output of any PrintIface Class or subclass. netshow.linux.print_bond module

Print and Analysis Module for Linux bond interfaces class netshow.linux.print_bond.PrintBond(_iface) Print and Analysis Class for Linux bond interfaces classmethod abbrev_bondstate(bondmem) Parameters bondmem – netshowlib.linux.BondMember instance Returns ‘P’ if bondmem in bond Returns ‘N’ if bondmem is not in bond bond_details() print out table with bond details for netshow interface [ifacename] bondmem_details() print out table with bond member summary info for netshow interface [ifacename] for bond interface cli_output() cli output of the linux bond interface :return: output for ‘netshow interface ’ hash_policy

1.1. Linux Provider API 13 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

Returns hash policy for bond lacp_rate() Returns lacp rate in plain english lldp_details() Returns lldp info for the bond members mode Returns name of the bond mode port_category Returns port category for a bond print_bondmems() Returns bondmember list when showing summary in netshow interfaces for the bond interface summary Returns summary info for bonds for ‘netshow interfaces’ class netshow.linux.print_bond.PrintBondMember(_iface) Print and Analysis Class for Linux bond member interfaces bondmem_details() Returns string with output shown when netshow interfaces is issued on a bond member cli_output(show_legend=False) cli output of the linux bond member interface :return: output for ‘netshow interface ’ port_category Returns port category for a bondmem state_in_bond Returns text describing the state of the port in the bond summary Returns summary info for bond members for ‘netshow interfaces’ netshow.linux.print_bridge module

Print and Analysis Module for Linux bridge interfaces class netshow.linux.print_bridge.PrintBridge(_iface) Print and Analysis Class for Linux bridge interfaces cli_output(show_legend=False) Returns output for ‘netshow interface for a bridge interface’ no_stp_details() Returns details when stp is not enabled port_category Returns port category of bridge. Then return its a L2 or L3 port as wel

14 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

root_port() return: root port (should be only one or None) stp_details() Returns stp details for the bridge interface stp_summary() Returns root switch priority if switch is root of bridge Returns root port if switch is not root of bridge Returns stp disabled if stp is disabled summary Returns summary information regarding the bridge tagged_ifaces() Returns list of tagged interfaces of the bridge untagged_ifaces() Returns list of untagged interfaces of the bridge vlan_id() Returns vlan id Returns ‘untagged’ if non is available vlan_id_field() return: list with label saying ‘vlan id’ and vlan tag class netshow.linux.print_bridge.PrintBridgeMember(_iface) Print and Analysis Class for Linux bridge member interfaces cli_output(show_legend=False) Returns output for ‘netshow interface for a bridge interface’ port_category Returns port category for bridge member summary Returns summary info regarding a bridge member netshow.linux.print_iface module

Linux Iface module with print functions class netshow.linux.print_iface.PrintIface(_iface) Printer for Linux Iface class classmethod abbrev_linksummary(linuxiface) Returns ‘U’ if port is up Returns ‘D’ if port is down or admdn access_summary() Returns summary info for an access port

1.1. Linux Provider API 15 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

bridgemem_details() Returns list vlans or bridge names of various stp states cli_header() :return common cli header when printing single iface info cli_output(show_legend=False) Each PrintIface child should define their own of this function Args: show_legend: if set to to true, will show legend, otherwise will show just one line. message telling user to run “netshow” with -l option

Returns: output for ‘netshow interface

ip_details() Returns basic IP info about the interface for single iface info linkstate :return string that prints out link state. admin down or down or up lldp_details() Returns lldp details about this specific interface name Returns name of the interface classmethod new_line() return print newline in cli output. its just two “ “ port_category Returns port type. Via interface discovery determine classify port type print_list_in_chunks(listofstuff, _title, _result, place_in_list=False, break_into_list=False, shorten_to=4) take a long array of bridge names and break it up into smaller groups of ar- rays based on shorten_to variable Reference: http://stackoverflow.com/questions/312443/ how-do-you-split-a-list-into-evenly-sized-chunks-in-python Args: listofstuff (list): list of things that in are in a long list that you want to break up into chunks _title (str): heading of the list of stuff you want cut up in chunks _result (list): The list where the chunks will be stored. place_in_list (boolean): Some data needs to be returned as a list in a list. Others do not. Setting to this true means that you want the _result returned to be a list of list Example [‘1.1.1.1/24’] becomes [”ip: 1.1.1.1/24”] Default: False

break_into_list (boolean): When printing detailed IP info, print out each entry as a list. for example [1.1.1.1/24] becomes [”ip:”, “1.1.1.1/24”] Default: False shorten_to (int): How many elements are to be placed in each chunk. Default: 4

speed Returns print out current speed

16 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

summary Returns summary information regarding the interface trunk_summary() Returns summary info for a trunk port netshow.linux.print_iface.iface(name, cache=None) Returns :class:PrintIface instance that matches correct iface type of the named interface Returns None if interface does not exist netshow.linux.show module

Usage: netshow system [–json | -j ] netshow lldp [–json | -j | -l | –legend] netshow interface [] [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow access [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow bridges [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow bonds [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow bondmems [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow l2 [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow l3 [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow trunks [all] [–mac | -m ] [–oneline | -1 | –json | -j | -l | –legend ] netshow counters [errors] [all] netshow (–version | -V) Help: • default is to show intefaces only in the UP state. interface summary info of all interfaces access summary of physical ports with l2 or l3 config bonds summary of bonds bondmems summary of bond members bridges summary of ports with bridge members l3 summary of ports with an IP. l2 summary of access, trunk and bridge interfaces trunks summary of trunk interfaces lldp physical device neighbor information interface list summary of a single interface system system information counters basic interface counters Options: all show all ports include those are down or admin down –mac show inteface MAC in output –version netshow software version –oneline output each entry on one line -1 alias for –oneline –json print output in json -l alias for –legend –legend print legend key explaining abbreviations netshow.linux.show.interface_related(_nd) return: True if option inputed requires ShowInterfaces() to be activated netshow.linux.show.run() run cumulus netshow version

netshow.linux.show_interfaces module

Module for printout of ‘netshow interfaces’ class netshow.linux.show_interfaces.ShowInterfaces(cl) Class responsible for the ‘netshow interfaces’ printout for the linux provider cli_append_multiline(piface) prints summary netshow information multiple lines per interface cli_append_oneline(piface) prints summary netshow information one line per interface ifacelist

1.1. Linux Provider API 17 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

Returns hash of interface categories. each category containing a list of iface pointers to inter- faces that belong in that category. For example ifacelist[’bridge’] points to a list of bridge Ifaces. print_cli_many_ifaces(port_type) Returns ‘netshow interface’ of many interfaces in terminal output print_json_many_ifaces(port_type) Returns ‘netshow interface’ of many interfaces in JSON output print_many_ifaces() Returns the output of ‘netshow interfaces’ for many interfaces print_single_iface() Returns netshow terminal output or JSON of a single iface run() Returns terminal output or JSON for ‘netshow interfaces’ for the linux provider summary_header Returns summary header for ‘netshow interfaces’ netshow.linux.show_neighbors module

Module for printout out linux device neighbors class netshow.linux.show_neighbors.ShowNeighbors(cl) Class responsible for printing out basic linux device neighbor info print_neighbor_info() Returns cli output of netshow neighbor run() Returns basic neighbor information based on data obtained on netshow-lib netshow.linux.show_system module

Module for printing out basic linux system information class netshow.linux.show_system.ShowSystem(cl) Class responsible for printing out basic linux system summary info cli_output() print linux basic system output on a terminal run() Returns output regarding system like OS type, etc uptime Returns system uptime in humanly readable form

18 Chapter 1. Netshow Linux Provider Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

License

This software is distributed under the GNU General Public License version 2. See the LICENSE (needs a link) file for details.

Credits

Maintainer: Cumulus Networks

1.2. License 19 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

20 Chapter 1. Netshow Linux Provider Python Module Index

n netshow.linux.common, 13 netshow.linux.netjson_encoder, 13 netshow.linux.print_bond, 13 netshow.linux.print_bridge, 14 netshow.linux.print_iface, 15 netshow.linux.show, 17 netshow.linux.show_interfaces, 17 netshow.linux.show_neighbors, 18 netshow.linux.show_system, 18 netshowlib.linux.bond,1 netshowlib.linux.bridge,3 netshowlib.linux.cache,5 netshowlib.linux.common,5 netshowlib.linux.iface,7 netshowlib.linux.ip_address, 10 netshowlib.linux.ip_neighbor, 11 netshowlib.linux.lacp, 11 netshowlib.linux.lldp, 12 netshowlib.linux.provider_discovery, 12 netshowlib.linux.system_summary, 12

21 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

22 Python Module Index Index

A cacheinfo() (in module netshowlib.linux.ip_neighbor), 11 abbrev_bondstate() (netshow.linux.print_bond.PrintBond cacheinfo() (in module netshowlib.linux.lldp), 12 class method), 13 check() (in module netshowlib.linux.provider_discovery), abbrev_linksummary() (net- 12 show.linux.print_iface.PrintIface class check_bit() (in module netshowlib.linux.common),5 method), 15 check_port_dhcp_assignment() (net- access_summary() (netshow.linux.print_iface.PrintIface showlib.linux.iface.Iface method),7 method), 15 clear_bit() (in module netshowlib.linux.common),5 allentries (netshowlib.linux.ip_address.IpAddress at- cli_append_multiline() (net- tribute), 10 show.linux.show_interfaces.ShowInterfaces allentries (netshowlib.linux.ip_neighbor.IpNeighbor at- method), 17 tribute), 11 cli_append_oneline() (net- show.linux.show_interfaces.ShowInterfaces B method), 17 Bond (class in netshowlib.linux.bond),1 cli_header() (netshow.linux.print_iface.PrintIface bond_details() (netshow.linux.print_bond.PrintBond method), 16 method), 13 cli_output() (netshow.linux.print_bond.PrintBond bondmem_details() (netshow.linux.print_bond.PrintBond method), 13 cli_output() (netshow.linux.print_bond.PrintBondMember method), 13 method), 14 bondmem_details() (net- show.linux.print_bond.PrintBondMember cli_output() (netshow.linux.print_bridge.PrintBridge method), 14 method), 14 BondMember (class in netshowlib.linux.bond),2 cli_output() (netshow.linux.print_bridge.PrintBridgeMember bondstate (netshowlib.linux.bond.BondMember at- method), 15 cli_output() (netshow.linux.print_iface.PrintIface tribute),3 method), 16 Bridge (class in netshowlib.linux.bridge),3 bridge_masters (netshowlib.linux.bond.Bond attribute),2 cli_output() (netshow.linux.show_system.ShowSystem bridge_masters (netshowlib.linux.bridge.BridgeMember method), 18 attribute),4 counters (netshowlib.linux.iface.Iface attribute),7 bridge_priority (netshowlib.linux.bridge.KernelStpBridge create_range() (in module netshowlib.linux.common),5 create_sort_tuple() (in module net- attribute),4 showlib.linux.common),5 bridgemem_details() (net- show.linux.print_iface.PrintIface method), D 15 BridgeMember (class in netshowlib.linux.bridge),4 description (netshowlib.linux.iface.Iface attribute),7 dict_merge() (in module netshowlib.linux.common),5 C E Cache (class in netshowlib.linux.cache),5 exec_command() (in module netshowlib.linux.common), cacheinfo() (in module netshowlib.linux.ip_address), 10 6

23 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438 exec_commandl() (in module netshowlib.linux.common), is_bridgemem() (netshowlib.linux.iface.Iface method),8 6 is_bridgemem_initial_test() (netshowlib.linux.iface.Iface ExecCommandException,5 method),8 exists() (netshowlib.linux.iface.Iface method),7 is_l2() (netshowlib.linux.iface.Iface method),8 is_l3() (netshowlib.linux.iface.Iface method),8 F is_loopback() (netshowlib.linux.iface.Iface method),8 full_legend() (in module netshow.linux.common), 13 is_loopback_initial_test() (netshowlib.linux.iface.Iface method),9 G is_root() (netshowlib.linux.bridge.KernelStpBridge generate_cidr_ip() (in module net- method),4 showlib.linux.common),6 is_subint() (netshowlib.linux.iface.Iface method),9 get_bridgemem_port_type() (netshowlib.linux.iface.Iface is_subint_initial_test() (netshowlib.linux.iface.Iface method),7 method),9 get_sub_interfaces() (netshowlib.linux.iface.Iface is_trunk() (netshowlib.linux.iface.Iface method),9 method),7 group_iface() (in module netshowlib.linux.common),6 K group_ports() (in module netshowlib.linux.common),6 KernelStpBridge (class in netshowlib.linux.bridge),4 grouping_func() (in module netshowlib.linux.common),6 KernelStpBridgeMember (class in net- showlib.linux.bridge),4 H has_stats() (in module netshowlib.linux.common),6 L has_stats() (netshowlib.linux.iface.Iface method),8 Lacp (class in netshowlib.linux.lacp), 11 hash_policy (netshow.linux.print_bond.PrintBond at- lacp (netshowlib.linux.bond.Bond attribute),2 tribute), 13 lacp_rate() (netshow.linux.print_bond.PrintBond hash_policy (netshowlib.linux.bond.Bond attribute),2 method), 14 legend() (in module netshow.linux.common), 13 I legend_wrapped_cli_output() (in module net- Iface (class in netshowlib.linux.iface),7 show.linux.common), 13 iface() (in module netshow.linux.print_iface), 17 linkfailures (netshowlib.linux.bond.BondMember at- iface() (in module netshowlib.linux.iface), 10 tribute),3 ifacelist (netshow.linux.show_interfaces.ShowInterfaces linkstate (netshow.linux.print_iface.PrintIface attribute), attribute), 17 16 interface_related() (in module netshow.linux.show), 17 linkstate (netshowlib.linux.iface.Iface attribute),9 ip_addr_assign (netshowlib.linux.iface.Iface attribute),8 Lldp (class in netshowlib.linux.lldp), 12 ip_address (netshowlib.linux.iface.Iface attribute),8 lldp (netshowlib.linux.iface.Iface attribute),9 ip_details() (netshow.linux.print_iface.PrintIface lldp_details() (netshow.linux.print_bond.PrintBond method), 16 method), 14 ip_neighbor (netshowlib.linux.iface.Iface attribute),8 lldp_details() (netshow.linux.print_iface.PrintIface IpAddress (class in netshowlib.linux.ip_address), 10 method), 16 IpNeighbor (class in netshowlib.linux.ip_neighbor), 11 ipv4 (netshowlib.linux.ip_address.IpAddress attribute), M 10 mac (netshowlib.linux.iface.Iface attribute),9 ipv6 (netshowlib.linux.ip_address.IpAddress attribute), master (netshowlib.linux.bond.BondMember attribute),3 10 member_state (netshowlib.linux.bridge.KernelStpBridge is_access() (netshowlib.linux.iface.Iface method),8 attribute),4 is_bond() (netshowlib.linux.iface.Iface method),8 members (netshowlib.linux.bond.Bond attribute),2 is_bond_initial_test() (netshowlib.linux.iface.Iface members (netshowlib.linux.bridge.Bridge attribute),3 method),8 min_links (netshowlib.linux.bond.Bond attribute),2 is_bondmem() (netshowlib.linux.iface.Iface method),8 mode (netshow.linux.print_bond.PrintBond attribute), 14 is_bondmem_initial_test() (netshowlib.linux.iface.Iface mode (netshowlib.linux.bond.Bond attribute),2 method),8 mtu (netshowlib.linux.iface.Iface attribute),9 is_bridge() (netshowlib.linux.iface.Iface method),8 munge_str() (in module netshowlib.linux.common),6 is_bridge_initial_test() (netshowlib.linux.iface.Iface method),8

24 Index Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438

N port_category (netshow.linux.print_bridge.PrintBridge at- name (netshow.linux.print_iface.PrintIface attribute), 16 tribute), 14 name (netshowlib.linux.iface.Iface attribute),9 port_category (netshow.linux.print_bridge.PrintBridgeMember name_and_priority() (in module net- attribute), 15 showlib.linux.provider_discovery), 12 port_category (netshow.linux.print_iface.PrintIface at- native_vlan (netshowlib.linux.iface.Iface attribute),9 tribute), 16 NetEncoder (class in netshow.linux.netjson_encoder), 13 portname_list() (in module netshowlib.linux.common),6 netmask_dot_notation_to_cidr() (in module net- portname_list() (in module netshowlib.linux.iface), 10 showlib.linux.common),6 print_bondmems() (netshow.linux.print_bond.PrintBond netshow.linux.common (module), 13 method), 14 netshow.linux.netjson_encoder (module), 13 print_cli_many_ifaces() (net- netshow.linux.print_bond (module), 13 show.linux.show_interfaces.ShowInterfaces netshow.linux.print_bridge (module), 14 method), 18 netshow.linux.print_iface (module), 15 print_json_many_ifaces() (net- netshow.linux.show (module), 17 show.linux.show_interfaces.ShowInterfaces netshow.linux.show_interfaces (module), 17 method), 18 netshow.linux.show_neighbors (module), 18 print_list_in_chunks() (net- netshow.linux.show_system (module), 18 show.linux.print_iface.PrintIface method), netshowlib.linux.bond (module),1 16 netshowlib.linux.bridge (module),3 print_many_ifaces() (net- netshowlib.linux.cache (module),5 show.linux.show_interfaces.ShowInterfaces netshowlib.linux.common (module),5 method), 18 netshowlib.linux.iface (module),7 print_neighbor_info() (net- netshowlib.linux.ip_address (module), 10 show.linux.show_neighbors.ShowNeighbors netshowlib.linux.ip_neighbor (module), 11 method), 18 netshowlib.linux.lacp (module), 11 print_single_iface() (net- netshowlib.linux.lldp (module), 12 show.linux.show_interfaces.ShowInterfaces netshowlib.linux.provider_discovery (module), 12 method), 18 netshowlib.linux.system_summary (module), 12 PrintBond (class in netshow.linux.print_bond), 13 new_line() (netshow.linux.print_iface.PrintIface class PrintBondMember (class in netshow.linux.print_bond), method), 16 14 no_stp_details() (netshow.linux.print_bridge.PrintBridge PrintBridge (class in netshow.linux.print_bridge), 14 method), 14 PrintBridgeMember (class in net- show.linux.print_bridge), 15 O PrintIface (class in netshow.linux.print_iface), 15 one_line_legend() (in module netshow.linux.common), 13 R rate (netshowlib.linux.lacp.Lacp attribute), 11 P read_file() (in module netshowlib.linux.common),6 parse_info() (in module netshowlib.linux.ip_neighbor), read_file_oneline() (in module net- 11 showlib.linux.common),6 parse_ip_cache() (in module net- read_from_sys() (in module netshowlib.linux.common),6 showlib.linux.ip_address), 10 read_from_sys() (netshowlib.linux.iface.Iface method),9 parse_lsb_release_exec() (net- read_symlink() (in module netshowlib.linux.common),6 showlib.linux.system_summary.SystemSummary read_symlink() (netshowlib.linux.iface.Iface method),9 method), 12 root_port() (netshow.linux.print_bridge.PrintBridge parse_lsb_release_file() (net- method), 14 showlib.linux.system_summary.SystemSummary root_priority (netshowlib.linux.bridge.KernelStpBridge method), 12 attribute),4 partner_mac (netshowlib.linux.lacp.Lacp attribute), 11 run() (in module netshow.linux.show), 17 port_category (netshow.linux.print_bond.PrintBond at- run() (netshow.linux.show_interfaces.ShowInterfaces tribute), 14 method), 18 port_category (netshow.linux.print_bond.PrintBondMemberrun() (netshow.linux.show_neighbors.ShowNeighbors attribute), 14 method), 18

Index 25 Netshow CLI / Netshow Library - Linux Provider, Release 1.1.7+git.18.c727438 run() (netshow.linux.show_system.ShowSystem method), T 18 tagged_ifaces() (netshow.linux.print_bridge.PrintBridge run() (netshowlib.linux.cache.Cache method),5 method), 15 run() (netshowlib.linux.ip_address.IpAddress method), tagged_members (netshowlib.linux.bridge.Bridge at- 10 tribute),3 run() (netshowlib.linux.ip_neighbor.IpNeighbor method), test_bit() (in module netshowlib.linux.common),7 11 trunk_summary() (netshow.linux.print_iface.PrintIface run() (netshowlib.linux.lldp.Lldp method), 12 method), 17 run() (netshowlib.linux.system_summary.SystemSummary method), 12 U untagged_ifaces() (netshow.linux.print_bridge.PrintBridge S method), 15 set_bit() (in module netshowlib.linux.common),6 untagged_members (netshowlib.linux.bridge.Bridge at- ShowInterfaces (class in netshow.linux.show_interfaces), tribute),3 17 update_stp_state() (in module netshowlib.linux.bridge),5 ShowNeighbors (class in netshow.linux.show_neighbors), uptime (netshow.linux.show_system.ShowSystem at- 18 tribute), 18 ShowSystem (class in netshow.linux.show_system), 18 uptime (netshowlib.linux.system_summary.SystemSummary sort_ports() (in module netshowlib.linux.common),6 attribute), 12 speed (netshow.linux.print_iface.PrintIface attribute), 16 speed (netshowlib.linux.iface.Iface attribute),9 V state (netshowlib.linux.bridge.KernelStpBridgeMember vlan_id() (netshow.linux.print_bridge.PrintBridge attribute),5 method), 15 state_in_bond (netshow.linux.print_bond.PrintBondMembervlan_id_field() (netshow.linux.print_bridge.PrintBridge attribute), 14 method), 15 stp (netshowlib.linux.bond.Bond attribute),2 vlan_list (netshowlib.linux.iface.Iface attribute), 10 stp (netshowlib.linux.bridge.Bridge attribute),3 vlan_tag (netshowlib.linux.bridge.Bridge attribute),3 stp (netshowlib.linux.bridge.BridgeMember attribute),4 stp_details() (netshow.linux.print_bridge.PrintBridge method), 15 stp_state() (netshowlib.linux.iface.Iface method),9 stp_summary() (netshow.linux.print_bridge.PrintBridge method), 15 subint_port_regex() (netshowlib.linux.iface.Iface class method), 10 summary (netshow.linux.print_bond.PrintBond attribute), 14 summary (netshow.linux.print_bond.PrintBondMember attribute), 14 summary (netshow.linux.print_bridge.PrintBridge at- tribute), 15 summary (netshow.linux.print_bridge.PrintBridgeMember attribute), 15 summary (netshow.linux.print_iface.PrintIface attribute), 16 summary_header (netshow.linux.show_interfaces.ShowInterfaces attribute), 18 sys_path() (in module netshowlib.linux.common),6 sys_path() (netshowlib.linux.iface.Iface method), 10 sys_priority (netshowlib.linux.lacp.Lacp attribute), 11 system_mac (netshowlib.linux.bond.Bond attribute),2 SystemSummary (class in net- showlib.linux.system_summary), 12

26 Index