Cisco NX-OS data centre lab 9 of 15

NX-API, on-box Python, Bash and Guest Shell

Drive a Nexus switch the way a program does: NX-API calls in JSON and XML from a workstation, a Python script that changes VLANs, Bash and Python on the switch itself, Guest Shell, and an Ansible playbook you can run twice with no harm.

Run this lab

It needs Lite: its 2 nodes are set to 3 vCPU and 7,168 MB in total. That fits the free demo too.

In your workspace: Shared, then Cisco Nexus NX-OS data centre guided labs, then 09 - NX-API on-box Python Bash and Guest Shell

Try it free for 30 minutesRun it on Lite from £3 a day

The free demo needs no card and no email. Every lab plan includes every guided lab.

Level
Intermediate
Time
About 80 minutes
Nodes need
3 vCPU, 7,168 MB
Smallest plan
Lite

The scenario

Ashgrove's next tenant wants forty VLANs built by Friday, and nobody wants to type them. You'll try each of the ways NX-OS can be automated and see what each is good for. OPS is your automation workstation, with Python, curl and Ansible ready, and example files in /root/lab. N1 has its name, login and management address.

ItemValue
N1 mgmt0192.168.100.1
OPS192.168.100.10
Loginadmin, password Cl@ssLab1
NX-API URLhttp://192.168.100.1/ins

A note on HTTP. The labs use plain HTTP on port 80 so you can read every step. NX-API's default is HTTPS, and on a real network you'd keep it that way.

What you’ll practise

  • Enable NX-API and call it with curl
  • Choose between ins_api and JSON-RPC, and JSON and XML
  • Read and change a switch with Python requests
  • Use the Bash shell and reach NX-OS from it with vsh
  • Run an on-box Python script that uses the cli module
  • Enable Guest Shell, and explain how it differs from Bash
  • Run an idempotent Ansible playbook

The tasks

  1. Start the lab
  2. Switch on NX-API
  3. The first call
  4. XML and JSON-RPC
  5. Change the switch from Python
  6. The Bash shell
  7. Python on the switch
  8. Guest Shell
  9. Ansible

The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.

Topology and devices

The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.

Topology of NX-API on-box Python Bash and Guest Shell2 nodes and 1 network, 2 links. Every link is listed as text below the diagram.N1OPSMGMTeth0e0
2 nodes and 1 network, with the interface names each link uses.
Nodes in NX-API, on-box Python, Bash and Guest Shell, with the image each runs and the vCPU and RAM it’s set to
NodeDeviceImage in Add NodeSet to
N1Cisco Nexus 9000vnxosv9k-9300v-9.3.102 vCPU, 6,144 MB
OPSEVE-NG GUI server (Docker)eve-gui-server:latest1 vCPU, 1,024 MB

How to open this lab

  1. Sign in to your workspace at lab.cloudlabbox.com.

  2. In File Manager, open Shared, then the folder Cisco Nexus NX-OS data centre guided labs.

  3. Open 09 - NX-API on-box Python Bash and Guest Shell and start its nodes, then open Lab Tasks for the scenario and the steps.

The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.

More Cisco NX-OS data centre labs

All Cisco NX-OS data centre labs

Related labs in other courses

CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.