Created
June 9, 2020 10:48
-
-
Save johnddias/e7375d18676612776fed9bebbeb0561c to your computer and use it in GitHub Desktop.
Get vROps Resource ID from UUID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
def getResourceId(context, inputs): | |
if "verify" not in inputs.keys(): | |
inputs["verify"] = True | |
headers = {'Content-type':'application/json','Accept':'application/json','Authorization':'vRealizeOpsToken '+ inputs["token"]} | |
payload = { | |
'propertyName':'summary|UUID', | |
'propertyValue':inputs["vmUUID"] | |
} | |
r = requests.request('GET','https://vrops-fielddemo.cmbu.local/suite-api/api/resources',params=payload, headers=headers, verify=inputs["verify"]) | |
print (r.text) | |
resource = json.loads(r.text) | |
if not resource["resourceList"]: | |
return() | |
else: | |
return(resource["resourceList"][0]["identifier"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment