Forum Discussion
Gouri
Nimbostratus
Jun 29, 2016Direct URIs for iControlREST calls
I am a newbie and was trying to get my feet wet with REST calls. As such, I am writing (rather attempting to write) a simple call which will get me the serial and the installed version from a LTM. ...
matthew_wedlow_
Nimbostratus
Nov 01, 2018If you are trying to get the serial number out of the JSON output you can simply walk through the nested JSON until you get to what you're looking for.
Example for Serial Number path
["entries"]["https://localhost/mgmt/tm/sys/hardware/system-info"]["nestedStats"]["entries"]["https://localhost/mgmt/tm/sys/hardware/system-info/0"]["nestedStats"]["entries"]["bigipChassisSerialNum"]["description"]
So in python 2.7 using requests it would look like this
import json
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) Fixes certificate warning BS
def GetSerial(URI):
request = requests.session()
request.auth = ('USERNAME' , 'PASSWORD')
request.verify = False
request.headers.update({'Content-Type':'application/json'})
response = request.get(URI)
data = response.json()
parse the JSON output for the Serial Number
print (data["entries"]["https://localhost/mgmt/tm/sys/hardware/system-info"]["nestedStats"]["entries"]["https://localhost/mgmt/tm/sys/hardware/system-info/0"]["nestedStats"]["entries"]["bigipChassisSerialNum"]["description"])
uri = 'https://X.X.X.X/mgmt/tm/sys/hardware'
GetSerial(uri)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects