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
- 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.
| Item | Value |
|---|---|
| N1 mgmt0 | 192.168.100.1 |
| OPS | 192.168.100.10 |
| Login | admin, password Cl@ssLab1 |
| NX-API URL | http://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
- Start the lab
- Switch on NX-API
- The first call
- XML and JSON-RPC
- Change the switch from Python
- The Bash shell
- Python on the switch
- Guest Shell
- 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.
Every link, as text
- N1
e0to MGMT (network) - OPS
eth0to MGMT (network)
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| N1 | Cisco Nexus 9000v | nxosv9k-9300v-9.3.10 | 2 vCPU, 6,144 MB |
| OPS | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Cisco Nexus NX-OS data centre guided labs.Open
09 - NX-API on-box Python Bash and Guest Shelland 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.