Comprehensive data protection for all workloads
Post Reply
scran
Lurker
Posts: 2
Liked: never
Joined: Jul 14, 2017 12:49 pm
Contact:

Veeam vRO Workflows

Post by scran »

Please can anyone offer any suggestions on getting the following working.
I am trying to add a Restore VM option for vRA users to restore their own virtual machines using the Veeam vRO example workflows downloaded from github. I have set up the REST API host and credentials, the add VM to backup workflow is successful so I know the connection is good from vRO to Veeam.
When I try running the Restore VM workflow I can select the VM, but the workflow cannot pull the restore points from the Veeam server. The select restore point field is just a blank text box. The property is a predefined answer with a value of GetAction("com.veeam.backup","getVMRestorePoints").call( #vmObj , #restHost ). The com.veeam.backup is the correct workflow package, the getVMRestorePoints action looks ok to me (script below). The #vmObj element is working as I am able to pull a list of VM names, #restHost has the correct attributes for the Veeam server.
Is there another customisation required somewhere that I have missed?

Code: Select all

// Create REST Session and grab Session ID
var restResponse = restHost.createRequest("POST", "/api/sessionMngr/?v=v1_1", null).execute();
var restResponseXml = XMLManager.fromString(restResponse.contentAsString);
var sessionId = restResponseXml.documentElement.getElementsByTagName("SessionId").item(0).textContent;

// Find vCenter UID and combine with VM MoRef to create unique HierarchyRef
var restRequest = "api/hierarchyRoots?format=Entity";
var restResponse = restHost.createRequest("GET", escape(restRequest), null).execute();
var restResponseXml = XMLManager.fromString(restResponse.contentAsString);
var hierarchyRoots = restResponseXml.documentElement.getElementsByTagName("HierarchyRoot")
for (i=0;i<hierarchyRoots.getLength();i++) {
 if (hierarchyRoots.item(i).getElementsByTagName("UniqueId").item(0).textContent == vmObj.sdkConnection.instanceUuid) {
vcId = hierarchyRoots.item(i).getElementsByTagName("HierarchyRootId").item(0).textContent;
 }
}
var hierarchyRef = vcId + "." + vmObj.id

// Retrieve all Restore Points by VM Display Name
var restResponse = restHost.createRequest("GET", "api/query?type=VmRestorePoint&format=Entities&sortDesc=CreationTime&filter=(VmDisplayName==%22" + vmObj.name + "%22)", null).execute();
var restResponseXml = XMLManager.fromString(restResponse.contentAsString);
var restorePointNodes = restResponseXml.documentElement.getElementsByTagName("VmRestorePoint");

// Filter out any VMs with duplicate names by using hierarchy reference and create array of restore points in local timezone
var restorePoints = [];
for (i=0;i<restorePointNodes.getLength();i++) {
 var rpDateLocale = System.getDateFromFormat(restorePointNodes.item(i).getElementsByTagName("CreationTimeUTC").item(0).textContent + " UTC","yyyy-MM-dd'T'HH:mm:ss'Z' ZZZ").toLocaleString();
 var hierarchyObjRef = (restorePointNodes.item(i).getElementsByTagName("HierarchyObjRef").item(0).textContent.split(":").pop()).split("?")[0];
 if (hierarchyRef == hierarchyObjRef) {
   restorePoints[i] = rpDateLocale;
 }
}

// Close REST Session
var restResponse = restHost.createRequest("DELETE", "/api/sessionMngr/" + sessionId, null).execute();

return restorePoints;
scran
Lurker
Posts: 2
Liked: never
Joined: Jul 14, 2017 12:49 pm
Contact:

Re: Veeam vRO Workflows

Post by scran »

Can anyone help with this?
Post Reply

Who is online

Users browsing this forum: unixnerd443 and 113 guests