zoukankan      html  css  js  c++  java
  • 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/acquire
    Method: POST
    Content-Type: application/json
    Accept: application/json
    Body: {"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-P003
    Method: GET
    Authorization: vRealizeOpsToken {{token}}
    Accept: application/json
    Response:
    {
        "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"
            }
        ]
    }
  • 相关阅读:
    Ubuntu(Debian)的aptitude与aptget的区别和联系
    安装lxml相关
    解决Ubuntu 12.04更新后 ”系统的网络服务与此版本的网络管理器不兼容“问题
    Windows下配置Nginx代理Django
    scons入门笔记
    git仓库合并(向原有git仓库中加入新仓库)
    asterisk源码分析(main函数)
    live555源码编译(win7+vs2010)
    asterisk源码目录结构
    小试一题
  • 原文地址:https://www.cnblogs.com/vincenshen/p/10771527.html
Copyright © 2011-2022 走看看