salt.modules.napalm_network module

Basic functions from Napalm library

salt.modules.napalm_network.arp(interface='', ipaddr='', macaddr='')

NAPALM returns a list of dictionaries with details of the ARP entries: [{INTERFACE, MAC, IP, AGE}]

CLI example:

salt myminion net.arp
salt myminion net.arp macaddr='5c:5e:ab:da:3c:f0'
参数:
  • interface -- interface name to filter on
  • ipaddr -- IP address to filter on
  • macaddr -- MAC address to filter on
Example output:
[
{
'interface' : 'MgmtEth0/RSP0/CPU0/0', 'mac' : '5c:5e:ab:da:3c:f0', 'ip' : '172.17.17.1', 'age' : 1454496274.84

}, {

'interface': 'MgmtEth0/RSP0/CPU0/0', 'mac' : '66:0e:94:96:e0:ff', 'ip' : '172.17.17.2', 'age' : 1435641582.49

}

]

salt.modules.napalm_network.cli(*commands)

NAPALM returns a dictionary with the output of all commands passed as arguments:

CLI example:

salt myminion net.cli "show version" "show route 8.8.8.8"
参数:commands -- list of raw commands to execute on device
Example:
{
u'show version and haiku' : u'''Hostname: re0.edge01.arn01

Model: mx480 Junos: 13.3R6.5

Help me, Obi-Wan I just saw Episode Two You're my only hope

''',

u'show chassis fan' : u'''Item Status RPM Measurement
Top Rear Fan OK 3840 Spinning at intermediate-speed Bottom Rear Fan OK 3840 Spinning at intermediate-speed Top Middle Fan OK 3900 Spinning at intermediate-speed Bottom Middle Fan OK 3840 Spinning at intermediate-speed Top Front Fan OK 3810 Spinning at intermediate-speed Bottom Front Fan OK 3840 Spinning at intermediate-speed

'''

}

salt.modules.napalm_network.ipaddrs()

Returns IP addresses on the device

CLI example:

salt myminion net.ipaddrs
salt.modules.napalm_network.lldp(interface='')

returns LLDP neighbors

CLI example:

salt myminion net.lldp
salt myminion net.lldp interface='TenGigE0/0/0/8'
参数:interface -- interface name to filter on
Example output:
{
'TenGigE0/0/0/8': [
{

'parent_interface': u'Bundle-Ether8', 'interface_description': u'TenGigE0/0/0/8', 'remote_chassis_id': u'8c60.4f69.e96c', 'remote_system_name': u'switch', 'remote_port': u'Eth2/2/1', 'remote_port_description': u'Ethernet2/2/1', 'remote_system_description': u'''Cisco Nexus Operating System (NX-OS) Software 7.1(0)N1(1a)

TAC support: http://www.cisco.com/tac Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.''',

'remote_system_capab': u'B, R', 'remote_system_enable_capab': u'B'

}

]

}

salt.modules.napalm_network.mac(address='', interface='', vlan=0)

returns device MAC address table

CLI example:

salt myminion net.mac
salt myminion net.mac vlan=10
参数:
  • address -- MAC address to filter on
  • interface -- interface name to filter on
  • vlan -- vlan identifier
Example output:
[
{
'mac' : '00:1c:58:29:4a:71', 'interface' : 'xe-3/0/2', 'static' : False, 'active' : True, 'moves' : 1, 'vlan' : 10, 'last_move' : 1454417742.58

}, {

'mac' : '8c:60:4f:58:e1:c1', 'interface' : 'xe-1/0/1', 'static' : False, 'active' : True, 'moves' : 2, 'vlan' : 42, 'last_move' : 1453191948.11

}

]

salt.modules.napalm_network.ping()

is the device alive ?

CLI example:

salt myminion net.ping