I am looking for a script for update reservation memory and storage size values.
Thanks
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);
And what have you produced so far? Or are you looking for someone to just hand over code to you?
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?
Any chance to get the current allocation of memory and storage for a reservation from vro?
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);