I have a python script that is getting the machine details for a portal using the following code:
response = urllib.urlopen(portalUrl+'/portaladmin/machines?f=json&token='+token).read()
jsonResponse = json.loads(response)
the jsonResponse is as follows when I print jsonResponse['machines']:
[{u'adminURL': u'https://10.10.24.94:7443/arcgis', u'machineName': u'10.10.24.94', u'role': u'standby'}, {u'adminURL': u'https://10.10.25.110:7443/arcgis', u'machineName': u'10.10.25.110', u'role': u'primary'}]
How do I create variables to get output separated into machineName1,role1 and machineName2, role2?
Thanks
Solved! Go to Solution.
I answered my own question but thought I would post the answer for completeness
response = urllib.urlopen(portalUrl+'/portaladmin/machines?f=json&token='+token).read()
jsonResponse = json.loads(response)
machineOneName = jsonResponse['machines'][0]['machineName']
machineTwoName = jsonResponse['machines'][1]['machineName']
machineOneRole = jsonResponse['machines'][0]['role']
machineTwoRole = jsonResponse['machines'][1]['role']
print (machineOneName, machineOneRole)
I answered my own question but thought I would post the answer for completeness
response = urllib.urlopen(portalUrl+'/portaladmin/machines?f=json&token='+token).read()
jsonResponse = json.loads(response)
machineOneName = jsonResponse['machines'][0]['machineName']
machineTwoName = jsonResponse['machines'][1]['machineName']
machineOneRole = jsonResponse['machines'][0]['role']
machineTwoRole = jsonResponse['machines'][1]['role']
print (machineOneName, machineOneRole)