API Guide

Table Of Contents
head = {'Authorization': 'Bearer ' + session_token}
jsonReponse = requests.post(base_url, json=postBodyData, verify=False, headers=head)
if (jsonReponse.status_code != 204):
print("setOperationalContext failed.")
```
Retrieve host details using host ID
Retrieve the host IP, hostname, management IP, ServiceTag, model, and system ID for a host using host ID.
host IP: Hypervisor IP address
hostname: DNS host name of the hypervisor. If hostName is not configured value will be empty.
management IP : iDRAC IP address of the server
ServiceTag : Service tag of the server
model : Dell Technologies server model
system ID : Unique ID used to determine the server model. Server model will be same for all servers of a particular model
Sample code to retrieve the host details using host ID:
```json
def get_vcenter_tree(ip_address, user_name, password, bearer_token, vcenter_ip,
vc_username, vc_domain, vc_password, host_id, details):
"""Authenticate with OMIVV and enumerate reports."""
try:
local_bearer_token=None
if(bearer_token == None):
local_bearer_token = get_bearer_token(ip_address, user_name, password)
else:
local_bearer_token = bearer_token
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address,
local_bearer_token)
if(registered_vcenter_list is None):
print("No vcenter is regsitered with this OMIVV")
return
else:
vcenter_id = None;
registered_vc_array = json.loads(registered_vcenter_list)
for vc in registered_vc_array:
if vcenter_ip.upper() == vc['ip'].upper():
vcenter_id = vc['id']
#Set operational Context.
set_operational_context(ip_address, vcenter_id, local_bearer_token,
vc_username, vc_domain, vc_password)
# Get host subsystem heath
if(host_id is None):
print("Pass the host_id")
else:
get_host_details(ip_address, local_bearer_token, host_id, details)
""" Log out from OMIVV """
if(bearer_token == None):
logout(ip_address, local_bearer_token)
except:
traceback.print_exc()
print("get_vcenter_tree: Unexpected error:", sys.exc_info()[0])
def get_bearer_token(ip_address, user_name, password):
try:
baseurl = "https://" + ip_address + "/Spectre/api/rest/v1/Services/
AuthenticationService/login"
postBodyData = {"apiUserCredential": {"username": user_name, "domain": "",
"password": password}}
response = requests.post(baseurl, json=postBodyData, verify=False)
if (response.status_code == 200):
json_response = response.json()
bearerToken = json_response['accessToken']
return bearerToken
else:
print("Login to OMIVV failed")
22
Use cases