VMware Cloud Community
VK2COT
Contributor
Contributor

vROps API via curl to collect some basic information

Hi dear community members,

I seek some advice and help in something that I thought would be simple originally but now find it a bit complex. I a not an expert on vROps, and my background is Unix/Linux.

Here is what I want to achieve:

1. Get list of VMs for each datastore and RDM (yes, we have some special clusters that use Raw Device Mappings),

2. Get list of all resources that VMs use (including RDMs),

3. Get tag information for all VMs (custom attributes),

4. Run a specific report based on reportdefinitions.

I can easily get the listing of datastores (I have not yet figured out how to get RDMs) and the VMs that use them (in CSV format). This was done on a Linux server:

#!/bin/sh

PATH=/usr/bin:/bin:/sbin; export PATH

VROPSSRV="vropsserver"

VROPSOPT1='Content-Type: application/json'

VROPSURL="suite-api/api/resources"

ESXLIST="$(curl -s -n -k -H $VROPSOPT1 -H 'Accept: application/json' "https://${VROPSSRV}/${VROPSURL}?resourceKind=HostSystem" | jq '.resourceList[] .resourceKey .name' | sed -e 's/"//g' | tr '[:space:]' " ")"

for esxhost in $(echo $ESXLIST)

do

   echo -n "$esxhost,"

   curl -s -n -k -H $VROPSOPT1 -H 'Accept: application/json' "https://${VROPSSRV}/${VROPSURL}?propertyName=summary|parentHost&propertyValue=$esxhost" | jq '.resourceList[] .resourceKey .name' | sed -e 's/"//g' -e 's/,//g' | tr '\n' ' '

   echo

done

exit

I am reading the API documents and am still in the dark how to progress.

I know that vROps offers lot of reports, but for some reason, somebody disabled all of them for us, which is pity:

$ curl -s -n -k -H 'Content-Type: application/json' -H "Accept: application/json" "https://vropsserver/suite-api/api/reports" | json_reformat

{

    "pageInfo": {

        "totalCount": 0,

        "page": 0,

        "pageSize": 1000

    },

    "links": [

        {

            "href": "/suite-api/api/reports?page=0&pageSize=1000",

            "rel": "SELF",

            "name": "current"

        },

        {

            "href": "/suite-api/api/reports?page=0&pageSize=1000",

            "rel": "RELATED",

            "name": "first"

        },

        {

            "href": "/suite-api/api/reports?page=0&pageSize=1000",

            "rel": "RELATED",

            "name": "last"

        }

    ],

    "reports": [

    ]

}

Best wishes and thank you in advance for any comments. All I have been given is a vROps account with obviously limited privileges.

Dusan

Reply
0 Kudos
0 Replies