4 Replies Latest reply on Feb 27, 2019 7:52 AM by htdo

    Looking for a vro script for update reservation - memory and storage values

    Sany Novice

      I am looking for a script for update reservation memory and storage size values.

      Thanks

        • 1. Re: Looking for a vro script for update reservation - memory and storage values
          daphnissov Guru
          vExpertCommunity Warriors

          And what have you produced so far? Or are you looking for someone to just hand over code to you?

          • 2. Re: Looking for a vro script for update reservation - memory and storage values
            Sany Novice

            I have script for update network and memory. But do we have any script to get the available physical memory for the reservation and free space in each selected datastore?

            • 3. Re: Looking for a vro script for update reservation - memory and storage values
              Sany Novice

              Any chance to get the current allocation of memory and storage for a reservation from vro?

              • 4. Re: Looking for a vro script for update reservation - memory and storage values
                htdo Novice

                Here is the code to get the reservation info:

                 

                function getResourceReservations() {
                    var endpoint = "com.vmware.vcac.core.cafe.reservation.api";
                    // Create a rest client from the reservation endpoint
                    var restClient = vCACCAFEHost.createRestClient(endpoint);
                    // The REST resource URL
                    var resourceUrl = "reservations/info";
                
                    var restResponse = restClient.get(resourceUrl);
                    if (restResponse.getStatus() != 200)
                        throw ('Failed to get list of reservations, status ' + restResponse.statusCode);
                    var restJson = restResponse.getBodyAsJson();
                    System.debug("Result: " + JSON.stringify(restJson, null, 4));
                    return restJson;
                }
                
                
                
                

                 

                If you need more details for the reservation:

                 

                function getDetailReservation(id) {
                    var endpoint = "com.vmware.vcac.core.cafe.reservation.api";
                    var restClient = vCACCAFEHost.createRestClient(endpoint);
                    var reservationUrl = "reservations/" + id;
                
                    var reservationResponse = restClient.get(reservationUrl);
                    if (reservationResponse.getStatus() != 200)
                        throw ('Failed to get list of reservations, status ' + reservationResponse.statusCode);
                    var reserJson = reservationResponse.getBodyAsJson();
                    System.debug("BG Reservation: " + JSON.stringify(reserJson, null, 4));
                    return reserJson;
                }
                
                
                

                 

                vCACCAFEHost is typeof vCACCAFE:vCACHost and you can use this call to get it if you don't want to have as an attribute in the workflow:

                vCACCAFEHost = vCACCAFEHostManager.getDefaultHostForTenant(tenantName, true);