VMware Cloud Community
jonathanvh
Enthusiast
Enthusiast
Jump to solution

Remaining capacity for cluster via REST API vRealize Operations Manager

Hello,

We have automated the VM deployement via vRealize Orchestrator.

And now we do our capacity calculations ourselves via custom calculations in vRealize Orchestrator.

We calculate how many CPU/MEM we have left, per cluster, and then select the best cluster for deploying the VM on.

But now we want to use vRealize Operations Manager to do this task.

The numbers in there are very similar as our own calculations.

But I'm really struggling to find it via the API.

Anybody has an idea, or already does it via API?

The only info I can find related to the cluster via API is this:

<ops:badge type="CAPACITY_REMAINING" color="ORANGE" score="1.3157894736842104"/>

Thanks!

2020-09-16 11_37_46.png

1 Solution

Accepted Solutions
jonathanvh
Enthusiast
Enthusiast
Jump to solution

I've managed to find it myself

I'll paste the solution I've found:

First get the object ID from the name:

GET https://url_vrom/suite-api/api/resources?name=CLUSTER_NAME

{

    "pageInfo": {

        "totalCount": 1,

        "page": 0,

        "pageSize": 1000

    },

...

            "relatedResources": [],

            "links": [

...

            ],

            "identifier": "1921bd16-5e01-4b5c-a5c9-2d4020777daa"     <== this ID is what we need

        }

    ]

}

To see what kind of information you can retrieve you should run the following:

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/statkeys

{

    "stat-key": [

...

{

            "key": "OnlineCapacityAnalytics|mem|alloc|capacityRemaining"

        },

...

{

            "key": "OnlineCapacityAnalytics|cpu|alloc|capacityRemaining"

        },

...

    ]

}

I only need those 2.

Do a GET for each value you need, I only need the last info, so that's why there is "latest" in the url:

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/stats/latest?statKey=O...

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/stats/latest?statKey=O...

Sample output:

{

    "values": [

        {

            "resourceId": "1921bd16-5e01-4b5c-a5c9-2d4020777daa",

            "stat-list": {

                "stat": [

                    {

                        "timestamps": [

                            1600267847497

                        ],

                        "statKey": {

                            "key": "OnlineCapacityAnalytics|cpu|alloc|capacityRemaining"

                        },

                        "data": [

                            10.0   <== These are the vCPU remaining on the cluster

                        ]

                    }

                ]

            }

        }

    ]

}

{

    "values": [

        {

            "resourceId": "1921bd16-5e01-4b5c-a5c9-2d4020777daa",

            "stat-list": {

                "stat": [

                    {

                        "timestamps": [

                            1600267847497

                        ],

                        "statKey": {

                            "key": "OnlineCapacityAnalytics|mem|alloc|capacityRemaining"

                        },

                        "data": [

                            7.36745024E8   <== amount of memory available in the cluster

                        ]

                    }

                ]

            }

        }

    ]

}

View solution in original post

1 Reply
jonathanvh
Enthusiast
Enthusiast
Jump to solution

I've managed to find it myself

I'll paste the solution I've found:

First get the object ID from the name:

GET https://url_vrom/suite-api/api/resources?name=CLUSTER_NAME

{

    "pageInfo": {

        "totalCount": 1,

        "page": 0,

        "pageSize": 1000

    },

...

            "relatedResources": [],

            "links": [

...

            ],

            "identifier": "1921bd16-5e01-4b5c-a5c9-2d4020777daa"     <== this ID is what we need

        }

    ]

}

To see what kind of information you can retrieve you should run the following:

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/statkeys

{

    "stat-key": [

...

{

            "key": "OnlineCapacityAnalytics|mem|alloc|capacityRemaining"

        },

...

{

            "key": "OnlineCapacityAnalytics|cpu|alloc|capacityRemaining"

        },

...

    ]

}

I only need those 2.

Do a GET for each value you need, I only need the last info, so that's why there is "latest" in the url:

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/stats/latest?statKey=O...

GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/stats/latest?statKey=O...

Sample output:

{

    "values": [

        {

            "resourceId": "1921bd16-5e01-4b5c-a5c9-2d4020777daa",

            "stat-list": {

                "stat": [

                    {

                        "timestamps": [

                            1600267847497

                        ],

                        "statKey": {

                            "key": "OnlineCapacityAnalytics|cpu|alloc|capacityRemaining"

                        },

                        "data": [

                            10.0   <== These are the vCPU remaining on the cluster

                        ]

                    }

                ]

            }

        }

    ]

}

{

    "values": [

        {

            "resourceId": "1921bd16-5e01-4b5c-a5c9-2d4020777daa",

            "stat-list": {

                "stat": [

                    {

                        "timestamps": [

                            1600267847497

                        ],

                        "statKey": {

                            "key": "OnlineCapacityAnalytics|mem|alloc|capacityRemaining"

                        },

                        "data": [

                            7.36745024E8   <== amount of memory available in the cluster

                        ]

                    }

                ]

            }

        }

    ]

}