I've recently started working with vRA 8.8 and working on migrating our processes over. My custom naming workflow/action searches vCenter for existing vm name. in vRA 7.6, the plugin used was vCAC and vCACEntityManager to search based on name. Looks like the equivalent in vRA 8 is Server.findAllForType("VRA:Machine"). I'm trying to filter based on vm name, but i can't seem to get the correct syntax.
What i've tried so far is Server.findAllForType("VRA:Machine",hostname) and Server.findAllForType("VRA:Machine","name="'"hostname"'").
Any idea what i'm missing? Google hasn't turned up much help on this.
Thanks
As vRA has it’s own forum area, I have reported your thread to moderators, they should now move it.
This is a simple way to achieve what you're looking for in 8. Hope it helps.
Your input is a string named "hostname"
Your output is vcVM in this case
**dev-vcSdkConnection is a config element of type VC:SdkConnection. if you have multiple create multiple with unique names
Hi, I assume that you are trying to find a VM in vRA8 inventory (not in vCenter directly). I was trying with Server.findAllForType("VRA:Machine", query) but it doesn't seems to work.
What you can do is to use the ability to execute HTTP Rest queries to vRA. The following code does the trick but is not really ready for production (need some more work):
var hosts = VraHostManager.findHostsByType("vra-onprem");
var host = hosts[0]; // I have only one host. If not, find the correct one checking "vraHost" property.
var restClient = host.createRestClient();
var request = restClient.createRequest("GET", "/iaas/api/machines?$filter=name+eq+'vmName'", null);
var response = restClient.execute(request);
if (response.statusCode==200) {
var vms = JSON.parse(response.contentAsString);
// You can look for any property, for example:
System.log(vms.content[0].name);
}