task: napalm_cli

napalm_cli exposes napalm’s method cli.

Example:

[1]:
from nornir import InitNornir
from nornir_napalm.plugins.tasks import napalm_cli

nr = InitNornir(
    inventory={
        "plugin": "SimpleInventory",
        "options": {
            "host_file": "inventory/hosts.yaml",
            "group_file": "inventory/groups.yaml",
            "defaults_file": "inventory/defaults.yaml",
        }
    },
    dry_run=True,
)
[2]:
result = nr.run(napalm_cli, commands=["show version", "show interfaces"])
[3]:
print(result["rtr00"][0].result["show version"])
Arista vEOS
Hardware version:
Serial number:
System MAC address:  0800.27af.1c32

Software image version: 4.15.2.1F
Architecture:           i386
Internal build version: 4.15.2.1F-2759627.41521F
Internal build ID:      8404cfa4-04c4-4008-838b-faf3f77ef6b8

Uptime:                 2 minutes
Total memory:           1897596 kB
Free memory:            78796 kB

[4]:
print(result["rtr00"][0].result["show interfaces"])
Ethernet1 is up, line protocol is up (connected)
  Hardware is Ethernet, address is 0800.2746.8502 (bia 0800.2746.8502)
  Ethernet MTU 9214 bytes
  Full-duplex, Unconfigured, auto negotiation: off, uni-link: n/a
  Up 1 minutes, 27 seconds
  Loopback Mode : None
  1 link status changes since last clear
  Last clearing of "show interface" counters never
  5 minutes input rate 0 bps (- with framing overhead), 0 packets/sec
  5 minutes output rate 0 bps (- with framing overhead), 0 packets/sec
     0 packets input, 0 bytes
     Received 0 broadcasts, 0 multicast
     0 runts, 0 giants
     0 input errors, 0 CRC, 0 alignment, 0 symbol, 0 input discards
     0 PAUSE input
     50 packets output, 6464 bytes
     Sent 0 broadcasts, 50 multicast
     0 output errors, 0 collisions
     0 late collision, 0 deferred, 0 output discards
     0 PAUSE output
Ethernet2 is up, line protocol is up (connected)
  Hardware is Ethernet, address is 0800.27f9.0ff6 (bia 0800.27f9.0ff6)
  Ethernet MTU 9214 bytes
  Full-duplex, Unconfigured, auto negotiation: off, uni-link: n/a
  Up 1 minutes, 27 seconds
  Loopback Mode : None
  1 link status changes since last clear
  Last clearing of "show interface" counters 0:02:18 ago
  5 minutes input rate 0 bps (- with framing overhead), 0 packets/sec
  5 minutes output rate 0 bps (- with framing overhead), 0 packets/sec
     0 packets input, 0 bytes
     Received 0 broadcasts, 0 multicast
     0 runts, 0 giants
     0 input errors, 0 CRC, 0 alignment, 0 symbol, 0 input discards
     0 PAUSE input
     50 packets output, 6464 bytes
     Sent 0 broadcasts, 50 multicast
     0 output errors, 0 collisions
     0 late collision, 0 deferred, 0 output discards
     0 PAUSE output
Management1 is up, line protocol is up (connected)
  Hardware is Ethernet, address is 0800.277d.44c1 (bia 0800.277d.44c1)
  Internet address is 10.0.2.15/24
  Broadcast address is 255.255.255.255
  Address determined by manual configuration
  IP MTU 1500 bytes , BW 1000000 kbit
  Full-duplex, 1Gb/s, auto negotiation: on, uni-link: n/a
  Up 1 minutes, 11 seconds
  Loopback Mode : None
  5 link status changes since last clear
  Last clearing of "show interface" counters never
  5 minutes input rate 1.40 kbps (0.0% with framing overhead), 0 packets/sec
  5 minutes output rate 1.32 kbps (0.0% with framing overhead), 1 packets/sec
     3 packets input, 66960 bytes
     Received 3 broadcasts, 0 multicast
     0 runts, 0 giants
     0 input errors, 0 CRC, 0 alignment, 0 symbol, 0 input discards
     0 PAUSE input
     449 packets output, 62541 bytes
     Sent 0 broadcasts, 0 multicast
     0 output errors, 0 collisions
     0 late collision, 0 deferred, 0 output discards
     0 PAUSE output
     '