Skip to content

Lab 20.2 - Exploring the Cisco Nexus NX-API

This lab introduces you to the Developer Sandbox environment that exists on each Nexus switch (assuming it supports NX-API). The NX-API is a great tool for beginners and experts alike, as it gives you direct insight with how the switch will respond to API calls. This allows you to verify what key-value pairs and responses you should be getting back as you are writing and testing your code.

Task 1 - NX-API Developer Sandbox

Step 1-1

Remote-desktop (RDP) into your jump-host, open a web browser (Chromium or Firefox) using the desktop shortcuts, and then connect to the switch.

  • Enter https://nxos-spine1 into the browser.
  • You will get a security warning because the certificate is self-signed.
  • Click on the Advanced button and then Proceed to nxos-spine1 (unsafe).

NX-API Sandbox

Note: This screenshot is from Chromium, but you will get a similar prompt to accept a bad certificate (in this case self-signed) in Firefox.

Step 1-2

Login with the credentials username: ntc, password: ntc123

NX-API Sandbox Logon

You will then see the NX-API Developer Sandbox:

NX-API Sandbox

Step 1-3

Enter the command show version in the large text box on the left hand side. Keep all other settings as default for now.

Step 1-4

Click the Send button.

You will see the response in the Response box.

NX-API Sandbox

Notice the JSON data that came back. It has several key-value pairs including jsonrpc and result. Notably, the main response is in under its own key called body as the value for the key result.

Step 1-5

In the command text box, now enter the following command:

show interface Eth1/2

Step 1-6

Choose the Message format XML and choose the command type cli_show_ascii

Note: cli_show_ascii is used when you want to receive raw text back from the device as opposed to structured data that is returned when you use cli_show.

Step 1-7

Click the amber Send button.

NX-API Sandbox

You will see the raw text response just like you'd see if you were on the switch locally.

NX-API Sandbox

Step 1-8

Now keep the same command show interface Eth1/2, but change the command type back to cli_show.

NX-API Sandbox

Step 1-9

Click the amber Send button.

Notice the difference from the previous task comparing and contrasting receiving structured data (XML) vs. raw text. Feel free to try the same command using JSON-RPC.

NX-API Sandbox

Step 1-10

Now Go back to the command text box and enter the following string:

interface Ethernet1/2 ; no shutdown

Step 1-11

Change the command type to be cli_conf.

cli_conf is used when you want to configure the device from within "configuration" mode on the switch.

Step 1-12

Click the amber Send button.

NX-API Sandbox

You will see the response in the bottom left. Notice that a status code for each command returned.

<?xml version="1.0"?>
<ins_api>
  <type>cli_conf</type>
  <version>1.0</version>
  <sid>eoc</sid>
  <outputs>
    <output>
      <body/>
      <code>200</code>
      <msg>Success</msg>
    </output>
    <output>
      <body/>
      <code>200</code>
      <msg>Success</msg>
    </output>
  </outputs>
</ins_api>

Take a few more minutes and continue to explore the Cisco NX-API Developer Sandbox.