CLI IP Data Plugin

This plugin populates diagram with IP related information, such as subnets and IP addresses.

IP data plugin mainly useful in networking domain, it can take show commands output from network devices, parse it with TTP templates in a structure that processed further to load into one of diagram plugin objects using from_dict method

Features Supported

Support matrix

Platform Name

IP/Subnets

ARP

interface config

links grouping

FHRP Protocols

cisco_ios

YES

YES

YES

YES

YES

cisco_xr

YES

YES

YES

YES

cisco_nxos

YES

YES

YES

YES

YES

huawei

YES

YES

YES

YES

YES

fortinet

YES

YES

YES

YES

arista_eos

YES

YES

YES

YES

Required Commands output

cisco_ios:

  • show running-config or show running-config | section interface - mandatory output, used to parse interfaces IP addresses

  • show ip arp and/or show ip arp vrf xyz - required by ARP visualization feature

cisco_xr:

  • show running-config or show running-config interface - mandatory output, used to parse interfaces IP addresses

  • show arp and/or show arp vrf xyz/all - required by ARP visualization feature

cisco_nxos:

  • show running-config or show running-config | section interface - mandatory output, used to parse interfaces IP addresses

  • show ip arp - required by ARP visualization feature

huawei:

  • display current-configuration interface - mandatory output, used to parse interfaces IP addresses

  • display arp all - required by ARP visualization feature

fortinet:

  • get system config - mandatory output, used to parse interfaces IP addresses

  • get system arp - required by ARP visualization feature

arista_eos:

  • show running-config or show running-config | section interface - mandatory output, used to parse interfaces IP addresses

  • show ip arp and/or show ip arp vrf all - required by ARP visualization feature

Sample Usage

Code to populate yEd diagram object with IP and subnet nodes using data dictionary:

data = {"huawei": ['''
<hua_sw1>dis current-configuration interface
#
interface Vlanif140
 ip binding vpn-instance VRF_MGMT
 ip address 10.1.1.2 255.255.255.0
 vrrp vrid 200 virtual-ip 10.1.1.1
#
interface Eth-Trunk5.123
 vlan-type dot1q 123
 description hua_sw2 BGP  peering
 ip binding vpn-instance VRF_MGMT
 ip address 10.0.0.1 255.255.255.252
 ipv6 address FD00:1::1/126
#
interface Eth-Trunk5.200
 vlan-type dot1q 200
 description hua_sw3 OSPF  peering
 ip address 192.168.2.2 255.255.255.252

<hua_sw1>dis arp all
10.1.1.2        a008-6fc1-1101        I         Vlanif140       VRF_MGMT
10.1.1.1        a008-6fc1-1102   0    D         Vlanif140       VRF_MGMT
10.1.1.3        a008-6fc1-1103   10   D/200     Vlanif140       VRF_MGMT
10.1.1.9        a008-6fc1-1104   10   D/200     Vlanif140       VRF_MGMT
10.0.0.2        a008-6fc1-1105   10   D/200     Eth-Trunk5.123  VRF_MGMT
    ''',
    '''
<hua_sw2>dis current-configuration interface
#
interface Vlanif140
 ip binding vpn-instance VRF_MGMT
 ip address 10.1.1.3 255.255.255.0
 vrrp vrid 200 virtual-ip 10.1.1.1
#
interface Eth-Trunk5.123
 vlan-type dot1q 123
 description hua_sw1 BGP  peering
 ip binding vpn-instance VRF_MGMT
 ip address 10.0.0.2 255.255.255.252
 ipv6 address FD00:1::2/126
    ''',
    '''
<hua_sw3>dis current-configuration interface
#
interface Vlanif200
 ip binding vpn-instance VRF_CUST1
 ip address 192.168.1.1 255.255.255.0
#
interface Eth-Trunk5.200
 vlan-type dot1q 200
 description hua_sw1 OSPF  peering
 ip address 192.168.2.1 255.255.255.252

<hua_sw3>dis arp
192.168.1.1         a008-6fc1-1111       I      Vlanif200
192.168.1.10        a008-6fc1-1110   30  D/300  Vlanif200
    '''],
"cisco_nxos": ['''
switch_1# show run | sec interface
interface Vlan133
  description OOB
  vrf member MGMT_OOB
  ip address 10.133.137.2/24
  hsrp 133
    preempt
    ip 10.133.137.1
!
interface Vlan134
  description OOB-2
  vrf member MGMT_OOB
  ip address 10.134.137.2/24
  vrrpv3 1334 address-family ipv4
    address 10.134.137.1 primary
!
interface Vlan222
  description PTP OSPF Routing pat to  siwtch2
  ip address 10.222.137.1/30
!
interface Vlan223
  description PTP OSPF Routing pat to siwtch3
  ip address 10.223.137.1/30

switch_1# show ip arp vrf all
10.133.137.2    -  d094.7890.1111  Vlan133
10.133.137.1    -  d094.7890.1111  Vlan133
10.133.137.30   -  d094.7890.1234  Vlan133
10.133.137.91   -  d094.7890.4321  Vlan133
10.134.137.1    -  d094.7890.1111  Vlan134
10.134.137.2    -  d094.7890.1111  Vlan134
10.134.137.3   90  d094.7890.2222  Vlan134
10.134.137.31  91  d094.7890.beef  Vlan134
10.134.137.81  81  d094.7890.feeb  Vlan134
10.222.137.2   21  d094.7890.2222  Vlan222
'''
}

drawing = create_yed_diagram()
drawer = cli_ip_data(drawing, add_arp=True, add_fhrp=True)
drawer.work(data)
drawer.drawing.dump_file(filename="ip_graph_dc_1.graphml", folder="./Output/")

API Reference

class N2G.plugins.data.cli_ip_data.cli_ip_data(drawing, ttp_vars=None, group_links=False, add_arp=False, label_interface=False, label_vrf=False, collapse_ptp=True, add_fhrp=False, bottom_label_length=0, lbl_next_to_subnet=False, platforms=None)

Class to instantiate IP Data Plugin.

Parameters
  • drawing – (obj) - N2G drawing object instantiated using drawing module e.g. yed_diagram or drawio_diagram

  • ttp_vars – (dict) - dictionary to use as TTP parser object template variables

  • platforms – (list) - list of platform names to process e.g. cisco_ios, cisco_xr etc, default is _all_

  • group_links – (bool) - if True, will group links between same nodes, default is False

  • add_arp – (bool) - if True, will add IP nodes from ARP parsing results, default is False

  • label_interface – (bool) - if True, will add interface name to the link’s source and target labels, default is False

  • label_vrf – (bool) - if True, will add VRF name to the link’s source and target labels, default is False

  • collapse_ptp – (bool) - if True (default) combines links for /31 and /30 IPv4 and /127 IPv6 subnets into a single ink

  • add_fhrp – (bool) - if True adds HSRP and VRRP IP addresses to the diagram, default is False

  • bottom_label_length – (int) - bottom label length of interface description to use for subnet nodes, if False or 0, bottom label will not be set for subnet nodes

  • lbl_next_to_subnet – (bool) - if True, put link port:vrf:ip label next to subnet node, default is False

work(data)

Method to parse text data and add nodes and links to drawing object.

Parameters

data – (dict or str) dictionary or OS path string to directories with data files

If data is dictionary, keys must correspond to Platform column in Features Supported section table, values are lists of text items to process.

Data dictionary sample:

data = {
    "cisco_ios" : ["h1", "h2"],
    "cisco_xr": ["h3", "h4"],
    "cisco_nxos": ["h5", "h6"],
    ...etc...
}

Where hX devices show commands output.

If data is an OS path directory string, child directories’ names must correspond to Platform column in Features Supported section table. Each child directory should contain text files with show commands output for each device, names of files are arbitrary, but output should contain device prompt to extract device hostname.

Directories structure sample:

├───folder_with_data
    ├───cisco_ios
    │       switch1.txt
    │       switch2.txt
    └───cisco_nxos
            nxos_switch_1.txt
            nxos_switch_2.txt

To point N2G to above location data attribute string can be /var/data/n2g/folder_with_data/