API Guide
Table Of Contents
- OpenManage Integration for VMware vCenter Version 5.3 API Guide
- Overview
- Get started
- Security
- Use cases
- Session management
- License management
- Console management
- Repository profile management
- Cluster profile management
- Firmware repository inventory management
- Firmware inventory management
- Firmware update management
- System profile management
- Host management
- Get subsystem health report (OMIVV Host Health)
- Host management
- Request body
- Response body
- OMIVV-Specific error codes
print("Get registered vCenter list failed")
```
After you get the list of registered vCenters, set the vCenter context.
Sample code to set the vCenter context:
```json
def setOperationalContext(omivvIP, bearerToken, vcenterId,
vcenterUsername,vCenterDomain, vCenterPassword):
url ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/ConsoleService/
OperationalContext"
postBodyData={"consoleId" : vcenterId, "consoleUserCredential":
{"username":vcenterUsername,"domain" : vCenterDomain,"password" : vCenterPassword}}
head = {'Authorization': 'Bearer ' + bearerToken}
jsonReponse = requests.post(url, json=postBodyData, verify=False,headers=head)
if(jsonReponse.status_code == 204):
return pass;
else:
print("setOperationalContext failed.")
pass
```
3. Identify system ID of the host for retrieving repository inventory. To get the repository inventory for the host, identify the
host ID based on the Service Tag of the host, and then retrieve the system ID using host ID.
Invoke the /services/consoleServices/Console/{1d}/Hosts?
serviceTags={serviceTag1}&servicetas={serviceTags2} API to get the host ID.
Sample code to get the Host ID:
```
def get_host_id_from_serviceTag(omivvIP, bearerToken, vcenter_ip,host_servicetag):
url ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/ConsoleService/
Consoles"
head = {'Authorization': 'Bearer ' + bearerToken}
response = requests.get(url, verify=False, headers=head)
print(response)
if(response.status_code == 200):
json_response = json.dumps(response.json(), indent=4, sort_keys=True)
registered_vc_array = json.loads(json_response)
for vc in registered_vc_array:
if vcenter_ip.upper() == vc['ip'].upper():
vcenter_id = vc['id']
url = "https://" + omivvIP + "/Spectre/api/rest/v1/Services/
ConsoleService/Consoles/" + vcenter_id + "/Hosts?serviceTags=" + host_servicetag
head = {'Authorization': 'Bearer ' + bearerToken}
print(url)
response = requests.get(url, verify=False, headers=head)
print(response)
if (response.status_code == 200):
json_response = json.dumps(response.json(), indent=4,
sort_keys=True)
print(json_response)
return json_response
else:
print("Get host details failed")
else:
print("Get registered vCenter list failed")
```
Invoke the /services/consoleServices/Consoles/{id}/Hosts/{hostid} to get the system ID.
Sample code to get the system ID:
```
def get_vcenter_tree_from_omivv(omivvIP, bearerToken, vcenter_ip,host_id):
url ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/ConsoleService/
Consoles"
head = {'Authorization': 'Bearer ' + bearerToken}
response = requests.get(url, verify=False, headers=head)
Use cases
25