Preparing vRealize Automation 7.6 for 8.2 migrations - Fix reservation Cluster references to include endpoint names.

 As the migration assistant reveals skeletons









Fix reservation endpoint names.
Missing the ClusterName (Endpoint) style in vRA 7.6 reservations lead to a NullPoint exception during the migration of reservations to cloud zones.

Map the variable vra7 to the vRA rest host, require a valid access token and set the limit that will cover your reservations, If you have extremely many rewrite to use the page system,


var request = vra7.createRequest("GET", "/reservation-service/api/reservations/?limit=999");
request.setHeader("Accept", "application/json");
request.setHeader("Authorization", "Bearer " + token);
var response = request.execute();

var results = JSON.parse(response.contentAsString);

for each (var reservation in results.content) {
var endpointName = 'Insert endpoint name here';
//System.debug(Object.keys(reservation.extensionData.entries));

if (!reservation.extensionData.entries[3].value.label.match(' ')) {
System.debug(reservation.name + " is missing vSphere endpoint");
System.debug(reservation.extensionData.entries[3].value.label);
                var label = 
reservation.extensionData.entries[3].value.label + " (" + endpointName + ")"; reservation.extensionData.entries[3].value.label = label;
                var content = JSON.stringify(reservation);
                var update = vra7.createRequest("PUT", "/reservation-service/api/reservations/" + reservation.id, content); update.setHeader("Content-Type", "application/json");
update.setHeader("Authorization", "Bearer " + token);
var response = update.execute();
var statusCode = response.statusCode;
System.debug("statusCode: " + statusCode);
}
}

Note: If you have several endpoints add some logic to add the assign the correct endpoint name.

Kommentarer

Populære innlegg fra denne bloggen

vRealize Automation 8.7 makes custom validations easier with API support

vRealize Automation 8 - Event Topics timeline