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(host_response['id'])
flag = False
cluster_array = vcenter_datacenter['clusters']
for cluster in cluster_array:
href = cluster['href']
cluster_list.append(href)
if flag:
"""set operational context"""
set_operational_context(ip_address,vcenter_id, bearer_token, vc_username,
vc_domain, vc_password)
""" Found the host inside the clusters"""
cluster_flag = False
for cluster_href in cluster_list:
"""Get cluster details"""
cluster_details = get_cluster_details(cluster_href, bearer_token)
cluster_json_response = cluster_details.json()
hosts_list = cluster_json_response['hosts']
for host in hosts_list:
if host['hostip'] == hostIp:
host_response = json.dumps(host, indent=4, sort_keys=True)
print(host_response)
cluster_flag = True
break
if cluster_flag:
break;
if cluster_flag == False:
print("Host with serice tag " + hostIp + " not found.")
except:
print("get_vcenter_tree: Unexpected error:", sys.exc_info()[0])
def get_registered_vcenter_list(omivvIP,bearerToken):
"""Get all registered vcenter with this OMIVV"""
url ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/ConsoleService/Consoles"
head = {'Authorization': 'Bearer ' + bearerToken}
response = requests.get(url, verify=False, headers=head)
if(response.status_code == 200):
json_response = json.dumps(response.json(), indent=4, sort_keys=True)
return json_response;
else:
print("Get registered vCenter list failed")
def get_vcenter_tree_from_omivv(OMIVV_ip, vcenter_id, session_token):
url = "https://" + OMIVV_ip + "/Spectre/api/rest/v1/Services/ConsoleService/
Consoles/" + vcenter_id
head = {'Authorization': 'Bearer ' + session_token}
response = requests.get(url, verify=False, headers=head)
if (response.status_code == 200):
json_response = json.dumps(response.json(), indent=4, sort_keys=True)
return json_response
else:
print("Get registered vCenter list failed")
def get_cluster_details(url, session_token):
head = {'Authorization': 'Bearer ' + session_token}
response = requests.get(url, verify=False, headers=head)
if (response.status_code == 200):
return response
else:
print(response.status_code)
print("Get cluster details failed")
def set_operational_context(omivv_ip, vcenter_id, session_token, vcenter_username,
vcenter_domain, vcenter_password):
base_url = "https://" + omivv_ip + "/Spectre/api/rest/v1/Services/ConsoleService/
OperationalContext"
postBodyData = {"consoleId": vcenter_id,
"consoleUserCredential": {"username": vcenter_username, "domain":
vcenter_domain,
"password": vcenter_password}}
Use cases
21