VMware Cloud Community
TomHEMC
Contributor
Contributor

How can I get a reference to a machine created via requestCatalogItem?

Hello,

I've got a workflow that calls com.vmware.library.vcaccafe.request.requestCatalogItem to create a Request on a Catalog item that creates a VM. I use the Wait for catalog Item workflow to wait for the process to complete. At the end, all I have is a Success message. How can I get a reference to the actual VM vCAC:VirtualMachine that was created by the request? I'd like to add additional workflows to this provisioning chain but I need the reference to the created VM in order to do so.

Thanks

0 Kudos
4 Replies
eoinbyrne
Expert
Expert

Looking at the inventory for the vRA plugin, an entry in the Items folder has a requestId field on it. You should be able to to resolve the machine from that if you have request.id? You'd have to iterate over all entries in the items list and match on the requestId. I would think that the request doesn't get a reference to the machine as not all requests are guaranteed to result in a managed object

Also, the field request.completed will contain text like "SUCCESSFUL - Request completed. Created <machine name>." where <machine name> is the VM name though I'm not sure I like relying on a text match when the IDs are there.

HTH

-Eoin

0 Kudos
eoinbyrne
Expert
Expert

Curiosity got the better of me....

var resources = vCACCAFEEntitiesFinder.findCatalogResources(host, "");

System.log("returned " + resources.length + " items");

var res;

for(var i=0; i<resources.length; i++)

{

res = resources[i];

System.log("resource name == " + res.getName());

System.log("resource requestId == " + res.getRequestId());

}


The above code retrieves all entries from the vRA Items inventory and prints the names + requestIds. The type CatalogResource is used to wrap the entries. Once you have the name of the VM it should be simple enough to lookup the vCAC:VirtualMachine object from the vRA inventory



0 Kudos
TomHEMC
Contributor
Contributor

Thanks for this! I'll take a look and see what I can do. Thank you very much for the help,

Tom

0 Kudos
sanchezs
VMware Employee
VMware Employee

This can complete the suggestion: How to get the actual IaaS VM from a provisioned vCAC Catalog Resource VM?

On the other hand, instead of getting all the catalog resources and filtering them manually, you should be able to create an odata filter (see How to find vCAC entities with the vCAC plug-in for vCO (and how to filter them in scripting)) to get directly the catalog resource created by your request.

I hope that helps.

Sergio

0 Kudos