vROPS中虚拟机对象的ID为resourceID,跟vCenter中虚拟机的UUID是不一致的,因此想要将vROPS中的虚拟机和vCenter中的虚拟机对应肯定不能靠虚拟机名称,而是一定要靠UUID。
下面的示例显示如何通过vROPS API获取虚拟机在vCenter中的UUID
步骤1,获取vROPS Token
URL: https://vrops.vmware.com/suite-api/api/auth/token/acquireMethod: POSTContent-Type: application/jsonAccept: application/jsonBody: {"username":"admin","password":"VMware1!"}Response:
{ "token": "4971b55f-68aa-47a0-a351-19fa751d59cb::5c1db8e3-90ec-44f4-87f7-ad986f358ca6", "validity": 1556219805813, "expiresAt": "Friday, April 26, 2019 3:16:45 AM CST", "roles": [] }
步骤2,获取虚拟机UUID
URL: https://vrops.dev-pso.com/suite-api/api/resources?name=000-001-OS-P003Method: GETAuthorization: vRealizeOpsToken {{token}}Accept: application/jsonResponse:
{ "pageInfo": { "totalCount": 1, "page": 0, "pageSize": 1000 }, "links": [ { "href": "/suite-api/api/resources?name=000-001-OS-P003&page=0&pageSize=1000", "rel": "SELF", "name": "current" }, { "href": "/suite-api/api/resources?name=000-001-OS-P003&page=0&pageSize=1000", "rel": "RELATED", "name": "first" }, { "href": "/suite-api/api/resources?name=000-001-OS-P003&page=0&pageSize=1000", "rel": "RELATED", "name": "last" } ], "resourceList": [ { "creationTime": 1555486851466, "resourceKey": { "name": "000-001-OS-P003", "adapterKindKey": "VMWARE", "resourceKindKey": "VirtualMachine", "resourceIdentifiers": [ { "identifierType": { "name": "VMEntityInstanceUUID", "dataType": "STRING", "isPartOfUniqueness": false }, "value": "50229f5c-74e6-9e0a-c3f4-a1d104e6fbe9" // vmUUID, 和VC中VM的virtualMachine.ConfigInfo.instanceUUID是一致的 }, { "identifierType": { "name": "VMEntityName", "dataType": "STRING", "isPartOfUniqueness": false }, "value": "000-001-OS-P003" }, { "identifierType": { "name": "VMEntityObjectID", "dataType": "STRING", "isPartOfUniqueness": true }, "value": "vm-601" }, { "identifierType": { "name": "VMEntityVCID", "dataType": "STRING", "isPartOfUniqueness": true }, "value": "e55e5bf7-06f7-4a77-9fb5-d16bcc4d5ecc" } ] }, "resourceStatusStates": [ { "adapterInstanceId": "e9e24f83-a735-4e8c-a974-0d01a2d9d681", "resourceStatus": "DATA_RECEIVING", "resourceState": "STARTED", "statusMessage": "" } ], "resourceHealth": "RED", "resourceHealthValue": 25, "dtEnabled": true, "badges": [ { "type": "HEALTH", "color": "RED", "score": 25 }, { "type": "CAPACITY_REMAINING", "color": "GREEN", "score": 66.13910915503129 }, { "type": "COMPLIANCE", "color": "GREY", "score": -1 }, { "type": "TIME_REMAINING", "color": "GREEN", "score": 366 }, { "type": "RISK", "color": "GREEN", "score": 0 }, { "type": "EFFICIENCY", "color": "GREEN", "score": 100 }, { "type": "WORKLOAD", "color": "GREEN", "score": 33.4913158416748 } ], "relatedResources": [], "links": [ { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93", "rel": "SELF", "name": "linkToSelf" }, { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93/relationships", "rel": "RELATED", "name": "relationsOfResource" }, { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93/properties", "rel": "RELATED", "name": "propertiesOfResource" }, { "href": "/suite-api/api/alerts?resourceId=40394dc8-2828-4277-85ef-15727e9c0e93", "rel": "RELATED", "name": "alertsOfResource" }, { "href": "/suite-api/api/symptoms?resourceId=40394dc8-2828-4277-85ef-15727e9c0e93", "rel": "RELATED", "name": "symptomsOfResource" }, { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93/statkeys", "rel": "RELATED", "name": "statKeysOfResource" }, { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93/stats/latest", "rel": "RELATED", "name": "latestStatsOfResource" }, { "href": "/suite-api/api/resources/40394dc8-2828-4277-85ef-15727e9c0e93/properties", "rel": "RELATED", "name": "latestPropertiesOfResource" }, { "href": "/suite-api/api/credentials/", "rel": "RELATED", "name": "credentialsOfResource" } ], "identifier": "40394dc8-2828-4277-85ef-15727e9c0e93" } ] }
原文地址:https://www.cnblogs.com/vincenshen/p/10771527.html
时间: 2024-10-12 16:32:51