├── Monitoring ├── LLDP │ ├── Description.txt │ └── lldp_python.py ├── users │ ├── Description.txt │ └── users_python.py ├── hardware_buffer │ ├── Description.txt │ └── hardware_buffer_python.py ├── quick_switch_capacity │ ├── Description.txt │ └── quick_switch_capacity_python.py ├── interface │ ├── Description.txt │ ├── interface_nxapi.json │ └── interface_python.py ├── vxlan │ ├── Description.txt │ └── vxlan_python.py ├── tcam │ ├── Description.txt │ └── tcam_python.py ├── sflow │ ├── Description.txt │ └── sflow_python.py ├── VMTracker │ ├── Description.txt │ └── VMtracker_python.py ├── ipsla │ ├── Description.txt │ └── ipsla_python.py ├── rollback │ ├── Description.txt │ └── rollback_python.py ├── acl │ ├── Description.txt │ └── acl_python.py ├── sandbox_python.txt └── sandbox_nxapi.txt ├── Troubleshooting ├── Ping │ └── python │ │ ├── sandbox.txt │ │ └── script.txt └── Traceroute │ └── python │ ├── script.txt │ └── sandbox.txt ├── Configuration ├── VLAN │ ├── vlan_puppet.pp │ ├── vlan_ansible.yml │ ├── vlan_python.py │ ├── Description.txt │ └── vlan_nxapi.json ├── interface │ ├── Description.txt │ ├── interface_ansible.yml │ ├── interface_puppet.pp │ ├── interface_nxapi.json │ └── interface_python.py ├── snmp │ ├── snmp_puppet.pp │ ├── Description.txt │ ├── snmp_python.py │ └── snmp_ansible.yml ├── TACACS │ ├── tacacs_ansible.yml │ ├── tacacs_puppet.pp │ ├── tacacs_nxapi.json │ ├── Description.txt │ └── tacacs_python.py ├── OSPF │ ├── Description.txt │ ├── ospf_puppet.pp │ └── ospf_python.py ├── AAA │ ├── aaa_nxapi.json │ ├── Description.txt │ └── aaa_python.py ├── sandbox-python.txt ├── sandbox-ansible.txt ├── sandbox-nxapi.txt └── sandbox-puppet.txt ├── SandBoxSteps.txt ├── Introduction.txt └── README.md /Monitoring/LLDP/Description.txt: -------------------------------------------------------------------------------- 1 | Displays the LLDP neighbour device status. 2 | -------------------------------------------------------------------------------- /Monitoring/users/Description.txt: -------------------------------------------------------------------------------- 1 | This section monitors the SSH and telnet connections for a particular switch. 2 | -------------------------------------------------------------------------------- /Monitoring/hardware_buffer/Description.txt: -------------------------------------------------------------------------------- 1 | Monitors the egress or ingress per-port per-queue occupancy in the running system 2 | -------------------------------------------------------------------------------- /Troubleshooting/Ping/python/sandbox.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datacenter/nxos-examples/HEAD/Troubleshooting/Ping/python/sandbox.txt -------------------------------------------------------------------------------- /Monitoring/quick_switch_capacity/Description.txt: -------------------------------------------------------------------------------- 1 | This section gives report details of MAC address table, size of ACL TCAM region and port channel usage. 2 | -------------------------------------------------------------------------------- /Configuration/VLAN/vlan_puppet.pp: -------------------------------------------------------------------------------- 1 | #Configuring vlan 2 | cisco_vlan { "220": 3 | ensure => present, 4 | vlan_name => 'newtest', 5 | shutdown => 'true', 6 | state => 'active', 7 | } 8 | -------------------------------------------------------------------------------- /Configuration/interface/Description.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | -------------------------------------------------------------------------------- /Monitoring/interface/Description.txt: -------------------------------------------------------------------------------- 1 | Program and manage interfaces. You can configure interfaces using different configuration management tools. 2 | Following example shows how to display Nexus 9000 interfaces, bring the interfaces up or down, configure IP address. 3 | -------------------------------------------------------------------------------- /Configuration/snmp/snmp_puppet.pp: -------------------------------------------------------------------------------- 1 | # Configure snmp community 2 | 3 | class snmp_community_test { 4 | 5 | cisco_snmp_community { "test": 6 | ensure => present, 7 | group => "network-operator", 8 | acl => "aclname", 9 | } 10 | 11 | } 12 | 13 | class { 'snmp_community_test': } -------------------------------------------------------------------------------- /Monitoring/vxlan/Description.txt: -------------------------------------------------------------------------------- 1 | VXLAN provides a solution to extend Layer 2 networks across Layer 3 infrastructure by way of MAC-in-UDP encapsulation and tunneling. 2 | The pre requisite for this section is to have leaf-spine architecture with VXLAN configured. 3 | This section is monitoring the NVE interface and VNI details. 4 | 5 | -------------------------------------------------------------------------------- /Configuration/TACACS/tacacs_ansible.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: aaa server example 4 | hosts: n9kvswitchfcs 5 | 6 | tasks: 7 | 8 | # Tacacs Server Basic settings 9 | - name: "Tacacs Server Basic settings" 10 | nxos_aaa_server: server_type=tacacs timeout=8 deadtime=19 directed_request=disabled host={{ inventory_hostname }} 11 | -------------------------------------------------------------------------------- /Monitoring/tcam/Description.txt: -------------------------------------------------------------------------------- 1 | Ternary Content Addressable Memory. This is the space in hardware where access-lists (ACLs) are stored. 2 | This is a specialized piece of memory that stores complex tabular data and supports very rapid parallel lookups. 3 | This section monitors current utilization of each configured TCAM region, hardware and software configuration. 4 | -------------------------------------------------------------------------------- /Configuration/snmp/Description.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | -------------------------------------------------------------------------------- /Monitoring/sflow/Description.txt: -------------------------------------------------------------------------------- 1 | Sampled flow (sFlow) allows you to monitor real-time traffic in data networks that contain switches and routers. 2 | It uses the sampling mechanism in the sFlow agent software on switches and routers to monitor traffic and to forward the sample data to the central data collector. 3 | This section monitors sflow statistics and sflow configuration. 4 | -------------------------------------------------------------------------------- /Configuration/TACACS/tacacs_puppet.pp: -------------------------------------------------------------------------------- 1 | #Configure tacacs server 2 | cisco_tacacs_server {"default": 3 | ensure => present, 4 | timeout => 10, 5 | directed_request => true, 6 | deadtime => 20, 7 | encryption_type => clear, 8 | encryption_password => 'test123', 9 | source_interface => 'Ethernet1/2', 10 | } 11 | -------------------------------------------------------------------------------- /Monitoring/VMTracker/Description.txt: -------------------------------------------------------------------------------- 1 | Virtual Machine Tracker along with VMware Vcenter enables to track the movement of VMs from one host (ESXi) to another, VM configuration changes such as additions, deletions, 2 | or modifications of VLANs, and configure VLANs on Cisco Nexus 9000 Series ports accordingly. 3 | This section configures VM connection and monitors status of connection and details. 4 | -------------------------------------------------------------------------------- /Configuration/OSPF/Description.txt: -------------------------------------------------------------------------------- 1 | Implement Open Shortest Path First (OSPF). 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. 2 | -------------------------------------------------------------------------------- /Configuration/TACACS/tacacs_nxapi.json: -------------------------------------------------------------------------------- 1 | #Configure tacacs server 2 | POST URL: http://SWITCH_IP/api/node/mo/sys/userext/tacacsext.json 3 | Content-Type: application/json 4 | Cache-Control: no-cache 5 | POST BODY : 6 | { 7 | "aaaTacacsPlusEp": { 8 | "attributes": { 9 | "timeout": "20", 10 | "deadtime": "10", 11 | "keyEnc": "7", 12 | "key": "cisco", 13 | "srcIf": "mgmt 0" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Configuration/AAA/aaa_nxapi.json: -------------------------------------------------------------------------------- 1 | #Configure aaa authentication to show or display of error message on login failures and ascii authentication 2 | 3 | POST URL: http://SWITCH_IP/api/node/mo/sys/userext/authrealm.json 4 | Content-Type: application/json 5 | 6 | POST BODY : 7 | { 8 | "aaaDefaultAuth": { 9 | "attributes": { 10 | "authProtocol": "ascii", 11 | "errEn": "no" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Monitoring/ipsla/Description.txt: -------------------------------------------------------------------------------- 1 | IP Service Level Agreements (SLAs) allow you to manage IP service levels for IP applications and services. 2 | Cisco NX-OS IP SLAs performs active monitoring by generating and analyzing traffic to measure performance either between Cisco NX-OS devices or from a Cisco NX-OS device to a remote IP device such as a network application server. 3 | This section monitors IP SLA configuration, application and statistics. 4 | -------------------------------------------------------------------------------- /Configuration/AAA/Description.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | -------------------------------------------------------------------------------- /Monitoring/rollback/Description.txt: -------------------------------------------------------------------------------- 1 | The rollback feature allows you to take a snapshot, or user checkpoint, of the Cisco NX-OS configuration and then reapply that configuration to your device at any point without 2 | having to reload the device. A rollback allows any authorized administrator to apply this checkpoint configuration without requiring expert knowledge of the features configured in the 3 | checkpoint. 4 | This section creates a checkpoint , then rollsback the configuration to the checkpoint. 5 | -------------------------------------------------------------------------------- /Monitoring/acl/Description.txt: -------------------------------------------------------------------------------- 1 | Cisco provides basic traffic filtering capabilities with access control lists (also referred to as access lists). 2 | Access lists can be configured for all routed network protocols (IP, AppleTalk, and so on) to filter the packets of those protocols as the packets pass through a router. 3 | A time range is created that defines specific times of the day and week in order to implement time-based ACLs. 4 | This section configures ACL with a time range and applies it to an interface and monitor the ACL on Cisco Nexus 9000. 5 | -------------------------------------------------------------------------------- /Configuration/VLAN/vlan_ansible.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: vlan testing 4 | hosts: n9kvswitchfcs 5 | 6 | tasks: 7 | - name: config VLANs names for a few VLANs 8 | nxos_vlan: vlan_id={{ item.vid }} name={{ item.name }} host={{ inventory_hostname }} state=present 9 | with_items: 10 | - { vid: 10, name: web } 11 | - { vid: 20, name: app } 12 | 13 | - name: ensure VLAN 30 exists with the name WEB and is in the shutdown state 14 | nxos_vlan: vlan_id=30 host={{ inventory_hostname }} admin_state=down name=WEB 15 | -------------------------------------------------------------------------------- /Configuration/VLAN/vlan_python.py: -------------------------------------------------------------------------------- 1 | from .vlan import Vlan 2 | 3 | #Mention vlan id to be created 4 | vlan_id = 40 5 | 6 | v = Vlan() 7 | print "Before adding vlan" 8 | print v.show_vlan().get_vlans() 9 | 10 | print "\nCreating Vlan with vlan id %s" %vlan_id 11 | v.create_vlan(vlan_id) 12 | 13 | print "\nAfter adding vlan" 14 | print v.show_vlan().get_vlans() 15 | 16 | print "\nDeleting vlan with vlan id %s" %vlan_id 17 | v.delete_vlan(vlan_id) 18 | 19 | print "\nAfter deleting vlan id %s " %vlan_id 20 | print v.show_vlan().get_vlans() 21 | 22 | -------------------------------------------------------------------------------- /Configuration/TACACS/Description.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | -------------------------------------------------------------------------------- /Monitoring/interface/interface_nxapi.json: -------------------------------------------------------------------------------- 1 | #Show pysical ethernet port 2 | GET http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/1].json?query-target=self 3 | Host: switch_ip 4 | Content-Type: application/json 5 | Cache-Control: no-cache 6 | Postman-Token: f92aa2b5-ac52-a3ff-60fa-348a69faf3e0 7 | 8 | #Get Interface statistics 9 | GET http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/5].json?rsp-subtree=full&rsp-subtree-include=stats 10 | Host: switch_ip 11 | Content-Type: application/json 12 | Cache-Control: no-cache 13 | Postman-Token: 61080f1e-cd96-5e9c-8797-a6e9936bc7e5 14 | -------------------------------------------------------------------------------- /Monitoring/interface/interface_python.py: -------------------------------------------------------------------------------- 1 | #Sample file to Show Interface details 2 | #Import Interface class 3 | from .interface import Interface 4 | from .nxcli import NXCLI 5 | import traceback 6 | 7 | interfaceName = "Ethernet1/6" 8 | 9 | def available_interface(interfaceName): 10 | """ 11 | Display interface details. 12 | """ 13 | interface = NXCLI('show interface %s' % interfaceName) 14 | 15 | 16 | if __name__=="__main__": 17 | try: 18 | available_interface(interfaceName) 19 | except Exception,e: 20 | traceback.print_exc() 21 | -------------------------------------------------------------------------------- /SandBoxSteps.txt: -------------------------------------------------------------------------------- 1 | How to connect to sandbox lab: 2 | 3 | 1. Go to the sandbox homepage: https://developer.cisco.com/site/devnet/sandbox/ 4 | 2. Login. Hit the yellow button “Go To the Labs” button 5 | 3. In the upper-right corner click on “DEVNET”. 6 | 4. Now you are in Cisco's Devnet domain and it would list the labs hosted under the domain. 7 | 5. You can find the 8 tiles for the NX-OS labs. The tiles are named as "Open NX-OS Lab -1(through 8)" 8 | 6. Click on 'Reserve' a lab. Upon successful reservation you would receive a mail from "devnetsandbox@cisco.com" that describes further instructions to access the sandbox. 9 | -------------------------------------------------------------------------------- /Configuration/VLAN/Description.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | -------------------------------------------------------------------------------- /Monitoring/LLDP/lldp_python.py: -------------------------------------------------------------------------------- 1 | # Sample file to display lldp neighbors details 2 | 3 | # Import Interface class 4 | from .nxcli import NXCLI 5 | import traceback 6 | 7 | def available_interface(): 8 | """ 9 | Display lldp neighbors details. 10 | """ 11 | try: 12 | resp = NXCLI('show lldp neighbors') 13 | return True 14 | except Exception as e: 15 | return False 16 | 17 | if __name__=="__main__": 18 | try: 19 | available_interface() 20 | except Exception,e: 21 | traceback.print_exc() 22 | -------------------------------------------------------------------------------- /Monitoring/hardware_buffer/hardware_buffer_python.py: -------------------------------------------------------------------------------- 1 | #Sample file to display the switch hardware buffer info 2 | 3 | from .nxcli import NXCLI 4 | import traceback 5 | 6 | def show_hardware_buffer(): 7 | """ 8 | Show the switch hardware buffer info 9 | """ 10 | try: 11 | interface = NXCLI('show hardware internal buffer info pkt-stats detail') 12 | return True 13 | except: 14 | return False 15 | 16 | if __name__=="__main__": 17 | 18 | try: 19 | show_hardware_buffer() 20 | except Exception,e: 21 | traceback.print_exc() 22 | -------------------------------------------------------------------------------- /Configuration/snmp/snmp_python.py: -------------------------------------------------------------------------------- 1 | # Sample file to configure snmp community 2 | 3 | from .nxcli import NXCLI 4 | import traceback 5 | 6 | def config_snmp_community(): 7 | """ 8 | Configure the snmp community 9 | """ 10 | try: 11 | cmd = 'snmp-server community test group network-operator ; snmp-server community test use-acl aclname' 12 | NXCLI._run_cfg(cmd) 13 | return True 14 | except: 15 | return False 16 | 17 | 18 | if __name__=="__main__": 19 | 20 | try: 21 | config_snmp_community() 22 | except Exception,e: 23 | traceback.print_exc() 24 | -------------------------------------------------------------------------------- /Troubleshooting/Traceroute/python/script.txt: -------------------------------------------------------------------------------- 1 | #Sample file to troubleshoot using traceroute 2 | 3 | from .nxcli import NXCLI 4 | import traceback 5 | 6 | # Fill the details to troubleshoot using traceroute 7 | host = '172.31.219.60' 8 | vrf = 'management' 9 | 10 | def check_traceroute_ops(): 11 | """ 12 | traceroute the host 13 | """ 14 | try: 15 | interface = NXCLI('traceroute %s vrf %s' % (host, vrf)) 16 | return True 17 | except: 18 | return False 19 | 20 | if __name__=="__main__": 21 | 22 | try: 23 | check_traceroute_ops() 24 | except Exception,e: 25 | traceback.print_exc() 26 | -------------------------------------------------------------------------------- /Troubleshooting/Ping/python/script.txt: -------------------------------------------------------------------------------- 1 | #Sample file to troubleshoot using ping 2 | 3 | from .nxcli import NXCLI 4 | import traceback 5 | 6 | # Fill the details to troubleshoot using ping 7 | host = '172.31.219.60' 8 | count = '4' 9 | vrf = 'management' 10 | 11 | 12 | def check_ping_ops(): 13 | """ 14 | Checks if the host is reachable 15 | """ 16 | try: 17 | interface = NXCLI('ping %s count %s vrf %s' % (host, count, vrf)) 18 | return True 19 | except: 20 | return False 21 | 22 | if __name__=="__main__": 23 | 24 | try: 25 | check_ping_ops() 26 | except Exception,e: 27 | traceback.print_exc() 28 | -------------------------------------------------------------------------------- /Configuration/interface/interface_ansible.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: sample playbook for interface 4 | hosts: n9kvswitchfcs 5 | 6 | tasks: 7 | 8 | - name: default interfaces 9 | nxos_interface: interface={{ item }} state=default host={{ inventory_hostname }} 10 | with_items: 11 | - Ethernet1/6 12 | - Ethernet1/7 13 | 14 | # Ensure an interface is a Layer 3 port and that it has the proper description 15 | - name: config interface 16 | nxos_interface: interface=Ethernet1/6 description='Configured by Ansible' mode=layer3 host={{ inventory_hostname }} 17 | 18 | # Admin down an interface 19 | - nxos_interface: interface=Ethernet1/7 admin_state=down host={{ inventory_hostname }} 20 | -------------------------------------------------------------------------------- /Configuration/interface/interface_puppet.pp: -------------------------------------------------------------------------------- 1 | #Configuring Interface eth1/1 2 | cisco_interface { "Ethernet1/1" : 3 | shutdown => true, 4 | switchport_mode => disabled, 5 | description => 'managed by puppet', 6 | ipv4_address => '1.1.43.43', 7 | ipv4_netmask_length => 24, 8 | } 9 | #Configuring interface eth1/2 10 | cisco_interface { "Ethernet1/2" : 11 | description => 'default', 12 | shutdown => 'default', 13 | access_vlan => 'default', 14 | switchport_mode => access, 15 | } 16 | #Configuring interface 17 | cisco_interface { "Vlan22" : 18 | svi_autostate => false, 19 | svi_management => true, 20 | } 21 | -------------------------------------------------------------------------------- /Monitoring/sandbox_python.txt: -------------------------------------------------------------------------------- 1 | Follow following steps to execute the python scripts on Nexus switch. 2 | 3 | 1. Login to switch using provided credentials. Example username is ‘admin’ and password ‘cisco123’. 4 | 2. If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell' 5 | 3. Run ‘run bash’ to go to bash shell. 6 | 4. Run sudo su 7 | 5. Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage ACL 8 | configuration using python, create test_.py using vi editor like this: 9 | vi test_acl.py 10 | 6. Now copy the script to this file. Save and exit. 11 | 7. Execute following command to run the script '/isan/bin/python –m cisco.test_' 12 | 8. The format of the command to be executed is, '/isan/bin/python -m' 13 | -------------------------------------------------------------------------------- /Configuration/sandbox-python.txt: -------------------------------------------------------------------------------- 1 | Follow following steps to execute the python scripts on Nexus switch. 2 | 3 | 1. Login to switch using provided credentials. Example username is ‘admin’ and password ‘cisco123’. 4 | 2. If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell' 5 | 3. Run ‘run bash’ to go to bash shell. 6 | 4. Run sudo su 7 | 5. Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage AAA 8 | configuration using python, create test_.py using vi editor like this: 9 | vi test_.py 10 | 6. Now copy the script to this file. Save and exit. 11 | 7. Execute following command to run the script '/isan/bin/python –m cisco.test_ 12 | 8. The format of the command to be executed is, '/isan/bin/python -m' 13 | -------------------------------------------------------------------------------- /Troubleshooting/Traceroute/python/sandbox.txt: -------------------------------------------------------------------------------- 1 | Follow following steps to execute the python scripts on Nexus switch. 2 | 3 | 1. Login to switch using provided credentials. Example username is ‘admin’ and password ‘cisco123’. 4 | 2. If bash is not enabled, Goto 'config t' and enable it by running 'feature bash-shell' 5 | 3. Run ‘run bash’ to go to bash shell. 6 | 4. Run sudo su 7 | 5. Copy the required script to /isan/python/scripts/cisco directory. For example, if you want to manage Traceroute 8 | configuration using python, create test_traceroute.py using vi editor like this: 9 | vi test_traceroute.py 10 | 6. Now copy the script to this file. Save and exit. 11 | 7. Execute following command to run the script '/isan/bin/python –m cisco.test_traceroute 12 | 8. The format of the command to be executed is, '/isan/bin/python -m' 13 | -------------------------------------------------------------------------------- /Configuration/snmp/snmp_ansible.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: snmp configuration 3 | hosts: n9kvswitchfcs 4 | connection: local 5 | gather_facts: no 6 | 7 | tasks: 8 | 9 | - name: create snmp community with group 10 | nxos_snmp_community: community=test group="network-operator" host={{ inventory_hostname }} 11 | register: data 12 | 13 | - name: delete snmp community with group 14 | nxos_snmp_community: community=test group="network-operator" state=absent host={{ inventory_hostname }} 15 | register: data 16 | 17 | - name: create snmp user with auth parameters 18 | nxos_snmp_user: user=user1 group="network-operator" auth=md5 pwd=cisco123 privacy=cisco321 host={{ inventory_hostname }} 19 | register: data 20 | 21 | - name: delete snmp user with auth parameters 22 | nxos_snmp_user: user=user1 group="network-operator" auth=md5 pwd=cisco123 privacy=cisco321 state=absent host={{ inventory_hostname }} 23 | register: data 24 | -------------------------------------------------------------------------------- /Introduction.txt: -------------------------------------------------------------------------------- 1 | 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 automate and program Nexus devices, including – NX-API REST (brings Model Driven Programmability (MDP) to standalone, Python, Puppet, Chef, Ansible etc. 2 |
3 |
4 | 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. 5 |
6 |
7 | In addition to code snippets, we are happy to provide users with access to Cisco’s DevNet lab resources. Instructions on accessing DevNet Labs and instructions to run the script are provided in “DevNet Lab Info” and “Sandbox” tabs respectively. 8 | -------------------------------------------------------------------------------- /Configuration/interface/interface_nxapi.json: -------------------------------------------------------------------------------- 1 | 2 | #Configure physical ethernet port for various interface properties on eth1/1 3 | POST URL: http://SWITCH_IP/api/mo/sys/intf/phys-[eth1/1].json?query-target=self 4 | Content-Type: application/json 5 | Cache-Control: no-cache 6 | POST BODY : 7 | { 8 | "l1PhysIf": { 9 | "attributes": { 10 | "accessVlan": "vlan-321", 11 | "adminSt": "down", 12 | "bw": "0", 13 | "childAction": "", 14 | "delay": "1", 15 | "descr": "Sample test", 16 | "duplex": "auto", 17 | "id": "eth1/1", 18 | "layer": "Layer2", 19 | "lcOwn": "local", 20 | "linkDebounce": "100", 21 | "mdix": "auto", 22 | "mode": "access", 23 | "mtu": "1500", 24 | "portT": "leaf", 25 | "snmpTrapSt": "enable", 26 | "speed": "auto", 27 | "trunkLog": "default", 28 | "trunkVlans": "1-4094" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nxos-examples 2 | 3 | # Description 4 | 5 | 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 automate and program Nexus devices, including – NX-API REST (brings Model Driven Programmability (MDP) to standalone, Python, Puppet, Chef, Ansible etc. 6 | 7 | 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. 8 | 9 | In addition to code snippets, we are happy to provide users with access to Cisco’s DevNet lab resources. Instructions on accessing DevNet Labs and instructions to run the script are provided in “DevNet Lab Info” and “Sandbox” tabs respectively. 10 | -------------------------------------------------------------------------------- /Configuration/AAA/aaa_python.py: -------------------------------------------------------------------------------- 1 | #Sample file to configure AAA authentication login ascii and error-enable 2 | 3 | from .nxcli import NXCLI 4 | import traceback 5 | 6 | def show_config_info(): 7 | """ 8 | Show the running aaa configuration 9 | """ 10 | 11 | try: 12 | interface = NXCLI('show run aaa') 13 | return True 14 | except: 15 | return False 16 | 17 | def configure_terminal(cmd): 18 | """ 19 | Configure terminal based on the commands given 20 | """ 21 | 22 | NXCLI._run_cfg(cmd) 23 | 24 | def enable_aaa_ascii_error(): 25 | """ 26 | Configure the default aaa authentication login features 27 | """ 28 | 29 | cmd = "aaa authentication login ascii-authentication ; aaa authentication login error-enable" 30 | configure_terminal(cmd) 31 | 32 | if __name__=="__main__": 33 | 34 | try: 35 | enable_aaa_ascii_error() 36 | show_config_info() 37 | except Exception,e: 38 | traceback.print_exc() 39 | -------------------------------------------------------------------------------- /Configuration/VLAN/vlan_nxapi.json: -------------------------------------------------------------------------------- 1 | #Create VLAN 100 2 | 3 | POST URL: http://SWITCH-IP/api/node/mo/sys/bd/bd-[vlan-100].json 4 | Content-Type: application/json 5 | Cache-Control: no-cache 6 | POST-BODY: 7 | { 8 | "l2BD": { 9 | "attributes": { 10 | "fabEncap": "vlan-100", 11 | "id": "100" 12 | } 13 | } 14 | } 15 | 16 | #Configure eth1/1 as Access Interface with VLAN 300 17 | 18 | POST URL: http://SWITCH-IP/api/mo/sys/intf/phys-[eth1/1]/.json 19 | Content-Type: application/json 20 | Cache-Control: no-cache 21 | POST-BODY: 22 | { 23 | "l1PhysIf": { 24 | "attributes": { 25 | "accessVlan": "vlan-300", 26 | "layer": "Layer2", 27 | "mode": "access" 28 | } 29 | } 30 | } 31 | 32 | #Configure trunk interface of VLAN 100 and 200 on interface eth1/1 33 | 34 | POST URL: http://SWITCH-IP/api/mo/sys/intf/phys-[eth1/1]/.json 35 | Content-Type: application/json 36 | Cache-Control: no-cache 37 | POST-BODY: 38 | { 39 | "l1PhysIf": { 40 | "attributes": { 41 | "layer": "Layer2", 42 | "mode": "trunk", 43 | "trunkVlans": "100,200" 44 | } 45 | } 46 | } 47 | 48 | #Delete VLAN 200 49 | 50 | DELETE URL: http://SWITCH-IP/api/node/mo/sys/bd/bd-[vlan-100].json 51 | Content-Type: application/json 52 | Cache-Control: no-cache 53 | -------------------------------------------------------------------------------- /Monitoring/rollback/rollback_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | 3 | checkpointName = 'sample' 4 | 5 | class ShowRollbackDiff(NXCLI): 6 | def __init__ (self, name): 7 | super(ShowRollbackDiff, self).__init__('show diff rollback-patch checkpoint %s running-config' % name) 8 | 9 | def configure_terminal(cmd): 10 | """ 11 | Configure terminal based on the commands given 12 | """ 13 | NXCLI._run_cfg(cmd) 14 | 15 | def main(): 16 | """ 17 | Configure checkpoint 18 | """ 19 | NXCLI._run_cfg('checkpoint %s' % checkpointName) 20 | 21 | # Make some configuration changes 22 | configure_terminal('feature vmtracker') 23 | 24 | checkpoint = ShowRollbackDiff(checkpointName) 25 | 26 | # Show the difference between running-config and checkpoint 27 | configure_terminal('show diff rollback-patch checkpoint %s running-config' %checkpointName) 28 | 29 | # Unconfiguring checkpoint 30 | configure_terminal('no checkpoint %s' %checkpointName) 31 | 32 | # Unconfigure the changes done 33 | configure_terminal('no feature vmtracker') 34 | 35 | if __name__=="__main__": 36 | main() 37 | 38 | -------------------------------------------------------------------------------- /Monitoring/users/users_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | def main(): 5 | """ 6 | Monitor SSH & Telnet details 7 | """ 8 | cli = NXCLI('show users', do_print=True) 9 | print "\nShow users" 10 | print "===============" 11 | pids = {} 12 | lines = cli.raw_output.split('\n') 13 | for line in lines: 14 | user_line = re.search(r'([a-zA-Z0-9]+)(\s+)([a-zA-Z0-9/]+)(\s+)([0-9-]+)(\s+)([0-9:]+)(\s+)([0-9:.]+)(\s+)([0-9]+)(\s+)(.*)', line) 15 | if user_line: 16 | pid = user_line.group(11) 17 | pids[pid] = {} 18 | pids[pid]['name'] = user_line.group(1) 19 | pids[pid]['line'] = user_line.group(3) 20 | pids[pid]['time'] = user_line.group(5) + user_line.group(7) 21 | pids[pid]['idle'] = user_line.group(9) 22 | pids[pid]['comment'] = user_line.group(13) 23 | 24 | template = '{0:10} {1:10} {2:20} {3:10} {4:10} {5:20}' 25 | print template.format("NAME", "LINE", "TIME", "IDLE", "PID", "COMMENT") 26 | print template.format("=========", "=========", "=========", "=========", "=========", "=========") 27 | for pid in pids: 28 | print template.format(pids[pid]['name'], pids[pid]['line'], pids[pid]['time'], pids[pid]['idle'], pid, pids[pid]['comment']) 29 | 30 | 31 | if __name__=="__main__": 32 | main() 33 | 34 | 35 | -------------------------------------------------------------------------------- /Configuration/OSPF/ospf_puppet.pp: -------------------------------------------------------------------------------- 1 | # Configuring the interface to routed interface 2 | cisco_interface { "Ethernet1/1" : 3 | switchport_mode => disabled, 4 | } 5 | 6 | #Configuring Ospf 7 | cisco_ospf { "Sample": 8 | ensure => present, 9 | } 10 | 11 | #Configuring interface ospf 12 | cisco_interface_ospf { "Ethernet1/1 Sample": 13 | ensure => present, 14 | area => "200", 15 | cost => "200", 16 | hello_interval => "default", 17 | dead_interval => "200", 18 | message_digest => true, 19 | message_digest_key_id => 30, 20 | message_digest_algorithm_type => md5, 21 | message_digest_encryption_type => cisco_type_7, 22 | message_digest_password => "046E1803362E595C260E0B240619050A2D", 23 | passive_interface => true, 24 | } 25 | 26 | #Configuring ospf vrf 27 | cisco_ospf_vrf { 'dark_blue default': 28 | ensure => 'present', 29 | auto_cost => '45000', 30 | default_metric => '5', 31 | log_adjacency => 'detail', 32 | timer_throttle_lsa_hold => '5500', 33 | timer_throttle_lsa_max => '5600', 34 | timer_throttle_lsa_start => '5', 35 | timer_throttle_spf_hold => '1500', 36 | timer_throttle_spf_max => '5500', 37 | timer_throttle_spf_start => '250', 38 | } 39 | 40 | cisco_ospf_vrf { 'dark_blue vrf1': 41 | ensure => 'present', 42 | auto_cost => '46000', 43 | default_metric => '10', 44 | log_adjacency => 'log', 45 | timer_throttle_lsa_hold => '5600', 46 | timer_throttle_lsa_max => '5800', 47 | timer_throttle_lsa_start => '8', 48 | timer_throttle_spf_hold => '1700', 49 | timer_throttle_spf_max => '5700', 50 | timer_throttle_spf_start => '277', 51 | } 52 | -------------------------------------------------------------------------------- /Configuration/sandbox-ansible.txt: -------------------------------------------------------------------------------- 1 | Following steps would execute the playbook files on nx9000 switch. 2 | 3 | 1. SSH to toolserver host using provided credentials. (If credentials are not provided Default username is ‘cisco’ and password ‘cisco123’) 4 | 5 | 2. Edit the .netauth file to add the credentials of the switches. (Default username is 'cisco' and password is 'cisco123') 6 | Example: 7 | vi .netauth (do it under /home/USER directory. Here USER is cisco) 8 | cisco: 9 | nexus: 10 | username: "admin" 11 | password: "cisco123" 12 | 13 | 3. Go to /home/cisco/nxos-ansible directory. Edit hosts file and add the list of hosts / device names under switches section. 14 | Note: device or host names must be added in /etc/hosts file 15 | 16 | Example: vi hosts under /home/cisco/nxos-ansible. Then add below contents 17 | [all:vars] 18 | ansible_connection = local 19 | [switches] 20 | n9kvswitchfcs 21 | 22 | Note: Make sure "n9kvswitchfcs" name is added in /etc/hosts and /etc/hosts should contain "SWITCH_IP n9kvswitchfcs". Replace the IP of the switch with SWITCH_IP 23 | 24 | 4. Copy the respective playbook scripts to /home/USER/nxos-ansible/test-playbooks directory (replace the username with USER). Supppose you want to configure interface, then create a .yml file using vi editor and paste the playbook scripts to it. 25 | 26 | 5. Save and exit 27 | 28 | 6. Run "ansible-playbook -i hosts test-playbooks/PLAYBOOK_FILE_NAME.yml" 29 | Example: 30 | $ ansible-playbook -i hosts test-playbooks/interface.yml 31 | 32 | 7. Go to switch prompt and run 'copy r s' 33 | -------------------------------------------------------------------------------- /Monitoring/tcam/tcam_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | 5 | def main(): 6 | cli = NXCLI('show hardware access-list tcam region', do_print=False) 7 | print "\nShow hardware access-list tcam region" 8 | print "=======================================" 9 | names = [] 10 | sizes = [] 11 | out = cli.raw_output.split('\n') 12 | for line in out: 13 | tcamLine = re.search(r'TCAM Region Sizes:(\s+)(.*)', line) 14 | if tcamLine: 15 | total_tcam_region = tcamLine.group(2) 16 | print 'TCAM Region Sizes: ', total_tcam_region 17 | 18 | tcamSize = re.search(r'(\s+)(.*)(\s+)size(\s+)=(\s+)(.*)', line) 19 | if tcamSize: 20 | names.append(tcamSize.group(2)) 21 | sizes.append(tcamSize.group(6)) 22 | 23 | template = "{0:40} {1:10}" 24 | print template.format("Name", "Size") 25 | print template.format("=======", "=========") 26 | for name, size in zip(names, sizes): 27 | print template.format(name, size) 28 | 29 | print "\nShow hardware access-list resource utilization" 30 | print "=======================================" 31 | cli = NXCLI('show hardware access-list resource utilization', do_print=True) 32 | 33 | print "\nShow show system internal access-list global" 34 | print "=======================================" 35 | cli = NXCLI('show system internal access-list global', do_print=True) 36 | 37 | 38 | if __name__ == '__main__': 39 | main() 40 | -------------------------------------------------------------------------------- /Monitoring/sandbox_nxapi.txt: -------------------------------------------------------------------------------- 1 | Follow following steps to execute the nxapi code snippet files on nx9000 switch. 2 | 3 | On the nx9000 switch perform following operation. 4 | 1. SSH to switch using provided credentials. (If credentials are not provided Default username is ‘admin’ and 5 | password ‘cisco123’ 6 | 2. Run 'config t' on the switch prompt. 7 | 3. Enable nxapi by running ‘feature nxapi’. 8 | 4. Exit to switch prompt by running 'exit'. 9 | 5. Run 'Copy r s' to save the configuration. 10 | 11 | Setup postman Code snippet: 12 | In order to execute the the NXAPI from postman the login needs to be performed first. The cookie would get generated 13 | and stored for subsequent execution. 14 | 15 | POST-URL : http://SWITCH-IP/api/aaaLogin.json 16 | Content-Type: application/json 17 | Cache-Control: no-cache 18 | POST BODY : 19 | { 20 | "aaaUser" : { 21 | "attributes" : { 22 | "name" : "SWITCH_USER", 23 | "pwd" : "SWITCH_PASSWORD" 24 | } 25 | } 26 | } 27 | 28 | Executing NXAPI using postman for first time: 29 | 30 | 1. Copy POST URL, mentioned in 'setup postman' section above, after replacing SWITCH-IP with IP address of Nexus 31 | switch . 32 | 2. Select method as POST 33 | 3. Open raw JSON section. 34 | 4. Copy POST-BODY JSON to raw JSON body section of postman. 35 | 5. Replace SWITCH_USERNAME with switch user. 36 | 6. Replace SWITCH_PASSWORD with switch password. 37 | 7. Click send button 38 | 39 | Note: If the cookie gets expired you might have to perform the above steps again. 40 | 41 | For subsequent NXAPI call: 42 | 43 | 1. Copy POST URL, after replacing SWITCH-IP with IP address of Nexus switch. 44 | 2. Select method as POST 45 | 3. Open raw JSON section. 46 | 4. Copy POST-BODY JSON to raw JSON body section of postman. 47 | 5. Click send button 48 | -------------------------------------------------------------------------------- /Configuration/TACACS/tacacs_python.py: -------------------------------------------------------------------------------- 1 | from .tacacs import * 2 | 3 | tacacsServerIp="10.10.2.1" #TACACS+ server's DNS name or its IP address 4 | port="" #TACACS+ server port 5 | key="" #Global TACACS+ server shared secret 6 | timeout="" #TACACS+ server timeout period in seconds 7 | deleteIp="" #server Ip for removing 8 | 9 | #used to remove server configuration 10 | def deleteServer(tacacs,server): 11 | 12 | 13 | tacacs.add_server(server,no="True") 14 | print "Successfuly deleted configuration of server ",server 15 | 16 | 17 | def enable_feature_tacacs(): 18 | cmd = 'feature tacacs' 19 | configure_terminal(cmd) 20 | 21 | def configure_terminal(cmd): 22 | """ 23 | Configure terminal based on the commands given 24 | """ 25 | 26 | NXCLI._run_cfg(cmd) 27 | 28 | 29 | if __name__=="__main__": 30 | 31 | enable_feature_tacacs() 32 | #show TACACS Server 33 | showTacacs=ShTacasServer() 34 | print "Before TACACS+ Configuration" 35 | if showTacacs.servers(): 36 | print showTacacs.servers() 37 | else: 38 | print "no server configured" 39 | 40 | tacacs=Tacacs() 41 | 42 | if deleteIp !="" and tacacs._is_server_configured(deleteIp): 43 | #delete server Ip 44 | deleteServer(tacacs,deleteIp) 45 | 46 | if tacacsServerIp: 47 | 48 | #add th TACACS+ server 49 | tacacs.add_server(tacacsServerIp) 50 | #tacacs.src_interface("Ethernet1/2") 51 | #tacacs.commit() 52 | #tacacs.add_group("ciscogroup1",tacacsServerIp) 53 | 54 | 55 | showTacacs=ShTacasServer() 56 | print "After TACACS+ Configuration:",showTacacs.servers() 57 | -------------------------------------------------------------------------------- /Monitoring/vxlan/vxlan_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | def configure_terminal(cmd): 5 | """ 6 | Configure terminal based on the commands given 7 | """ 8 | NXCLI._run_cfg(cmd) 9 | 10 | def main(): 11 | """ 12 | Monitor nve vni interfaces 13 | """ 14 | 15 | # Enable the feature 16 | configure_terminal('feature nv overlay') 17 | 18 | cli = NXCLI('show nve vni', do_print=True) 19 | print "\nShow nve vni " 20 | print "===============" 21 | vni = {} 22 | lines = cli.raw_output.split('\n') 23 | for line in lines: 24 | vni_line = re.search(r'(nve1)(\s+)([0-9]+)(\s+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^0-9])(\s+)([a-zA-Z]+)(\s+)([a-zA-Z]+)(\s+)([a-zA-Z0-9]+)(\s+)\[([0-9]+)\]', line) 25 | if vni_line: 26 | vni_id = vni_line.group(3) 27 | vni[vni_id] = {} 28 | vni[vni_id]['interface'] = vni_line.group(1) 29 | vni[vni_id]['mcast_grp'] = vni_line.group(5) 30 | vni[vni_id]['state'] = vni_line.group(7) 31 | vni[vni_id]['mode'] = vni_line.group(9) 32 | vni[vni_id]['type'] = vni_line.group(11) 33 | vni[vni_id]['vrf'] = vni_line.group(13) 34 | print vni 35 | 36 | 37 | cli = NXCLI('show nve interface', do_print=True) 38 | print "\nShow nve interface" 39 | print "=========================" 40 | nveIntf = {} 41 | lines = cli.raw_output.split('\n') 42 | for line in lines: 43 | intf_line1 = re.search(r'Interface: (nve1), State: ([a-zA-Z]+), encapsulation: ([A-Z]+)', line) 44 | if intf_line1: 45 | nveIntf['interface'] = intf_line1.group(1) 46 | nveIntf['state'] = intf_line1.group(2) 47 | nveIntf['encapsulation'] = intf_line1.group(3) 48 | intf_line2 = re.search(r' Source-Interface: (.*) \(primary: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}), secondary: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)', line) 49 | if intf_line2: 50 | nveIntf['Source-Interface'] = intf_line2.group(1) 51 | nveIntf['primary'] = intf_line2.group(2) 52 | nveIntf['secondary'] = intf_line2.group(3) 53 | print nveIntf 54 | 55 | # Disable the feature 56 | configure_terminal('no feature nv overlay') 57 | 58 | if __name__=="__main__": 59 | main() 60 | 61 | -------------------------------------------------------------------------------- /Monitoring/quick_switch_capacity/quick_switch_capacity_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | 5 | def main(): 6 | """ 7 | Monitor port-channel, MAC, Tcam and SVI details 8 | """ 9 | cli = NXCLI('show port-channel usage', do_print=False) 10 | print "\nShow port-channel usage" 11 | print "=========================" 12 | pc_out = cli.raw_output.split('\n\t') 13 | for line in pc_out: 14 | used_pc = re.search(r'Used(\s+):(\s+)(.*)', line) 15 | if used_pc: 16 | usedPC = used_pc.group(3).split(',') 17 | print 'Used port channel group:' , usedPC 18 | unused_pc = re.search(r'Unused:(\s+)(.*)', line) 19 | if unused_pc: 20 | unUsedPC = unused_pc.group(2).split(',') 21 | print 'Unused port channel group:' , unUsedPC 22 | 23 | 24 | cli = NXCLI('show hardware access-list tcam region', do_print=False) 25 | print "\nShow hardware access-list tcam region" 26 | print "=======================================" 27 | names = [] 28 | sizes = [] 29 | out = cli.raw_output.split('\n') 30 | for line in out: 31 | t_reg = re.search(r'TCAM Region Sizes:(\s+)(.*)', line) 32 | if t_reg: 33 | total_tcam_region = t_reg.group(2) 34 | print 'TCAM Region Sizes: ', total_tcam_region 35 | 36 | t_names = re.search(r'(\s+)(.*)(\s+)size(\s+)=(\s+)(.*)', line) 37 | if t_names: 38 | names.append(t_names.group(2)) 39 | sizes.append(t_names.group(6)) 40 | 41 | template = "{0:40} {1:10}" 42 | print template.format("Name", "Size") 43 | print template.format("=======", "=========") 44 | for name, size in zip(names, sizes): 45 | print template.format(name, size) 46 | 47 | cli = NXCLI('show mac address-table count', do_print=False) 48 | print "\nShow mac address-table count" 49 | print "=================================" 50 | out = cli.raw_output.split('\n') 51 | mac_dict = {} 52 | for line in out: 53 | mac = re.search(r'(.*):(\s+)(.*)', line) 54 | if mac: 55 | mac_address = mac.group(1) 56 | mac_dict[mac_address] = mac.group(3) 57 | 58 | print mac_dict 59 | 60 | if __name__=="__main__": 61 | main() 62 | 63 | -------------------------------------------------------------------------------- /Configuration/sandbox-nxapi.txt: -------------------------------------------------------------------------------- 1 | Follow below steps to execute nxapi code snippet on nx9000 switch. 2 | 3 | On the nx9000 switch perform following operation. 4 | 1. SSH to switch using provided credentials. (If credentials are not provided Default username is ‘admin’ and password ‘cisco123’ 5 | 2. Run 'config t' on the switch prompt. 6 | 3. Enable nxapi by running ‘feature nxapi’. 7 | 4. Exit to switch prompt by running 'exit'. 8 | 5. Run 'copy r s' to save the configuration. 9 | 10 | Setup postman Code snippet: 11 | In order to execute NXAPI from postman, login needs to be performed. The cookie would get generated and stored for subsequent execution. 12 | 13 | POST-URL : http://SWITCH-IP/api/aaaLogin.json 14 | Content-Type: application/json 15 | Cache-Control: no-cache 16 | POST BODY : 17 | { 18 | "aaaUser" : { 19 | "attributes" : { 20 | "name" : "SWITCH_USER", 21 | "pwd" : "SWITCH_PASSWORD" 22 | } 23 | } 24 | } 25 | 26 | Executing NXAPI using postman for first time: 27 | 28 | 1. Copy POST URL, mentioned in 'setup postman' section above, after replacing SWITCH-IP with IP address of Nexus switch . 29 | 2. Select method as POST 30 | 3. Open raw JSON section. 31 | 4. Copy POST-BODY JSON to raw JSON body section of postman. 32 | 5. Replace SWITCH_USERNAME with switch user. 33 | 6. Replace SWITCH_PASSWORD with switch password. 34 | 7. Click send button 35 | 36 | Note: If the cookie gets expired, you might have to perform the above steps again. 37 | 38 | For subsequent NXAPI call: 39 | 40 | 1. Copy POST URL, after replacing SWITCH-IP with IP address of Nexus switch. 41 | 2. Select method as POST 42 | 3. Open raw JSON section. 43 | 4. Copy POST-BODY JSON to raw JSON body section of postman. 44 | 5. Click send button 45 | 46 | How to connect to sandbox lab: 47 | 48 | 1. Go to the sandbox homepage: https://developer.cisco.com/site/devnet/sandbox/ 49 | 2. Login. Hit the yellow button “Get Started!” button 50 | 3. In the upper-right corner click on “DEVNET”. 51 | 4. Now you are in Cisco's Devnet domain and it would list the labs hosted under the domain. 52 | 5. You can find the 8 tiles for the NX-OS labs. The tiles are named as "Open NX-OS Lab -1(through 8)" 53 | 6. Click on 'Reserve' a lab. Upon successful reservation you would receive a mail from "devnetsandbox@cisco.com" that describes further instructions to access the sandbox. 54 | -------------------------------------------------------------------------------- /Configuration/interface/interface_python.py: -------------------------------------------------------------------------------- 1 | #Sample file to configure Interface 2 | #Import Interface class 3 | from .interface import Interface 4 | from .nxcli import NXCLI 5 | import traceback 6 | 7 | #Fillup the Interface details to be configured 8 | interfaceName="Ethernet1/6" 9 | interfaceIpaddress="192.168.17.12/24" 10 | interfaceDescription="Interface6" 11 | interfaceState="no shut" 12 | 13 | def is_interface_available(interfaceName): 14 | """ 15 | Checks if interface is available or not. 16 | return True if interface is available, else return False 17 | """ 18 | 19 | try: 20 | interface = NXCLI('show run interface %s' %interfaceName) 21 | return True 22 | except: 23 | return False 24 | 25 | def configure_terminal(cmd): 26 | """ 27 | Configure terminal based on the commands given 28 | """ 29 | 30 | NXCLI._run_cfg(cmd) 31 | 32 | def convert_to_routed_interface(interfaceName): 33 | """ 34 | Convert interface mode from access to routed 35 | """ 36 | 37 | cmd = "interface %s ; no switchport" %interfaceName 38 | configure_terminal(cmd) 39 | 40 | if __name__=="__main__": 41 | 42 | try: 43 | if not is_interface_available(interfaceName): 44 | raise Exception("Interface not available. \nPlease give different interface. To list available interfaces, just go to switch-prompt and type : \nshow int br") 45 | 46 | switch=Interface(interfaceName) 47 | 48 | print "Before Interface Configuration" 49 | configurationResults=switch.config() 50 | print configurationResults 51 | 52 | convert_to_routed_interface(interfaceName) 53 | 54 | if interfaceIpaddress: 55 | #set Ip address 56 | ipaddress=switch.set_ipaddress(interfaceIpaddress) 57 | 58 | #set Description 59 | if interfaceDescription: 60 | description=switch.set_description(interfaceDescription) 61 | 62 | #set mode and state 63 | switch.set_state(interfaceState) 64 | 65 | print "After interface Configuration" 66 | configurationResults=switch.config() 67 | print configurationResults 68 | 69 | 70 | except Exception,e: 71 | traceback.print_exc() 72 | -------------------------------------------------------------------------------- /Monitoring/VMTracker/VMtracker_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import time 3 | import re 4 | 5 | conName = 'con1' 6 | ipAdd = '172.31.217.189' 7 | userName = 'root' 8 | password = 'C!sc0123' 9 | 10 | class ShowVmTracker(NXCLI): 11 | def __init__ (self, cmd): 12 | super(ShowVmTracker, self).__init__(cmd, do_print=True) 13 | 14 | def configure_terminal(cmd): 15 | """ 16 | Configure terminal based on the commands given 17 | """ 18 | NXCLI._run_cfg(cmd) 19 | 20 | def main(): 21 | """ 22 | Configure checkpoint 23 | """ 24 | # Enable the feature 25 | configure_terminal('feature vmtracker') 26 | 27 | # Config VM Tracker Connection 28 | configure_terminal('vmtracker connection %s ; remote ip address %s port 80 vrf management ; username %s password %s ; connect ' % (conName, ipAdd, userName, password)) 29 | 30 | time.sleep(20) 31 | vmStatus = {} 32 | 33 | cli = ShowVmTracker('show vmtracker status') 34 | cliStatusOutput = cli.raw_output 35 | out = cliStatusOutput.split('\n\t') 36 | for line in out: 37 | vmStatusLine = re.search(r'(\w+)(\s+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\s+)(\w+)', line) 38 | if vmStatusLine: 39 | connName = vmStatusLine.group(1) 40 | vmStatus[connName] = {} 41 | vmStatus[connName]['vcenterip'] = vmStatusLine.group(3) 42 | vmStatus[connName]['status'] = vmStatusLine.group(5) 43 | print vmStatus 44 | 45 | vmInfo = {} 46 | cli = ShowVmTracker('show vmtracker info detail') 47 | cliInfoOutput = cli.raw_output 48 | out = cliInfoOutput.split('\n') 49 | i = 1 50 | for line in out: 51 | vmInfoLine = re.search(r'([A-Za-z/0-9]+)(\s+)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\s+)(\w+)(\s+)([A-Za-z0-9-.]+)(\s+)(\w+)(\s+)([A-Za-z0-9-.]+)(\s+)(\w+)', line) 52 | if vmInfoLine: 53 | vmInfo[i] = {} 54 | vmInfo[i]['interface'] = vmInfoLine.group(1) 55 | vmInfo[i]['host'] = vmInfoLine.group(3) 56 | vmInfo[i]['vmnic'] = vmInfoLine.group(5) 57 | vmInfo[i]['vm'] = vmInfoLine.group(7) 58 | vmInfo[i]['state'] = vmInfoLine.group(9) 59 | vmInfo[i]['portgroup'] = vmInfoLine.group(11) 60 | vmInfo[i]['vlan'] = vmInfoLine.group(13) 61 | i += 1 62 | print vmInfo 63 | 64 | # Unconfigure the changes done 65 | configure_terminal('no feature vmtracker') 66 | 67 | 68 | if __name__=="__main__": 69 | main() 70 | 71 | -------------------------------------------------------------------------------- /Monitoring/acl/acl_python.py: -------------------------------------------------------------------------------- 1 | from .acl import * 2 | from .nxcli import NXCLI 3 | import re 4 | 5 | def configure_terminal(cmd): 6 | """ 7 | Configure terminal based on the commands given 8 | """ 9 | NXCLI._run_cfg(cmd) 10 | 11 | def apply_acl(name): 12 | """ 13 | Apply ACL 14 | """ 15 | cmd = "line vty ; ip access-class %s out" % acl.name 16 | configure_terminal(cmd) 17 | 18 | def config_timerange(name, type=None, s_day=None, e_day=None, s_time=None, 19 | e_time=None,a_type=None, a_date=None, a_month=None, 20 | a_year=None): 21 | """ 22 | Configure time range 23 | """ 24 | if type == 'periodic': 25 | cmd = "time-range %s ; periodic %s %s to %s %s"% (name, s_day, 26 | s_time, e_day, e_time) 27 | elif type == 'absolute': 28 | cmd = "time-range %s ; absolute %s %s %s %s %s"% (name, 29 | a_type, s_time, a_date, a_month, a_year) 30 | else: 31 | cmd = "time-range %s"% name 32 | configure_terminal(cmd) 33 | 34 | def main(): 35 | """ 36 | Configure time based ACL 37 | """ 38 | # Configuring time-range 39 | config_timerange('sample', type='periodic', s_day='Monday', 40 | e_day='Thursday', s_time='00:00:00', e_time='0') 41 | config_timerange('sample', type='absolute', a_type='start', 42 | s_time='00:00:00', a_date='31', a_month='Jan', 43 | a_year='2016') 44 | 45 | # Configuring access-list with time-range 46 | acl = IPv4ACL('my_acl') 47 | acl.permit('tcp', 'any', 'any', time_range='sample') 48 | 49 | # Applying the ACL to an interface 50 | apply_acl(acl.name) 51 | 52 | cli = NXCLI('show ip access-lists my_acl', do_print=False) 53 | acl_dict = {} 54 | acl_lines = cli.raw_output.split('\n\t') 55 | for line in acl_lines: 56 | match_acl_name = re.search(r'IP access list (.*)', line) 57 | if match_acl_name: 58 | aclName = match_acl_name.group(1) 59 | acl_dict[aclName] = {} 60 | else: 61 | match_acl_line = re.search(r'(\d+) permit (\w+) (\w+) (\w+) time-range (\w+)', line) 62 | if match_acl_line: 63 | seqNo = match_acl_line.group(1) 64 | acl_dict[aclName][seqNo] = {} 65 | acl_dict[aclName][seqNo]['protocol'] = match_acl_line.group(2) 66 | acl_dict[aclName][seqNo]['src'] = match_acl_line.group(3) 67 | acl_dict[aclName][seqNo]['dest'] = match_acl_line.group(4) 68 | acl_dict[aclName][seqNo]['timeRangeName'] = match_acl_line.group(5) 69 | else: 70 | print 'No Acl details found' 71 | print acl_dict 72 | 73 | if __name__=="__main__": 74 | main() 75 | -------------------------------------------------------------------------------- /Configuration/sandbox-puppet.txt: -------------------------------------------------------------------------------- 1 | Following steps would execute the manifest files on nx9000 switch. 2 | 3 | 4 | 1. SSH to toolserver host using provided credentials. (If credentials are not provided Default username is ‘cisco’ and password ‘cisco123’ 5 | 2. 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. 6 | 7 | Note: All the manifest scripts are available "/etc/puppetlabs/code/environments/production/modules/ciscolib_nxos/manifests" for reference. 8 | 9 | 3. Save and exit. 10 | 4. Run 'sudo su' 11 | 5. Start the puppetserver service. Run 'service puppetserver start' or '/opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master' 12 | 6. Run 'export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib' on toolserver 13 | 7. Run ‘puppet cert list -a’ 14 | 15 | 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. 16 | Note : Note: Make sure "/etc/hosts" file has correct IP and hostname mapping for toolserver 17 | Example: toolserver IP: 10.10.10.114 18 | hostname: toolserver-devnet.insieme.local 19 | Then, "/etc/hosts" should contain "10.10.10.114 toolserver-devnet.insieme.local toolserver-devnet" 20 | 21 | 8. Login to Switch sandbox. 22 | 9. On the switch console run 'run bash' 23 | 10. Run 'sudo ip netns exec management bash' 24 | 11. Run ‘export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib’ 25 | 12. export http and https proxy by executing these commands. 26 | Run 'export http_proxy=http://proxy.esl.cisco.com:8080' 27 | Run 'export https_proxy=http://proxy.esl.cisco.com:8080' 28 | 13. Install "install cisco_node_utils" package by executing following command, 29 | Run 'gem install cisco_node_utils' 30 | 14. Run 'puppet agent -t'. The configuration would be updated automatically on the switch. 31 | 15. Go to switch prompt and run 'copy r s' 32 | 33 | 34 | Steps to add the certificates : 35 | 36 | 1. Login to Switch sandbox. 37 | 2. On the switch console run 'run bash' 38 | 3. Run 'sudo ip netns exec management bash' 39 | 4. Run 'export PATH=$PATH:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/puppet/lib' 40 | 5. Run 'rm -rf /etc/puppetlabs/puppet/ssl' to clean all the old certificates. 41 | 6. Run 'puppet agent -t' on bash shell. This will create a new certificate. 42 | 7. Now login to toolserver. 43 | 8. Run 'sudo su' 44 | 9. Start the puppetserver service. Run 'service puppetserver start' or '/opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/bin/puppet master' 45 | 10. Run 'export PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/lib' on toolserver 46 | 11. Run ‘puppet cert list -a’ . It should list the certificate sent by agent #agent hostname should be present. 47 | 12. Run 'puppet cert sign '. For example, puppet cert sign "n9kvswitchfcs.cisco.com"​ ## agent hostname 48 | -------------------------------------------------------------------------------- /Monitoring/ipsla/ipsla_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | def configure_terminal(cmd): 5 | """ 6 | Configure terminal based on the commands given 7 | """ 8 | NXCLI._run_cfg(cmd) 9 | 10 | def main(): 11 | # Make IP SLA configurations 12 | NXCLI._run_cfg('feature sla sender') 13 | NXCLI._run_cfg('ip sla 6 ; icmp-echo 172.31.216.130') 14 | NXCLI._run_cfg('ip sla schedule 6 life forever start-time now') 15 | 16 | # Show the difference between running-config and checkpoint 17 | print "\nShow IP SLA application " 18 | print "===============" 19 | cli = NXCLI('show ip sla application', do_print=True) 20 | ipslaAppln = {} 21 | lines = cli.raw_output.split('\n') 22 | for line in lines: 23 | confEntries = re.search(r'Number of Entries configured\s+:\s+(.*)', line) 24 | if confEntries: 25 | ipslaAppln['Configured entries'] = confEntries.group(1) 26 | actEntries = re.search(r'Number of active Entries\s+:\s+(.*)', line) 27 | if actEntries: 28 | ipslaAppln['Active entries'] = actEntries.group(1) 29 | print ipslaAppln 30 | 31 | print "\nShow IP SLA configuration" 32 | print "===============" 33 | cli = NXCLI('show ip sla configuration', do_print=True) 34 | ipslaConf = {} 35 | lines = cli.raw_output.split('\n') 36 | for line in lines: 37 | entryNo = re.search(r'Entry number:\s+(.*)', line) 38 | if entryNo: 39 | ipslaConf['Entry number'] = entryNo.group(1) 40 | typeOfOp = re.search(r'Type of operation to perform:\s+(.*)', line) 41 | if typeOfOp: 42 | ipslaConf['Type of operation'] = typeOfOp.group(1) 43 | addr = re.search(r'Target address\/Source address:\s+(.*)\/(.*)', line) 44 | if addr: 45 | ipslaConf['target addr'] = addr.group(1) 46 | ipslaConf['source addr'] = addr.group(2) 47 | opFreq = re.search(r'Operation frequency \(seconds\):\s+([0-9]+)', line) 48 | if opFreq: 49 | ipslaConf['operation frequency'] = opFreq.group(1) 50 | print ipslaConf 51 | 52 | print "\nShow IP SLA statistics" 53 | print "===============" 54 | cli = NXCLI('show ip sla statistics', do_print=True) 55 | ipslaStats = {} 56 | lines = cli.raw_output.split('\n') 57 | for line in lines: 58 | opId = re.search(r'IPSLA operation id:\s+(.*)', line) 59 | if opId: 60 | ipslaStats['operation id'] = opId.group(1) 61 | noOfSuc = re.search(r'Number of successes:\s+(.*)', line) 62 | if noOfSuc: 63 | ipslaStats['number of successes'] = noOfSuc.group(1) 64 | noOfFail = re.search(r'Number of failures:\s+(.*)', line) 65 | if noOfFail: 66 | ipslaStats['number of failures'] = noOfFail.group(1) 67 | opTime = re.search(r'Operation time to live:\s+(.*)', line) 68 | if opTime: 69 | ipslaStats['operation ttl'] = opTime.group(1) 70 | print ipslaStats 71 | 72 | NXCLI._run_cfg('no feature sla sender') 73 | 74 | if __name__=="__main__": 75 | main() 76 | -------------------------------------------------------------------------------- /Monitoring/sflow/sflow_python.py: -------------------------------------------------------------------------------- 1 | from .nxcli import NXCLI 2 | import re 3 | 4 | def configure_terminal(cmd): 5 | """ 6 | Configure terminal based on the commands given 7 | """ 8 | NXCLI._run_cfg(cmd) 9 | 10 | def main(): 11 | 12 | # Make some configuration changes 13 | NXCLI._run_cfg('feature sflow') 14 | 15 | # Show the difference between running-config and checkpoint 16 | cli = NXCLI('show sflow', do_print=True) 17 | print "\nShow sflow " 18 | print "===============" 19 | sflow = {} 20 | lines = cli.raw_output.split('\n') 21 | for line in lines: 22 | sampRate = re.search(r'sflow sampling-rate :\s+(.*)', line) 23 | if sampRate: 24 | sflow['sampling rate'] = sampRate.group(1) 25 | sampMaxSize = re.search(r'sflow max-sampled-size :\s+(.*)', line) 26 | if sampMaxSize: 27 | sflow['sampling max size'] = sampMaxSize.group(1) 28 | pollIntrwl = re.search(r'sflow counter-poll-interval :\s+(.*)', line) 29 | if pollIntrwl: 30 | sflow['poll interval'] = pollIntrwl.group(1) 31 | dataSize = re.search(r'sflow max-datagram-size :\s+(.*)', line) 32 | if dataSize: 33 | sflow['datagram max size'] = dataSize.group(1) 34 | collIp = re.search(r'sflow collector-ip :\s+(.*)\s+,vrf :\s+(.*)', line) 35 | if collIp: 36 | sflow['collector ip'] = collIp.group(1) 37 | sflow['vrf'] = collIp.group(2) 38 | collPort = re.search(r'sflow collector-port :\s+(.*)', line) 39 | if collPort: 40 | sflow['collector port'] = collPort.group(1) 41 | agentIp = re.search(r'sflow agent-ip :\s+(.*)', line) 42 | print sflow 43 | 44 | cli = NXCLI('show sflow statistics', do_print=True) 45 | print "\nShow sflow stats" 46 | print "===============" 47 | sflowStats = {} 48 | lines = cli.raw_output.split('\n') 49 | for line in lines: 50 | totPkts = re.search(r'Total Packets\s+:\s+(.*)', line) 51 | if totPkts: 52 | sflowStats['total packets'] = totPkts.group(1) 53 | totSamples = re.search(r'Total Samples\s+:\s+(.*)', line) 54 | if totSamples: 55 | sflowStats['total samples'] = totSamples.group(1) 56 | procSamples = re.search(r'Processed Samples\s+:\s+(.*)', line) 57 | if procSamples: 58 | sflowStats['processed samples'] = procSamples.group(1) 59 | drpSamples = re.search(r'Dropped Samples\s+:\s+(.*)', line) 60 | if drpSamples: 61 | sflowStats['dropped samples'] = drpSamples.group(1) 62 | sentData = re.search(r'Sent Datagrams\s+:\s+(.*)', line) 63 | if sentData: 64 | sflowStats['sent datagrams'] = sentData.group(1) 65 | dropData = re.search(r'Dropped Datagrams\s+:\s+(.*)', line) 66 | if dropData: 67 | sflowStats['dropped datagrams'] = dropData.group(1) 68 | print sflowStats 69 | 70 | NXCLI._run_cfg('no feature sflow') 71 | 72 | if __name__=="__main__": 73 | main() 74 | 75 | -------------------------------------------------------------------------------- /Configuration/OSPF/ospf_python.py: -------------------------------------------------------------------------------- 1 | from .ospf import OSPFSession 2 | from .nxcli import NXCLI 3 | import traceback 4 | 5 | instance = '49' 6 | interface_name = 'eth1/6' 7 | area = '20' 8 | distance = 41 9 | ospf_cost = 45 10 | hello_interval = 61 11 | dead_interval = 55 12 | priority = 51 13 | 14 | def start_ospf_session(): 15 | ''' 16 | starts ospf session. 17 | Do show run ospf on switch to see the changes. 18 | ''' 19 | 20 | ospf_session = OSPFSession(instance) 21 | ospf_interface = OSPFSession.OSPFInterface(interface_name, area) 22 | 23 | ospf_session.start() 24 | return (ospf_session, ospf_interface) 25 | 26 | 27 | def shutdown_ospf_session(ospf_session): 28 | ospf_session.shutdown() 29 | 30 | 31 | def start_ospf_if_down(ospf_session): 32 | if ospf_session.is_shutdown(): 33 | start_ospf_session() 34 | 35 | 36 | def configure_distance(ospf_session): 37 | ospf_session.cfg_distance(distance) 38 | 39 | 40 | def add_interface_to_ospf(ospf_interface): 41 | ospf_interface.add() 42 | 43 | 44 | def configure_ospf_cost(ospf_interface): 45 | ospf_interface.cfg_ospf_cost(ospf_cost) 46 | 47 | 48 | def configure_ospf_hello_interval(ospf_interface): 49 | ospf_interface.cfg_hello_interval(hello_interval) 50 | 51 | 52 | def configure_dead_interval(ospf_interface): 53 | ospf_interface.cfg_dead_interval(dead_interval) 54 | 55 | 56 | def configure_priority(ospf_interface): 57 | ospf_interface.cfg_ospf_priority(priority) 58 | 59 | 60 | def interface_shutdown(ospf_interface): 61 | ospf_interface.shutdown() 62 | 63 | 64 | def is_interface_available(interface_name): 65 | """ 66 | Checks if interface is available or not. 67 | return True if interface ia available, else returns False 68 | """ 69 | 70 | try: 71 | interface = NXCLI('show run interface %s' %interface_name) 72 | return True 73 | except: 74 | return False 75 | 76 | def configure_terminal(cmd): 77 | """ 78 | Configure terminal based on the commands given 79 | """ 80 | 81 | NXCLI._run_cfg(cmd) 82 | 83 | 84 | def convert_to_routed_interface(interface_name): 85 | """ 86 | Convert interface mode from access to routed 87 | """ 88 | 89 | cmd = "interface %s ; no switchport" %interface_name 90 | configure_terminal(cmd) 91 | 92 | 93 | def enable_feature_ospf(): 94 | """ 95 | Enable feature on switch 96 | """ 97 | 98 | cmd = "feature ospf" 99 | configure_terminal(cmd) 100 | 101 | 102 | def configure_switch_for_ospf(): 103 | if not is_interface_available(interface_name): 104 | raise Exception("Interface not available. \nPlease give different interface. To list available interfaces, just go to switch-prompt and type : \nshow int br") 105 | 106 | convert_to_routed_interface(interface_name) 107 | 108 | enable_feature_ospf() 109 | 110 | return start_ospf_session() 111 | 112 | 113 | def configure_ospf(): 114 | ''' 115 | Use above mention functions as per requirement. 116 | Sample configuration is shown below. 117 | To check the result of any fucntion after using it here, do a 118 | show run ospf on switch. 119 | ''' 120 | try: 121 | #Switch is configured for OSPF. This is basic operation and should not be omitted. 122 | ospf_session, ospf_interface = configure_switch_for_ospf() 123 | 124 | #All of the functions below are independent of each other. 125 | configure_distance(ospf_session) 126 | add_interface_to_ospf(ospf_interface) 127 | configure_ospf_cost(ospf_interface) 128 | configure_ospf_hello_interval(ospf_interface) 129 | configure_dead_interval(ospf_interface) 130 | configure_priority(ospf_interface) 131 | 132 | print "After ospf configuration:" 133 | NXCLI('show run ospf') 134 | 135 | except Exception, e: 136 | traceback.print_exc() 137 | 138 | 139 | if __name__ == '__main__': 140 | configure_ospf() 141 | --------------------------------------------------------------------------------