Open NX-OS on the Cisco Nexus platform is a rich software suite built on a Linux foundation that exposes APIs, data models, and programmatic constructs. Using Application Programmatic Interfaces (APIs) and configuration agents, operators can affect configuration changes in a more programmatic way. Cisco provides various tools and frameworks to enable developers to automate and program Nexus devices, including - NX-API REST brings Model Driven Programmability (MDP) to standalone, Python, Puppet, Chef, Ansible etc.
This section provides basic Open NX-OS configuration use cases, such as - interface config, VLAN config & management, OSPF config etc. Examples are written in most widely used config tools/programmatic interfaces - Puppet, NX-API and Python.
In addition to code snippets on the right, we are happy to provide users with access to Cisco's DevNet Sandbox lab resources. Instructions on accessing DevNet Sandbox Labs and instructions to run the script are provided below.
The Open NX-OS sandbox is a testing environment that enables developers to experiment from the production environment or repository of CISCO lab. A developer can use this sandbox to program the switch through various configuration management tools and scripts like bash, python, puppet, chef and ansible.
Program and manage interfaces. You can configure interfaces using different configuration management tools. Following example shows how to display Nexus 9000 interfaces, bring the interfaces up or down, configure IP address.
Configure physical ethernet port for various interface properties on eth1/1:
POST http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/1].json?query-target=self HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
{
"l1PhysIf": {
"attributes": {
"accessVlan": "vlan-321",
"adminSt": "down",
"bw": "0",
"childAction": "",
"delay": "1",
"descr": "Sample test",
"duplex": "auto",
"id": "eth1/1",
"layer": "Layer2",
"lcOwn": "local",
"linkDebounce": "100",
"mdix": "auto",
"mode": "access",
"mtu": "1500",
"portT": "leaf",
"snmpTrapSt": "enable",
"speed": "auto",
"trunkLog": "default",
"trunkVlans": "1-4094"
}
}
}
# Sample file to configure Interface
# Import Interface class
from .interface import Interface
from .nxcli import NXCLI
import traceback
# Fillup the Interface details to be configured
interfaceName="Ethernet1/6"
interfaceIpaddress="192.168.17.12/24"
interfaceDescription="Interface6"
interfaceState="no shut"
def is_interface_available(interfaceName):
"""
Checks if interface is available or not.
return True if interface is available, else return False
"""
try:
interface = NXCLI('show run interface %s' %interfaceName)
return True
except:
return False
def configure_terminal(cmd):
"""
Configure terminal based on the commands given
"""
NXCLI._run_cfg(cmd)
def convert_to_routed_interface(interfaceName):
"""
Convert interface mode from access to routed
"""
cmd = "interface %s ; no switchport" %interfaceName
configure_terminal(cmd)
if __name__=="__main__":
try:
if not is_interface_available(interfaceName):
raise Exception("Interface not available. \nPlease give different interface. To list available interfaces, just go to switch-prompt and type : \nshow int br")
switch=Interface(interfaceName)
print "Before Interface Configuration"
configurationResults=switch.config()
print configurationResults
convert_to_routed_interface(interfaceName)
if interfaceIpaddress:
#set Ip address
ipaddress=switch.set_ipaddress(interfaceIpaddress)
#set Description
if interfaceDescription:
description=switch.set_description(interfaceDescription)
#set mode and state
switch.set_state(interfaceState)
print "After interface Configuration"
configurationResults=switch.config()
print configurationResults
except Exception,e:
traceback.print_exc()
# Configuring Interface eth1/1
cisco_interface { "Ethernet1/1" :
shutdown => true,
switchport_mode => disabled,
description => 'managed by puppet',
ipv4_address => '1.1.43.43',
ipv4_netmask_length => 24,
}
# Configuring interface eth1/2
cisco_interface { "Ethernet1/2" :
description => 'default',
shutdown => 'default',
access_vlan => 'default',
switchport_mode => access,
}
# Configuring interface
cisco_interface { "Vlan22" :
svi_autostate => false,
svi_management => true,
}
Follow below the steps below to execute NX-API REST code snippet on a nx9000 switch.
On the nx9000 switch perform following operation.
Setup postman Code snippet: In order to execute NXAPI from postman, login needs to be performed. The cookie would get generated and stored for subsequent execution.
POST-URL : http://SWITCH-IP/api/aaaLogin.json
Content-Type: application/json
Cache-Control: no-cache
POST BODY :
{
"aaaUser" : {
"attributes" : {
"name" : "SWITCH_USER",
"pwd" : "SWITCH_PASSWORD"
}
}
}
Executing NXAPI using postman for first time:
Click send button
Note: If the cookie gets expired, you might have to perform the above steps again.
For subsequent NXAPI call:
Follow following steps to execute the python scripts on Nexus switch.
Following steps would execute the manifest files on nx9000 switch.
Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference.
Save and exit.
Note : If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note : Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
Steps to add the certificates :
Program and manage Virtual LAN(VLAN). You can use VLANs to divide the network into separate logical areas. VLANs can also be considered as broadcast domains. Any Nexus 9000 switch port can belong to a VLAN, and unicast, broadcast, and multicast packets are forwarded and flooded only to end stations in that VLAN. Each VLAN is considered a logical network, and packets destined for stations that do not belong to the VLAN must be forwarded through a router. This section describe how you can manage and configure VLAN on a CISCO Nexus 9000 switch using different configuration management code snippet.
> Create VLAN 100
POST http://SWITCH-IP/api/node/mo/sys/bd/bd-[vlan-100].json HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
{
"l2BD": {
"attributes": {
"fabEncap": "vlan-100",
"id": "100"
}
}
}
> Configure eth1/1 as Access Interface with VLAN 300
POST http://SWITCH-IP/api/mo/sys/intf/phys-[eth1/1]/.json HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
{
"l1PhysIf": {
"attributes": {
"accessVlan": "vlan-300",
"layer": "Layer2",
"mode": "access"
}
}
}
>Configure trunk interface of VLAN 100 and 200 on interface eth1/1
POST http://SWITCH-IP/api/mo/sys/intf/phys-[eth1/1]/.json HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
{
"l1PhysIf": {
"attributes": {
"layer": "Layer2",
"mode": "trunk",
"trunkVlans": "100,200"
}
}
}
>Delete VLAN 200
DELETE http://SWITCH-IP/api/node/mo/sys/bd/bd-[vlan-100].json HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
from .vlan import Vlan
# Mention vlan id to be created
vlan_id = 40
v = Vlan()
print "Before adding vlan"
print v.show_vlan().get_vlans()
print "\nCreating Vlan with vlan id %s" %vlan_id
v.create_vlan(vlan_id)
print "\nAfter adding vlan"
print v.show_vlan().get_vlans()
print "\nDeleting vlan with vlan id %s" %vlan_id
v.delete_vlan(vlan_id)
print "\nAfter deleting vlan id %s " %vlan_id
print v.show_vlan().get_vlans()
# Configuring vlan
cisco_vlan { "220":
ensure => present,
vlan_name => 'newtest',
shutdown => 'true',
state => 'active',
}
Follow below steps to execute NX-API REST code snippet on nx9000 switch.
On the nx9000 switch perform following operation.
Setup postman Code snippet: In order to execute the the NXAPI from postman the login needs to be performed first. The cookie would get generated and stored for subsequent execution.
POST-URL :
http://SWITCH-IP/api/aaaLogin.json
Content-Type: application/json
Cache-Control: no-cache
POST BODY :
{
"aaaUser" : {
"attributes" : {
"name" : "SWITCH_USER",
"pwd" : "SWITCH_PASSWORD"
}
}
}
Executing NXAPI using postman for first time:
Note: If the cookie gets expired you might have to perform the above steps again.
For subsequent NXAPI call:
Follow following steps to execute the python scripts on Nexus switch.
Following steps would execute the manifest files on nx9000 switch.
Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference.
Save and exit.
Note : If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note : Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver.
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
Steps to add the certificates :
Implement Open Shortest Path First (OSPF) supports IP subnetting and tagging of externally derived routing information. OSPF also allows packet authentication and uses IP multicast when sending and receiving packets. This section describe how you can manage and configure OSPF on a CISCO Nexus 9000 switch using different configuration management code snippet.
NX-API REST script not available
from .ospf import OSPFSession
from .nxcli import NXCLI
import traceback
instance = '49'
interface_name = 'eth1/6'
area = '20'
distance = 41
ospf_cost = 45
hello_interval = 61
dead_interval = 55
priority = 51
def start_ospf_session():
'''
starts ospf session.
Do show run ospf on switch to see the changes.
'''
ospf_session = OSPFSession(instance)
ospf_interface = OSPFSession.OSPFInterface(interface_name, area)
ospf_session.start()
return (ospf_session, ospf_interface)
def shutdown_ospf_session(ospf_session):
ospf_session.shutdown()
def start_ospf_if_down(ospf_session):
if ospf_session.is_shutdown():
start_ospf_session()
def configure_distance(ospf_session):
ospf_session.cfg_distance(distance)
def add_interface_to_ospf(ospf_interface):
ospf_interface.add()
def configure_ospf_cost(ospf_interface):
ospf_interface.cfg_ospf_cost(ospf_cost)
def configure_ospf_hello_interval(ospf_interface):
ospf_interface.cfg_hello_interval(hello_interval)
def configure_dead_interval(ospf_interface):
ospf_interface.cfg_dead_interval(dead_interval)
def configure_priority(ospf_interface):
ospf_interface.cfg_ospf_priority(priority)
def interface_shutdown(ospf_interface):
ospf_interface.shutdown()
def is_interface_available(interface_name):
"""
Checks if interface is available or not.
return True if interface ia available, else returns False
"""
try:
interface = NXCLI('show run interface %s' %interface_name)
return True
except:
return False
def configure_terminal(cmd):
"""
Configure terminal based on the commands given
"""
NXCLI._run_cfg(cmd)
def convert_to_routed_interface(interface_name):
"""
Convert interface mode from access to routed
"""
cmd = "interface %s ; no switchport" %interface_name
configure_terminal(cmd)
def enable_feature_ospf():
"""
Enable feature on switch
"""
cmd = "feature ospf"
configure_terminal(cmd)
def configure_switch_for_ospf():
if not is_interface_available(interface_name):
raise Exception("Interface not available. \nPlease give different interface. To list available interfaces, just go to switch-prompt and type : \nshow int br")
convert_to_routed_interface(interface_name)
enable_feature_ospf()
return start_ospf_session()
def configure_ospf():
'''
Use above mention functions as per requirement.
Sample configuration is shown below.
To check the result of any fucntion after using it here, do a
show run ospf on switch.
'''
try:
#Switch is configured for OSPF. This is basic operation and should not be omitted.
ospf_session, ospf_interface = configure_switch_for_ospf()
#All of the functions below are independent of each other.
configure_distance(ospf_session)
add_interface_to_ospf(ospf_interface)
configure_ospf_cost(ospf_interface)
configure_ospf_hello_interval(ospf_interface)
configure_dead_interval(ospf_interface)
configure_priority(ospf_interface)
print "After ospf configuration:"
NXCLI('show run ospf')
except Exception, e:
traceback.print_exc()
if __name__ == '__main__':
configure_ospf()
# Configuring the interface to routed interface
cisco_interface { "Ethernet1/1" :
switchport_mode => disabled,
}
# Configuring Ospf
cisco_ospf { "Sample":
ensure => present,
}
# Configuring interface ospf
cisco_interface_ospf { "Ethernet1/1 Sample":
ensure => present,
area => "200",
cost => "200",
hello_interval => "default",
dead_interval => "200",
message_digest => true,
message_digest_key_id => 30,
message_digest_algorithm_type => md5,
message_digest_encryption_type => cisco_type_7,
message_digest_password => "046E1803362E595C260E0B240619050A2D",
passive_interface => true,
}
# Configuring ospf vrf
cisco_ospf_vrf { 'dark_blue default':
ensure => 'present',
auto_cost => '45000',
default_metric => '5',
log_adjacency => 'detail',
timer_throttle_lsa_hold => '5500',
timer_throttle_lsa_max => '5600',
timer_throttle_lsa_start => '5',
timer_throttle_spf_hold => '1500',
timer_throttle_spf_max => '5500',
timer_throttle_spf_start => '250',
}
cisco_ospf_vrf { 'dark_blue vrf1':
ensure => 'present',
auto_cost => '46000',
default_metric => '10',
log_adjacency => 'log',
timer_throttle_lsa_hold => '5600',
timer_throttle_lsa_max => '5800',
timer_throttle_lsa_start => '8',
timer_throttle_spf_hold => '1700',
timer_throttle_spf_max => '5700',
timer_throttle_spf_start => '277',
}
Follow following steps to execute the python scripts on Nexus switch.
Following steps would execute the manifest files on nx9000 switch.
Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference.
Save and exit.
Note : If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note : Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
Steps to add the certificates :
Terminal Access Controller Access Control System(TACACS) is an authentication protocol that allows a remote access server to forward a user's logon password to an authentication server to determine whether access can be allowed to a given system. On Nexus 9000 switch TACACS provide a centralized validation of users who are attempting to gain access to a router or network access server. This section describe how you can manage and program TACACS on a CISCO Nexus 9000 switch using different configuration management code snippet.
NX-API REST script not available
from .tacacs import *
tacacsServerIp="10.10.2.1" #TACACS+ server's DNS name or its IP address
port="" #TACACS+ server port
key="" #Global TACACS+ server shared secret
timeout="" #TACACS+ server timeout period in seconds
deleteIp="" #server Ip for removing
# used to remove server configuration
def deleteServer(tacacs,server):
tacacs.add_server(server,no="True")
print "Successfuly deleted configuration of server ",server
def enable_feature_tacacs():
cmd = 'feature tacacs'
configure_terminal(cmd)
def configure_terminal(cmd):
"""
Configure terminal based on the commands given
"""
NXCLI._run_cfg(cmd)
if __name__=="__main__":
enable_feature_tacacs()
#show TACACS Server
showTacacs=ShTacasServer()
print "Before TACACS+ Configuration"
if showTacacs.servers():
print showTacacs.servers()
else:
print "no server configured"
tacacs=Tacacs()
if deleteIp !="" and tacacs._is_server_configured(deleteIp):
#delete server Ip
deleteServer(tacacs,deleteIp)
if tacacsServerIp:
#add th TACACS+ server
tacacs.add_server(tacacsServerIp)
#tacacs.src_interface("Ethernet1/2")
#tacacs.commit()
#tacacs.add_group("ciscogroup1",tacacsServerIp)
showTacacs=ShTacasServer()
print "After TACACS+ Configuration:",showTacacs.servers()
# Configure tacacs server
cisco_tacacs_server {"default":
ensure => present,
timeout => 10,
directed_request => true,
deadtime => 20,
encryption_type => clear,
encryption_password => 'test123',
source_interface => 'Ethernet1/2',
}
Follow following steps to execute the python scripts on Nexus switch.
Following steps would execute the manifest files on nx9000 switch.
Copy the respective manifest script to /etc/puppetlabs/code/environments/production/manifests directory. For example, if you want to configure interface then create manifest file configure_interface.pp using vi editor and paste the respective script in this file.
Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference.
Save and exit.
Note: If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note: Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
Steps to add the certificates:
Access control is the way you control who is allowed access to the network server and what services they are allowed to use once they have access. Authentication, authorization, and accounting (AAA) network security services provide the primary framework through which you set up access control on your router or access server. Following example shows how to enable authentication login ascii-authentication and error-enable.
Configure aaa authentication to show or display of error message on login failures and ascii authentication:
POST http://SWITCH_IP/api/node/mo/sys/userext/authrealm.json HTTP/1.1
Content-Type: application/json
{
"aaaDefaultAuth": {
"attributes": {
"authProtocol": "ascii",
"errEn": "no"
}
}
}
# Sample file to configure AAA authentication login ascii and error-enable
from .nxcli import NXCLI
import traceback
def show_config_info():
"""
Show the running aaa configuration
"""
try:
interface = NXCLI('show run aaa')
return True
except:
return False
def configure_terminal(cmd):
"""
Configure terminal based on the commands given
"""
NXCLI._run_cfg(cmd)
def enable_aaa_ascii_error():
"""
Configure the default aaa authentication login features
"""
cmd = "aaa authentication login ascii-authentication ; aaa authentication login error-enable"
configure_terminal(cmd)
if __name__=="__main__":
try:
enable_aaa_ascii_error()
show_config_info()
except Exception,e:
traceback.print_exc()
Puppet script not available
Follow below steps to execute NX-API REST code snippet on nx9000 switch.
On the nx9000 switch perform following operation.
Setup postman Code snippet: In order to execute NXAPI from postman, login needs to be performed. The cookie would get generated and stored for subsequent execution.
POST-URL : http://SWITCH-IP/api/aaaLogin.json
Content-Type: application/json
Cache-Control: no-cache
POST BODY :
{
"aaaUser" : {
"attributes" : {
"name" : "SWITCH_USER",
"pwd" : "SWITCH_PASSWORD"
}
}
}
Executing NXAPI using postman for first time:
Click send button
Note: If the cookie gets expired, you might have to perform the above steps again.
For subsequent NXAPI call:
How to connect to sandbox lab:
Follow following steps to execute the python scripts on Nexus switch.
The Simple Network Management Protocol (SNMP) is an application-layer protocol that provides a message format for communication between SNMP managers and agents. SNMP provides a standardized framework and a common language used for the monitoring and management of devices in a network. Following example shows snmp community configuration.
NX-API REST script not available
# Sample file to configure snmp community
from .nxcli import NXCLI
import traceback
def config_snmp_community():
"""
Configure the snmp community
"""
try:
cmd = 'snmp-server community test group network-operator ; snmp-server community test use-acl aclname'
NXCLI._run_cfg(cmd)
return True
except:
return False
if __name__=="__main__":
try:
config_snmp_community()
except Exception,e:
traceback.print_exc()
# Configure snmp community
class snmp_community_test {
cisco_snmp_community { "test":
ensure => present,
group => "network-operator",
acl => "aclname",
}
}
class { 'snmp_community_test': }
Follow the following steps to execute the python scripts on Nexus switch.
Following steps would execute the manifest files on nx9000 switch.
Note: If agent hostname is not listed in the certificates in step 7 then we need to add the certificate first. Follow the steps mentioned in "Steps to add the certificates" section.
Note: Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver
Example: toolserver IP: 10.10.10.114
hostname: toolserver-devnet.insieme.local
Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet"
Steps to add the certificates :
Program and manage interfaces. You can configure interfaces using different configuration management tools. Following example shows the details of an interface.
Show physical ethernet port:
GET http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/1].json?query-target=self HTTP/1.1
Host: switch_ip
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: f92aa2b5-ac52-a3ff-60fa-348a69faf3e0
Get Interface statistics:
GET http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/5].json?rsp-subtree=full&rsp-subtree-include=stats HTTP/1.1
Host: switch_ip
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 61080f1e-cd96-5e9c-8797-a6e9936bc7e5
# Sample file to Show Interface details
# Import Interface class
from .interface import Interface
from .nxcli import NXCLI
import traceback
interfaceName = "Ethernet1/6"
def available_interface(interfaceName):
"""
Display interface details.
"""
interface = NXCLI('show interface %s' % interfaceName)
if __name__=="__main__":
try:
available_interface(interfaceName)
except Exception,e:
traceback.print_exc()
Puppet script not available
Follow following steps to execute the nxapi code snippet files on nx9000 switch.
On the nx9000 switch perform following operation.
Setup postman Code snippet: In order to execute the the NXAPI from postman the login needs to be performed first. The cookie would get generated and stored for subsequent execution.
POST-URL : http://SWITCH-IP/api/aaaLogin.json
Content-Type: application/json
Cache-Control: no-cache
POST BODY :
{
"aaaUser" : {
"attributes" : {
"name" : "SWITCH_USER",
"pwd" : "SWITCH_PASSWORD"
}
}
}
Executing NXAPI using postman for first time:
Note: If the cookie gets expired you might have to perform the above steps again.
For subsequent NXAPI call:
Follow following steps to execute the python scripts on Nexus switch.
Program and manage the hardware buffer. Following example shows the internal buffer packet statistics details.
NX-API REST script not available
# Sample file to display the switch hardware buffer info
from .nxcli import NXCLI
import traceback
def show_hardware_buffer():
"""
Show the switch hardware buffer info
"""
try:
interface = NXCLI('show hardware internal buffer info pkt-stats detail')
return True
except:
return False
if __name__=="__main__":
try:
show_hardware_buffer()
except Exception,e:
traceback.print_exc()
Puppet script not available
Follow the following steps to execute the python scripts on Nexus switch.
Ping is a networking utility program or a tool to test if a particular host is reachable. It is a diagnostic that checks if your computer is connected to a server. Ping, a term taken from the echo location of a submarine, sends data packet to a server and if it receives a data packet back, then you have a connection. Following example shows usage of ping in nexus devices.
NX-API REST script not available
# Sample file to troubleshoot using ping
from .nxcli import NXCLI
import traceback
# Fill the details to troubleshoot using ping
host = '172.31.219.60'
count = '4'
vrf = 'management'
def check_ping_ops():
"""
Checks if the host is reachable
"""
try:
interface = NXCLI('ping %s count %s vrf %s' % (host, count, vrf))
return True
except:
return False
if __name__=="__main__":
try:
check_ping_ops()
except Exception,e:
traceback.print_exc()
Puppet script not available
Follow following steps to execute the python scripts on Nexus switch.
Traceroute is a computer network diagnostic tool for displaying the route (path) and measuring transit delays of packets across an Internet Protocol (IP) network. Following example shows the usage of traceroute in nexus devices.
NX-API REST script not available
# Sample file to troubleshoot using traceroute
from .nxcli import NXCLI
import traceback
# Fill the details to troubleshoot using traceroute
host = '172.31.219.60'
vrf = 'management'
def check_traceroute_ops():
"""
traceroute the host
"""
try:
interface = NXCLI('traceroute %s vrf %s' % (host, vrf))
return True
except:
return False
if __name__=="__main__":
try:
check_traceroute_ops()
except Exception,e:
traceback.print_exc()
Puppet script is not available
Follow following steps to execute the python scripts on Nexus switch.