Dell OpenManage Integration for VMware vCenter Owner's manual

Type
Owner's manual
OpenManage Integration for VMware
vCenter Version 5.3
API Guide
March 2021
Rev. A00
Notes, cautions, and warnings
NOTE: A NOTE indicates important information that helps you make better use of your product.
CAUTION: A CAUTION indicates either potential damage to hardware or loss of data and tells you how to avoid
the problem.
WARNING: A WARNING indicates a potential for property damage, personal injury, or death.
© 2010 - 2021 Dell Inc. or its subsidiaries. All rights reserved. Dell, EMC, and other trademarks are trademarks of Dell Inc. or its subsidiaries.
Other trademarks may be trademarks of their respective owners.
Chapter 1: Overview...................................................................................................................... 6
Access OMIVV API documentation on Dell Technologies API marketplace..........................................................6
What is new in this release................................................................................................................................................6
Chapter 2: Get started.................................................................................................................. 9
Prerequisites......................................................................................................................................................................... 9
Base URI................................................................................................................................................................................ 9
Request headers.................................................................................................................................................................. 9
Rate limit................................................................................................................................................................................9
Chapter 3: Security...................................................................................................................... 11
OMIVV authentication....................................................................................................................................................... 11
Bearer Token..................................................................................................................................................................11
vCenter authorization....................................................................................................................................................... 12
Validate session token.................................................................................................................................................12
Validate vCenter user credentials ........................................................................................................................... 12
Chapter 4: Use cases................................................................................................................... 13
Navigate vCenter heirachy.............................................................................................................................................. 13
Retrieve firmware repository data................................................................................................................................ 24
Update firmware using catalogs.................................................................................................................................... 27
Retrieve OMIVV license information............................................................................................................................ 29
Compute server drift from baseline...............................................................................................................................31
Monitor component health in OMIVV.......................................................................................................................... 35
Chapter 5: Session management..................................................................................................37
Start an OMIVV session...................................................................................................................................................37
End an OMIVV session..................................................................................................................................................... 38
Chapter 6: License management..................................................................................................39
Get list of vCenter and host license ............................................................................................................................39
Get vCenter and hosts license details......................................................................................................................... 40
Upload license to OMIVV................................................................................................................................................ 40
Chapter 7: Console management................................................................................................. 42
Get list of registered vCenters...................................................................................................................................... 42
Get list of all hosts in vCenter........................................................................................................................................43
Get host details..................................................................................................................................................................43
Get vCenter tree view of data center..........................................................................................................................44
Set vCenter context.........................................................................................................................................................45
Get cluster details............................................................................................................................................................. 46
Get cluster health..............................................................................................................................................................47
Chapter 8: Repository profile management................................................................................. 49
Contents
Contents 3
Get list of repository profiles..........................................................................................................................................49
Get repository profile details..........................................................................................................................................50
Create a new repository profile...................................................................................................................................... 51
Modify or edit repository profile....................................................................................................................................52
Chapter 9: Cluster profile management....................................................................................... 54
Get list of cluster profiles................................................................................................................................................54
Get details of cluster profiles......................................................................................................................................... 54
Chapter 10: Firmware repository inventory management............................................................. 57
Get firmware repository inventory details...................................................................................................................57
Chapter 11: Firmware inventory management.............................................................................. 59
Create host level firmware inventory report.............................................................................................................. 59
Create cluster level firmware inventory report..........................................................................................................60
Chapter 12: Firmware update management.................................................................................. 63
Create host level firmware update jobs.......................................................................................................................63
Create cluster level firmware update jobs.................................................................................................................. 64
Get list of firmware update jobs (Host and Cluster)................................................................................................65
Get firmware update job details (Host or Cluster)................................................................................................... 66
Delete firmware update job.............................................................................................................................................67
Cancel firmware update job............................................................................................................................................68
Chapter 13: System profile management..................................................................................... 70
Get list of system profiles............................................................................................................................................... 70
Get system profile details................................................................................................................................................70
Chapter 14: Drift management..................................................................................................... 72
Get all drift detection job.................................................................................................................................................72
Get specified drift detection job....................................................................................................................................73
Get drift report for all clusters....................................................................................................................................... 74
Get drift report for specific cluster.............................................................................................................................. 75
Get firmware drift report ............................................................................................................................................... 76
Get driver drift report...................................................................................................................................................... 78
Get configuration drift report ....................................................................................................................................... 79
Gets host details on specified drift detection jobs.................................................................................................... 81
Chapter 15: Get subsystem health report (OMIVV Host Health)...................................................82
Chapter 16: Host management.....................................................................................................84
Get the host overview..................................................................................................................................................... 84
Get host firmware inventory.......................................................................................................................................... 85
Get host warranty.............................................................................................................................................................86
Get alarms and events..................................................................................................................................................... 87
Set alarms and events......................................................................................................................................................88
Get host power supply information.............................................................................................................................. 88
Get host memory information........................................................................................................................................ 89
Get host processors information...................................................................................................................................90
4
Contents
Appendix A: Request body........................................................................................................... 92
Appendix B: Response body.........................................................................................................96
Appendix C: OMIVV-Specific error codes....................................................................................112
Contents 5
Overview
OpenManage Integration for VMware vCenter (OMIVV) provides RESTful APIs to enable automation. The support for RESTful
API is available from version 5.2.0. The APIs are compliant with OpenAPI Specification (OAS) 3.0.0.
This document is intended for a vCenter Administrator. It is assumed that the reader is familiar with REST APIs and
programmatic interaction with REST APIs. Any programming language can be used to create applications that interface with
these APIs. You can run the APIs using an API Client such as Curl or Postman.
OMIVV sample API scripts are available at https://github.com/dell/omivv.
Topics:
Access OMIVV API documentation on Dell Technologies API marketplace
What is new in this release
Access OMIVV API documentation on Dell
Technologies API marketplace
About this task
The API documentation for OMIVV 5.2 and later versions is now available on the Dell Technologies API Marketplace. To access
the OMIVV API documentation:
Steps
1. Go to https://api-marketplace.dell.com/.
2. Click Explore API and then click APIs.
3. Under Filter by Categories, select Infrastructure.
4. Under Filter By API Access, select Public.
5. Under Filter By API Type, select Catalog.
The OMIVV API is displayed.
6. Click View More.
What is new in this release
Table 1. List of new and enhanced APIs
Summary of new APIs APIs
License management
GET to retrieve list of all licenses uploaded in OMIVV
and details by license ID
POST for uploading new licenses (in XML file format)
to OMIVV
(GET)/Services/LicenseService/Licenses
Gets list of all licenses uploaded in OMIVV
(GET)/Services/LicenseService/Licenses/
{id}Gets license details using license ID
(POST)/Services/LicenseService/Licenses
Uploads new license in XML file format to OMIVV
Console management
GET for all the hosts in a given vCenter and the details
of a particular host
(GET)/Services/ConsoleService/Consoles/
{id}/Hosts?serviceTags={service Tag1}&
serviceTags={serviceTag2}Gets the list of all
the hosts registered in a vCenter for the given OMIVV IP.
1
6 Overview
Table 1. List of new and enhanced APIs (continued)
Summary of new APIs APIs
(GET)/Services/ConsoleService/Consoles/
{id}/Hosts/{hostid}Gets details of a particular
host in a vCenter.
Repository Profile Management
POST for creating a new repository profile
PUT for modifying existing repository profiles
(POST)/Services/PluginProfileService/
RepositoryProfilesCreates a new repository
profile
(PUT)/Services/PluginProfileService/
RepositoryProfilesModifies repository profile
Cluster Profile Management
Enhancement to existing GET, added information about
the drift job details of a given cluster profile
(GET)/Services/PluginProfileService/
ClusterProfiles/{id}Gets the details
of a given cluster profile. Added information
about the drift job details of a given cluster profile.
Firmware Update Management
DELETE to remove a specific successful, failed, or
cancelled firmware update job
PUT to cancel a host firmware update job
(DELETE)/Services/UpdateService/Jobs/{id}
Deletes specific firmware update job
(PUT)/Services/UpdateService/Jobs/{id}/
CancelCancels host firmware update job
System Profile Management
Enhancement to existing GET, added reference server
information to the response as well as ability to get
details of specific profile ID
(GET)/Services/PluginProfileService/
SystemProfilesGets the list of all
system profiles that are created in OMIVV
UI. Added reference server information to the response.
(GET)/Services/PluginProfileService/
SystemProfilesGets the details of the given system
profile ID. Added more details about reference server.
Drift Management
GET for all and specific drift detection jobs, including
host details within a specific job, a report for all
non-compliant hosts, or specific firmware, driver, or
configuration only reports
(GET)/Services/DriftDetectionService/
DriftReport/{id}/DriverDriftDetailsGets
the driver drift details of a specific vSAN cluster ID.
(GET)/Services/DriftDetectionService/
DriftReport/{id}/ConfigurationDriftDetails
Gets the configuration drift (system profile
drift) details of a specific cluster ID.
Ensure that system profile is created using OMIVV UI.
(GET)/Services/DriftDetectionService/
DriftReportGets the drift report of
all the clusters that are non-compliant.
(GET)/Services/DriftDetectionService/Jobs/
{id}Gets specified drift detection job.
(GET)/Services/DriftDetectionService/Jobs
Gets all drift detection jobs.
(GET)/Services/DriftDetectionService/Jobs/
{id}/DetailsGets host details on specified drift
detection jobs
(GET)/Services/DriftDetectionService/
DriftReport/{cluster-id}Gets the drift report
of a specific cluster ID. The drift details includes firmware,
driver, and configuration details of the given cluster ID.
Subsystem Health report
GET to report on the health of iDRAC tracked
subsystems, such as fans, power supply, and memory.
(GET)/Services/InventoryService/Hosts/
{id}/SubSystemHealthGets the health of
the server components such as Fan, Power
Supply, and Memory.
Host Management
GET for the host overview, firmware inventory details,
warranty information, power supplies, host memory,
host processors.
(GET)/Services/ConsoleService/
AlarmsAndEventsGets alarms and events details
(GET)/Services/ConsoleService/
AlarmsAndEventsSets alarms and events
Overview 7
Table 1. List of new and enhanced APIs (continued)
Summary of new APIs APIs
GET and PUT to see and enable and disable alarms and
events, including new Memory Page Retire events
(GET)/Services/InventoryService/Hosts/
{id}/HostOverviewGets the host overview
(GET)/Services/InventoryService/Hosts/
{id}/FirmwareInventoryGets the host firmware
inventory details
(GET)/Services/InventoryService/Hosts/
{id}/WarrantyGets the host warranty details
(GET)/Services/InventoryService/Hosts/
{id}/Hardware/PowerSuppliesGets the host
power supplies
(GET)/Services/InventoryService/Hosts/
{id}/Hardware/ProcessorsGets the host
processors
(GET)/Services/InventoryService/Hosts/
{id}/Hardware/MemoriesGets the information
about the host memories.
8 Overview
Get started
Topics:
Prerequisites
Base URI
Request headers
Rate limit
Prerequisites
Ensure that:
User profile used to access API has administrator privileges
vCenter profile has required Dell privileges. For more information, see the Required privileges for non-administrator
users topic in User's Guide.
Host Credential Profile, Cluster Profile, and System Profile are created in OMIVV User Interface (UI) and use the profiles
as required. For more information, see the Create Host Credential Profile, Create Cluster Profile, and Create System
Profile topics in User's Guide.
The hosts are management-complaint. For more information, see the Management Compliance topic in User's Guide.
Base URI
The base URI for any OMIVV RESTful API request must be in the following format:
https://{OMIVV Address}/Spectre/api/rest/v1/Services/
OMIVV Address: IPv4 address or Fully Qualified Domain Name (FQDN).
NOTE: All the URIs and query parameters are case-sensitive.
Request headers
The request header represents headers in the client HTTPS request that are used to communicate client preferences to the
service end-point. The bearer token is the request header.
Rate limit
At a given time, only three unique client IPs can be active and can create total ten sessions.
OMIVV supports 100 requests per minute. If there are multiple sessions, make sure that each session has maximum 10 API
requests per minute in parallel. However, if there is a single session, parallel API requests can go up to 100 per minute.
If there are more than ten sessions, Request limit per minute exceeded message is sent to the API Client.
Each OMIVV session is correspond to one vCenter. Ensure that you sequence the communication if you have more than ten
vCenters registered in OMIVV because you can start only 10 sessions at a time.
The total number of failure login attempts that is allowed is six (count includes failed login attempts in administration console or
REST API or use of invalid token for REST API access). After six failed login attempts, the account gets locked.
The account lockout duration is one minute.
You cannot start a new session when the account is locked. But, current active session remains active.
2
Get started 9
During the lockout period, any REST API call will not work except logoff API. An appropriate error message is displayed.
10 Get started
Security
The authentication and authorization flows are prerequisites to any API invocation. The request is forwarded to the CXF server
defined for the REST API after the invocation.
If there is authorization and authentication failure, an appropriate error code with message is sent to the API client.
On success, the request is forwarded to the appropriate REST service endpoint (API) defined on the CXF servlet.
Topics:
OMIVV authentication
vCenter authorization
OMIVV authentication
OMIVV web server handles incoming web requests and routes them to the REST endpoints.
Authentication server performs the following:
Accepts login requests and provide the bearer token. This token is generated using the JWT scheme that includes a
header, body, and footer.
Accepts log out requests which closes the session
API server: Service all defined REST endpoints except endpoints that are related to authentication.
API clients establish a session with the API server using the endpoint: /Services/AuthenticationService/login.
OMIVV user credentials are required to authenticate a client of the RESTful API. Only user profile with admin privilege is allowed
to log in as an API user. Other user profiles with privileges like Read only cannot access the API.
Sample code to create an OMIVV session:
```json
def login_with_OMIVV (omivvIP,username,domain, password):
baseurl ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/AuthenticationService/
login"
postBodyData={"apiUserCredential" : {"username":username,"domain" :
domain,"password" : password}}
jsonReponse = requests.post(baseurl, json=postBodyData, verify=False)
if(jsonReponse.status_code == 200):
bearerToken = jsonReponse['accessToken']
return bearerToken
else:
print("Login failed")
```
omivvIP can be a valid OMIVV IP or FQDN.
Bearer Token
Each session that is created using an authentication service contains a bearer token that is generated using the JWT scheme.
Expiration period for bearer token is 60 minutes. If you are using the token after 60 minutes, Token is already expired
message is sent to the API client.
The account lockout duration is one minute. If an account lockout happens after creating the Bearer token, bearer token cannot
be used during lockout duration (one minute). After an account lockout duration, same Bearer token can be used until it expires.
3
Security 11
vCenter authorization
Authorization flow validates the following:
Session token
vCenter user credentials for the required permissions to run the API
Validate session token
OMIVV validates the token that is received from the API client against the following:
Tampering
Session validity
Validate vCenter user credentials
APIs are authorized against the vCenter user credentials, when required. Set an operational context which indicates the
registered vCenter and the associated user credentials.
An operation context is required to ensure the permissions available to the user. You can set an operation context by invoking
the corresponding API.
This context is unique to an OMIVV user session, and only a single context can be active for a session at a time. The different
OMIVV user sessions can invoke APIs using a different vCenter context.
The required vCenter user privileges for all other APIs are verified when you trigger the API.
The following is the sample code to set the operational 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.")
```
The vCenter user privilege is not required to access the following APIs:
/Services/AuthenticationService/login
/Services/AuthenticationService/logoff
/Services/ConsoleService/OperationalContext
/Services/ConsoleService/Consoles
/Services/ConsoleService/Consoles/{id}
12
Security
Use cases
Topics:
Navigate vCenter heirachy
Retrieve firmware repository data
Update firmware using catalogs
Retrieve OMIVV license information
Compute server drift from baseline
Monitor component health in OMIVV
Navigate vCenter heirachy
Prerequisites
Ensure that you have verified all the pre-requisites mentioned in the Prerequisites on page 9.
About this task
The vSphere Client lists all the registered vCenters, hosts, clusters, and datacenters in a hierarchical manner.
You can use OMIVV APIs to retrieve the required details of host, cluster, vCenter, and datacenter listed in the vSphere Client.
This topic describes how you can:
Retrieve host ID using Service Tag
Retrieve cluster ID using cluster name
Retrieve vCenter ID using vCenter IP
Retrive cluster ID for a given host ID
Get list of registered vCenters
Get host details
Retrieve host ID using Host IP
Retrieve host details using host ID
Steps
Start an OMIVV session using OMIVV user credentials. OMIVV credentials are required to authenticate a client of the RESTful
API.
For more information, see OMIVV authentication on page 11.
Retrieve host ID using Service Tag
Sample code to retrieve the host ID using Service Tag:
```json
def get_host_id_by_service_tag(bearer_token,ip_address, vcenter_ip, serviec_tag,
vc_username, vc_domain, vc_password):
"""Authenticate with OMIVV and enumerate reports."""
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, 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:
4
Use cases 13
if vcenter_ip.upper() == vc['ip'].upper():
vcenter_id = vc['id']
vcenter_tree_response = get_vcenter_tree_from_omivv(ip_address,vcenter_id,
bearer_token)
flag = True;
cluster_list = []
if vcenter_tree_response is not None:
vcenter_datacenters = json.loads(vcenter_tree_response)
vcenter_datacenters_List = vcenter_datacenters['datacenters']
for vcenter_datacenter in vcenter_datacenters_List:
hosts_list = vcenter_datacenter["hosts"]
if hosts_list is not None:
for host in hosts_list:
if host['serviceTag'] == serviec_tag:
host_response = json.dumps(host, indent=4,
sort_keys=True)
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['serviceTag'] == serviec_tag:
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 " + serviec_tag + " 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")
14
Use cases
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}}
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 cluster ID using cluster name
Sample code to retrieve the cluster ID:
```json
def get_cluster_id_by_cluster_name(bearer_token, ip_address, vcenter_ip, cluster_name):
"""Authenticate with OMIVV and enumerate reports."""
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, 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']
vcenter_tree_response = get_vcenter_tree_from_omivv(ip_address,vcenter_id,
bearer_token)
found = False
if vcenter_tree_response is not None:
vcenter_datacenters = json.loads(vcenter_tree_response)
vcenter_datacenters_List = vcenter_datacenters['datacenters']
for vcenter_datacenter in vcenter_datacenters_List:
cluster_list = vcenter_datacenter["clusters"]
if cluster_list is not None:
for cluster in cluster_list:
if cluster['name'] == cluster_name:
print("Cluster name: " + cluster_name + ", Cluster
id: " + cluster['id'])
found = True
break
if found:
break
if found == False:
print("Cluster " + cluster_name + " not found.")
""" Log out from OMIVV """
logout(ip_address, bearer_token)
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):
Use cases
15
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")
```
Retrieve vCenter ID using vCenter IP
Sample code retrieve the vCenter ID using the vCenter IP:
```json
def get_vcenter_id(bearer_token, ip_address, vcenter_ip):
"""Authenticate with OMIVV and enumerate reports."""
try:
bearer_token = get_bearer_token(ip_address, user_name, password)
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, bearer_token)
if(registered_vcenter_list is None):
print("No vcenter is regsitered with this OMIVV")
return
else:
registered_vc_array = json.loads(registered_vcenter_list)
for vc in registered_vc_array:
if vcenter_ip.upper() == vc['ip'].upper():
print(vc['id'])
break
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")
```
Retrieve cluster ID for a given host ID
Sample code to retrive the cluster ID using host ID:
```json
def get_cluster_id_by_host_id(bearer_token, ip_address, vcenter_ip, host_id,
vc_username, vc_domain, vc_password):
"""Authenticate with OMIVV and enumerate reports."""
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, bearer_token)
if(registered_vcenter_list is None):
print("No vcenter is regsitered with this OMIVV")
return
else:
16
Use cases
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']
vcenter_tree_response = get_vcenter_tree_from_omivv(ip_address,vcenter_id,
bearer_token)
flag = True;
cluster_list = []
dacenter_name = "";
if vcenter_tree_response is not None:
vcenter_datacenters = json.loads(vcenter_tree_response)
vcenter_datacenters_List = vcenter_datacenters['datacenters']
for vcenter_datacenter in vcenter_datacenters_List:
hosts_list = vcenter_datacenter["hosts"]
if hosts_list is not None:
for host in hosts_list:
if host['id'] == host_id:
datacenter_name = vcenter_datacenter['name']
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
cluster_id = "";
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['id'] == host_id:
host_response = json.dumps(host, indent=4, sort_keys=True)
cluster_flag = True
print("Host id: " + host_id + ", cluster id: " +
cluster_json_response['id'])
break
if cluster_flag:
break;
if cluster_flag == False:
print("Host with host id " + host_id + " not found.")
else:
print("Host is not inside a cluster. It is inside the datacenter: " +
datacenter_name)
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}
Use cases
17
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}}
head = {'Authorization': 'Bearer ' + session_token}
jsonReponse = requests.post(base_url, json=postBodyData, verify=False, headers=head)
if (jsonReponse.status_code != 204):
print("setOperationalContext failed.")
```
Get list of registered vCenters
Sample code to get the list of registered vCenters:
```json
def get_regitered_vcenter(bearer_token,ip_address, vcenter_ip, serviec_tag, vc_username,
vc_domain, vc_password):
"""Authenticate with OMIVV and enumerate reports."""
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, bearer_token)
if(registered_vcenter_list is None):
print("No vcenter is regsitered with this OMIVV")
return
else:
print(registered_vcenter_list)
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")
```
Get host details
Sample code to get the host details:
```json
def get_host_detail_by_service_tag(bearer_token,ip_address, vcenter_ip, serviec_tag,
vc_username, vc_domain, vc_password):
"""Authenticate with OMIVV and enumerate reports."""
18
Use cases
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, 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']
vcenter_tree_response = get_vcenter_tree_from_omivv(ip_address,vcenter_id,
bearer_token)
flag = True;
cluster_list = []
if vcenter_tree_response is not None:
vcenter_datacenters = json.loads(vcenter_tree_response)
vcenter_datacenters_List = vcenter_datacenters['datacenters']
for vcenter_datacenter in vcenter_datacenters_List:
hosts_list = vcenter_datacenter["hosts"]
if hosts_list is not None:
for host in hosts_list:
if host['serviceTag'] == serviec_tag:
host_response = json.dumps(host, indent=4,
sort_keys=True)
print(host_response)
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['serviceTag'] == serviec_tag:
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 " + serviec_tag + " 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")
Use cases
19
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}}
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 ID using Host IP
Sample code to retrieve the host ID:
```json
def get_host_id_by_service_tag(bearer_token,ip_address, vcenter_ip, hostIp, vc_username,
vc_domain, vc_password):
"""Authenticate with OMIVV and enumerate reports."""
try:
""" Get all registered vcenter """
registered_vcenter_list = get_registered_vcenter_list(ip_address, 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']
vcenter_tree_response = get_vcenter_tree_from_omivv(ip_address,vcenter_id,
bearer_token)
flag = True;
cluster_list = []
if vcenter_tree_response is not None:
vcenter_datacenters = json.loads(vcenter_tree_response)
vcenter_datacenters_List = vcenter_datacenters['datacenters']
for vcenter_datacenter in vcenter_datacenters_List:
hosts_list = vcenter_datacenter["hosts"]
if hosts_list is not None:
for host in hosts_list:
if host['hostip'] == hostIp:
host_response = json.dumps(host, indent=4,
sort_keys=True)
20
Use cases
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57
  • Page 58 58
  • Page 59 59
  • Page 60 60
  • Page 61 61
  • Page 62 62
  • Page 63 63
  • Page 64 64
  • Page 65 65
  • Page 66 66
  • Page 67 67
  • Page 68 68
  • Page 69 69
  • Page 70 70
  • Page 71 71
  • Page 72 72
  • Page 73 73
  • Page 74 74
  • Page 75 75
  • Page 76 76
  • Page 77 77
  • Page 78 78
  • Page 79 79
  • Page 80 80
  • Page 81 81
  • Page 82 82
  • Page 83 83
  • Page 84 84
  • Page 85 85
  • Page 86 86
  • Page 87 87
  • Page 88 88
  • Page 89 89
  • Page 90 90
  • Page 91 91
  • Page 92 92
  • Page 93 93
  • Page 94 94
  • Page 95 95
  • Page 96 96
  • Page 97 97
  • Page 98 98
  • Page 99 99
  • Page 100 100
  • Page 101 101
  • Page 102 102
  • Page 103 103
  • Page 104 104
  • Page 105 105
  • Page 106 106
  • Page 107 107
  • Page 108 108
  • Page 109 109
  • Page 110 110
  • Page 111 111
  • Page 112 112
  • Page 113 113
  • Page 114 114
  • Page 115 115
  • Page 116 116
  • Page 117 117
  • Page 118 118

Dell OpenManage Integration for VMware vCenter Owner's manual

Type
Owner's manual

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI