cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1142
Views
0
Helpful
1
Replies

Python script on Nexus Sanbox is not workink for "show version"

Hi all,

I am play around with nexus 9k sanbox. I have copy and pasted the pyhon script suggested from sanbox and I am running it on my local machine. Below the script.

#!/usr/bin/env python

import requests

import json

url='http://10.10.20.58/ins'

switchuser='cisco'

switchpassword='cisco123'

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()

When I run it however I don't get any reply. Any idea why? nxapi is enabled on Nexus

federico@federico:~/git/network_automation $ python nexus_9k_test.py

federico@federico:~/git/network_automation $

1 Reply 1

yawming
Cisco Employee
Cisco Employee

Add a "print" statement to see output.