VMware Cloud Community
Sany_1973
Enthusiast
Enthusiast
Jump to solution

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

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

Thanks

1 Solution

Accepted Solutions
htdo
Contributor
Contributor
Jump to solution

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);

View solution in original post

4 Replies
daphnissov
Immortal
Immortal
Jump to solution

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

Reply
0 Kudos
Sany_1973
Enthusiast
Enthusiast
Jump to solution

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?

Reply
0 Kudos
Sany_1973
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
htdo
Contributor
Contributor
Jump to solution

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);