Preparing vRealize Automation 7.6 for 8.2 migrations - Fix reservation blank Network Profiles.

As the migration assistant reveals well-hidden skeletons










Fix missing Network Profiles.
Having a reference to a network profile in the reservation JSON in vRA 7.6 seems valid but leads 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) {
System.debug("Reservation name: " + reservation.name);
System.debug("Network entries: " + reservation.extensionData.entries[4].value.items.length);
var i, j;

for (i = 0; i < reservation.extensionData.entries[4].value.items.length; i++){
for (j = 0; j < reservation.extensionData.entries[4].value.items[i].values.entries.length; j++) {
if (reservation.extensionData.entries[4].value.items[i].values.entries[j].key == 'networkProfile') {
if (!reservation.extensionData.entries[4].value.items[i].values.entries[j].value) { System.warn("Null Pointer Exception for vRA 8.2 found"); reservation.extensionData.entries[4].value.items[i].values.entries.splice(j,1); var update = vra7.createRequest("PUT", "/reservation-service/api/reservations/" + reservation.id, JSON.stringify(reservation));
update.setHeader("Content-Type", "application/json"); update.setHeader("Authorization", "Bearer " + token);
var response = update.execute();
var statusCode = response.statusCode;
}
}
}
}
}

Kommentarer

Populære innlegg fra denne bloggen

vRealize Automation 8 - Migration Assistant - Entitlements

vRealize Orchestrator and Microsoft Powershell Double Hops

vRealize Orchestrator - SSH Keys - Idea for how to easy manage multiple keys