vROPS中获取虚拟机在VC中的UUID

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-08-02 09:02:07

vROPS中获取虚拟机在VC中的UUID的相关文章

C++ 中获取 可变形参函数中的参数

#include <iostream> #include <stdarg.h> using namespace std; int ArgFunc(const char * str, ...) { va_list ap; // 定义参数列表变量 va_start(ap, str); // 确定参数位置,表明从 str 开始获取参数 // 开始获取参数 var_arg(ap, 数据类型) 返回获取的值 cout<<va_arg(ap, int)<<endl; c

从O365中获取users到D365中 使用flow

在我上篇blog中讲解到了怎么用代码把O365 users 获取到D365中. 从O365中获取users到D365中 这几天一直在研究flow, 发现flow可以更简单的完成这个功能. 一开始没有考虑用flow是因为flow获取所有用户的方式比较困难, 需要有个workaround (首先需要把所有用户添加到一个group当中,然后获取group member list) 首先我们需要使用Search for users (v2) 只有V2 版本可以直接获取所有的users 在一个list当中

spring中获取dao或对象中方法的实例化对象

spring中获取dao的中方法的实例化对象: 1 //获取应用上下文对象 2 ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml"); 3 //例子:获取dicDao实例 4 dicDao = ctx.getBean(IDicDao.class); //例子2:获取MemcacheAccess的实例: 5 memcachedAccess = ctx.getBean(Memcach

spring boot拦截器中获取request post请求中的参数

最近有一个需要从拦截器中获取post请求的参数的需求,这里记录一下处理过程中出现的问题. 首先想到的就是request.getParameter(String )方法,但是这个方法只能在get请求中取到参数,post是不行的,后来想到了使用流的方式,调用request.getInputStream()获取流,然后从流中读取参数,如下代码所示: String body = ""; StringBuilder stringBuilder = new StringBuilder(); Buf

C++ 中获取 可变形參函数中的參数

#include <iostream> #include <stdarg.h> using namespace std; int ArgFunc(const char * str, ...) { va_list ap; // 定义參数列表变量 va_start(ap, str); // 确定參数位置.表明从 str 開始获取參数 // 開始获取參数 var_arg(ap, 数据类型) 返回获取的值 cout<<va_arg(ap, int)<<endl; c

javascript中获取字符串或数组中元素的索引

有些时候,我们需要知道一个字符串中字符的位置,或者一个数组中元素的位置,这是就需要对该变量进行迭代操作. 对于数组,有两个方法indexOf和findIndex() , 需要注意的是,findIndex是数组的方法,不适用于字符串 1 let arr = ['a' ,'b', 'c'] 2 let idx = arr.findIndex((item) => { 3 return item == 'b' 4 }) 5 console.log(arr.indexOf('c')); // 2 6 co

VS中的路径宏 vc++中OutDir、ProjectDir、SolutionDir各种路径

$(RemoteMachine) 设置为“调试”属性页上“远程计算机”属性的值.有关更多信息,请参见更改用于 C/C++ 调试配置的项目设置. $(References) 以分号分隔的引用列表被添加到项目中. $(ConfigurationName) 当前项目配置的名称(例如“Debug”). $(PlatformName) 当前项目平台的名称(例如“Win32”). $(Inherit) 指定在由项目生成系统所撰写的命令行中,继承的属性出现的顺序.默认情况下,继承的属性出现在当前属性的末尾.

【转载】VS中的路径宏 vc++中OutDir、ProjectDir、SolutionDir各种路径

原文:http://www.cnblogs.com/lidabo/archive/2012/05/29/2524170.html 说明 $(RemoteMachine) 设置为“调试”属性页上“远程计算机”属性的值.有关更多信息,请参见更改用于 C/C++ 调试配置的项目设置. $(References) 以分号分隔的引用列表被添加到项目中. $(ConfigurationName) 当前项目配置的名称(例如“Debug”). $(PlatformName) 当前项目平台的名称(例如“Win32

(转)VS中的路径宏 vc++中OutDir、ProjectDir、SolutionDir各种路径说明

$(RemoteMachine) 设置为“调试”属性页上“远程计算机”属性的值.有关更多信息,请参见更改用于 C/C++ 调试配置的项目设置. $(References) 以分号分隔的引用列表被添加到项目中. $(ConfigurationName) 当前项目配置的名称(例如“Debug”). $(PlatformName) 当前项目平台的名称(例如“Win32”). $(Inherit) 指定在由项目生成系统所撰写的命令行中,继承的属性出现的顺序.默认情况下,继承的属性出现在当前属性的末尾.