Enable the NX-OS API

So what has changed in the past 20 years? Take for example the network equipment that was manufactured in 1997, how did you configure that equipment? I would imagine it involved a serial port, HyperTerminal and trusty command line. Was API even a thing back in 1997, was it common to have an API interface in network equipment like today? Why do we even need an API on the equipment in the first place? What changed? Well the year isn't 1997 anymore, that past us 20 years ago and the equipment we work with today looks and operates much differently than it did in 1997.

We work in a world now that operates with Gbps/Tbps not Kbps/Mbps. With the need for speed CLI isn't the fastest thing anymore to configure or monitor network devices. This industry is moving into automated ways to configure and monitor network devices. So in this post we'll look at enabling the NX-API that's in the Cisco Nexus 9000 and 3000 family switches, and in foing this we'll get introduced into the Cisco NX-API sandbox.

To enable this API  jump right into CLI and configure the management interface, we'll be able to use this API using the management IP address of the switch.

1vrf context management
2interface mgmt0
3  description OOB Management
4  vrf member management
5  ip address 172.16.1.192/24

Once the management interface is configured we now can enable the NX-API by one command.

1nx-osv9000-1# config t
2nx-osv9000-1(config)# feature nxapi

Open a web browser to the management IP address and login with a username and password.

Welcome to NX-API Sandbox! With this we can play around to get a further understanding of how to use this API. Like being able to configure and or monitor this device with either a custom home-grown system, or the use some network automation software like Puppet or Chef.

So now what?

Well if you are like me and really don't have much programming experience or just enough to be dangerous this where you get comfortable and use this sandbox to understand what it can and cannot do. For example on the upper right hand side, if I select XML on the message format, then cli_show on the command type, followed by typing the command show hostname in the CLI command box, and finishing by selecting the post button, I should see an output of an XML request as well as the XML response from the switch.

 1<?xml version="1.0" encoding="UTF-8"?>
 2<ins_api>
 3  <type>cli_show</type>
 4  <version>1.0</version>
 5  <sid>eoc</sid>
 6  <outputs>
 7    <output>
 8      <body>
 9      <hostname>nx-osv9000-1</hostname>
10     </body>
11      <input>show hostname</input>
12      <msg>Success</msg>
13      <code>200</code>
14    </output>
15  </outputs>
16</ins_api>

Note: Sandbox is a loose term here as any configuration viewed or applied is live on the equipment, don't play in the sandbox on production equipment. :)

This post just scratches the surface of what you could do with this API, being able to either write something yourself or using third-party software to help configure and maintain network equipment makes your job easier. Although we still have equipment and even people today that still like those three letters "CLI", being able to use an API that can configure and maintain provides options for these devices, and who doesn't like that?