VMware Cloud Community
CloudInfraTeam
Enthusiast
Enthusiast
Jump to solution

vRA 7.0.1 REST API Reservation Service - Getting computeResourceReservedMemory problem

Hello,

i've been making a vRO Workflow to automate Business Group, Entitlement and Reservation creation, and i've stumbled upon a problamatic behavior of the vRA REST API.

In the Reservation Creation part of my workflow, im using the vRA REST API Reservation Service in order to create the reservation.

The user requests how much memory and storage he wants the reservation assigned. before i create the reservation, i want to check if the requested memory + the already allocated memory from the requested Compute Resource, doesnt pass the physical memory available (we do not want to overprovison).

in the vRA GUI, i can see the fields "Physical", "Total Reserved", and "This Reservation".

when i do a GET of a specific reservation (with /reservation/#id#), i get the corresponding fields from the GUI, which are "computeResourceMemoryTotalSizeMB","computeResourceMemoryReservedTotalSizeMB, and "memoryReservedSizeMb"

I want to achieve the check i stated in paragraph 3 by doing a GET of a golden reservation (which serves as a template for creating the other reservations), get the "computeResourceMemoryReservedTotalSizeMB" field, and doing the math against the physical and requested memory.


However, the "computeResourceMemoryReservedTotalSizeMB" field doesnt get updated with the summation of other reservations that were added after the golden reservation was created/last updated. The only way i could make it to update was to manually go to the vRA GUI, Edit said reservation, and save it (Clicking "Finish" without changing anything).


I tried doing a PUT to the reservation with no changes to the JSON to try and trigger the field, but it didn't help.

I also tried doing a PUT and deleting the "computeResourceMemoryReservedTotalSizeMB" field, but it also didn't help.


Would like for a solution for this problem.. if not, is there maybe another way i can get this information (Total Reserved Memory of a Compute Resource)?


Thanks!



Reply
0 Kudos
1 Solution

Accepted Solutions
GrantOrchardVMw
Commander
Commander
Jump to solution

This may help.

1. POST https://{{vra-fqdn}}/reservation-service/api/data-service/schema/Infrastructure.Reservation.Virtual.vSphere/default/computeResource/values

Body: {}

That will return something like this:

{

  "values": [

    {

      "underlyingValue": {

        "type": "entityRef",

        "componentId": null,

        "classId": "ComputeResource",

        "id": "2183b391-b057-429b-b163-bb258a0ff868",

        "label": "Cluster Site A (vCenter)"

      },

      "label": "Cluster Site A (vCenter)"

    }

  ]

}

2. POST https://{{vra-fqdn}}/reservation-service/api/data-service/schema/Infrastructure.Reservation.Virtual.vSphere/default/reservationMemory/values

Body:

{

  "text" : "Element",

  "dependencyValues" : {

    "entries" : [

      {

        "key" : "computeResource",

        "value" : {

          "type" : "entityRef",

          "componentId" : null,

          "classId" : "ComputeResource",

          "id" : "2183b391-b057-429b-b163-bb258a0ff868", #update this id with the value from 1.

          "label" : "Cluster Site A (vCenter)"

        }

      }

    ]

  },

  "associateValue" : null

}

For the reservation Memory, you want:

/reservation/info with the appropriate filter. It's not retrievable per reservation.

Grant http://grantorchard.com

View solution in original post

Reply
0 Kudos
3 Replies
GrantOrchardVMw
Commander
Commander
Jump to solution

This may help.

1. POST https://{{vra-fqdn}}/reservation-service/api/data-service/schema/Infrastructure.Reservation.Virtual.vSphere/default/computeResource/values

Body: {}

That will return something like this:

{

  "values": [

    {

      "underlyingValue": {

        "type": "entityRef",

        "componentId": null,

        "classId": "ComputeResource",

        "id": "2183b391-b057-429b-b163-bb258a0ff868",

        "label": "Cluster Site A (vCenter)"

      },

      "label": "Cluster Site A (vCenter)"

    }

  ]

}

2. POST https://{{vra-fqdn}}/reservation-service/api/data-service/schema/Infrastructure.Reservation.Virtual.vSphere/default/reservationMemory/values

Body:

{

  "text" : "Element",

  "dependencyValues" : {

    "entries" : [

      {

        "key" : "computeResource",

        "value" : {

          "type" : "entityRef",

          "componentId" : null,

          "classId" : "ComputeResource",

          "id" : "2183b391-b057-429b-b163-bb258a0ff868", #update this id with the value from 1.

          "label" : "Cluster Site A (vCenter)"

        }

      }

    ]

  },

  "associateValue" : null

}

For the reservation Memory, you want:

/reservation/info with the appropriate filter. It's not retrievable per reservation.

Grant http://grantorchard.com
Reply
0 Kudos
CloudInfraTeam
Enthusiast
Enthusiast
Jump to solution

Amazing, this actually worked. Thanks!

Is there a way i can retrieve the JSON sended to the second POST from a GET call to the api? so i don't have to rely it being hardcoded and inserting the ID value of the compute reseource.

Also, did you took this stuff from any documentation i could use for future use? couldn't for the heck of it find how to work with compute resources anywhere.

Anyway, this helped alot. Smiley Happy

Reply
0 Kudos
GrantOrchardVMw
Commander
Commander
Jump to solution

I haven't been able to find the source for the JSON anywhere, I complained to the Product Manager responsible for it at length earlier this week Smiley Happy

I just happened to be in the right place at the right time, as I'm working on a bulk update process for reservations. I extrapolated a little from the Programming Guide.

Grant http://grantorchard.com
Reply
0 Kudos