I thought I’d start with a quick “how to” demo for Cisco’s Nexus9000 NX-API. Since I’m not in marketing I probably won’t do too many videos. However, for NX-API I really wanted to capture everyone’s attention and what better way then in video format!
Below is the code snippet from the video:
import requests import json """ Modify these please """ url='IP_ADDRESS' switchuser='USERNAME' switchpassword='PASSWORD' myheaders={'content-type':'application/json-rpc'} payload=[{ "jsonrpc": "2.0", "method": "cli", "params": { "cmd": "show version", "version": 1 }, "id": 1 }] response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json() # pretty print the JSON object print json.dumps(response , sort_keys=True, indent=4, separators=(',', ': '))
One thought on “NX-API Part 1”