1 Reply Latest reply on Sep 17, 2020 12:08 AM by jonathanvh

    Remaining capacity for cluster via REST API vRealize Operations Manager

    jonathanvh Enthusiast

      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. Re: Remaining capacity for cluster via REST API vRealize Operations Manager
          jonathanvh Enthusiast

          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=OnlineCapacityAnalytics|cpu|alloc|capacityRemaining

          GET https://url_vrom/suite-api/api/resources/1921bd16-5e01-4b5c-a5c9-2d4020777daa/stats/latest?statKey=OnlineCapacityAnalytics|mem|alloc|capacityRemaining

           

           

          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
                                  ]
                              }
                          ]
                      }
                  }
              ]
          }
          
          1 person found this helpful