VMware Cloud Community
CKloseFUM
Enthusiast
Enthusiast

vCAC and ASD with multiple vCenter Endpoint

Hi community,

i've got an issue with an Advanced Resource Action to a VM where i call a vCO Script.

Connected to the vCAC and also to the vCO i have three different vCenter Server in different locations (Sydney, London, Boston).

The vCO Script is available to all VM Items in all Locations.

As an example i have a VM in Boston and call the Resource Action Script where i handover the VC:Virtualmachine as an Input Parameter to the vCO Script.

Unfortunately this is the VMID in vCO, as an example vm-1152; but this is also an ID in a vCenter Server in London.

Any Ideas how to solve this as i'm not able to forward the VM Name from vCAC to vCO.

vmid.jpg

0 Kudos
8 Replies
qc4vmware
Virtuoso
Virtuoso

So I think you mean you are handing over the vm.id (managed object reference) as a string to another workflow?  If you are actually passing the VC:VirtualMachine you should be passing the correct item.  Since vm.id's are not unique you need to either use the vms uuid vm.config.instanceUuid or also filter on the vm.sdkConnection.about.instanceUuid or some other way of comparing the vCenter it is in. 

This action might also be helpful.  It takes a vCAC:VirtualMachine and returns the VC:VirtualMachine:

var sdkConnections = VcPlugin.allSdkConnections;

var vCenterVm = null;

for each (var sdkConnection in sdkConnections) {

  try {

  vCenterVm = sdkConnection.searchIndex.findByUuid(null, vCACVm.vmUniqueID, true, false);

  } catch(e) {

  System.getModule("com.qualcomm.basic").QClogSeverAndSystem("Error for SDK connection " + sdkConnection.name + " : " + e);

  continue;

  }

  if (vCenterVm != null && vCenterVm != undefined) {

  System.log("Resolved vCenter VM " + vCenterVm.name);

  return vCenterVm;

  break;

  }

}

return null;

0 Kudos
CKloseFUM
Enthusiast
Enthusiast

Thanks for that but this doesn't solve my Problem.

I Hand over the vm.id (VC:Virtualmachine) from vCloud Automation Center Advanced Service Action to vCenter Orchestrator where i wanted to run some Actions on it.

And the Problem seems to be that the ID which is transfered from vCAC to vCO is only the "vm-1152" which is only unique within one vCenter Server.

But i have three vCenter Server (three different locations) and my problem ist that the Default Workflow vCenter\Virtual Machine Management\Basic\Others\Get VM UUID which works with the vm id (VC:Virtualmachine) to get the UUID from the System searchs through ALL vCenter Server and this could result in a different VM in a different Location then the one i started the Workflow in vCAC for.

0 Kudos
GrantOrchardVMw
Commander
Commander

I've used VirtualMachine.Admin.UUID and then feed that to an action with the following:

var vCenters = VcPlugin.allSdkConnections;

var vmOut = null;

for each (VC in vCenters) {

    // Search through all known vCenters, all datacenters, search for VMs by SMBIOS UUID, not Instance UUID.

    vmOut = VC.searchIndex.findByUuid(null,uuid,true,false);

    if (vmOut != null) break;

}

return vmOut;

It's not foolproof, but the UUID is *likely* to be unique.

Grant

Grant http://grantorchard.com
0 Kudos
CKloseFUM
Enthusiast
Enthusiast

Thanks Grant

i tried that but where did i find that VirtualMachine.Admin.UUID?

When i create a Resource Action in vCAC i only can link VC:VirtualMachine to the vCO Workflow

vmid2.jpg

The default vCAC Resource type IaaS VC:VirtualMachine is linked to my input parameter vcenterVm

vmid3.jpg

which is defined as VC:VirtualMachine in my vCO Workflow

vmid4.jpg

And the first Action in my Workflow is the nested "Get VM Uuid" (original by vCO) which results in wrong values if the vm-1152 is available in any other vCenter Server.

In my case i start the Resource Action on a VM located and managed through a vCenter in Madrid but the result is a vm (with the same vm-ID) from a vCenter in Location Nice.

I wanted to transfer the VM Hostname also with the vCAC Action like "__asd_requestedBy" to match the ID and the Hostname but i don't know how to solve this.

vmid5.jpg

As an example i started a "find VM" workflow for two VMs located in Madrid

First one is MADVCCHK00253 and is correctly mapped to vmid variable as you can see in the screenshot.

vmid6.jpg

Second VM name is MADVCCHK00244 represented by Managed VM ID vm-1152 and this is linked to another VM (NCESEPNRE14) in vCenter vCO Plugin because of its Managed Object ID vm-1152

vmid7.jpg

vmid8.jpg

0 Kudos
CKloseFUM
Enthusiast
Enthusiast

The only ID i can use is the __asd_targetResourceInternalId  which also comes from vCAC and is the ID of my Resource in vCAC Database Table cat_resources where i can also find the Name of the VM.

And as long as the Name in vCAC is also the Name in vCenter it works.

vmid9.jpg

vmid is the VC:VirtualMachine Property from vCAC

__asd_targetResourceInternalId comes as a default value from vCAC

database is the vCAC locale Postgres DB

System.log("VM-ID from vCAC :"+vmid.id);

System.log("VM-Name from vCAC :"+vmid.name);

System.log("VM-Host from vCAC :"+vmid.vimHost);

sqlString = "Select name from cat_resource WHERE id ='"+__asd_targetResourceInternalId+"'";

resultRecords = database.readCustomQuery(sqlString);

vmname = resultRecords[0].name;

System.log("VMname from vCAC DB: "+vmname);

var sdkConnections = VcPlugin.allSdkConnections;

vms = new Array();

for (var i in sdkConnections) {

  var host = sdkConnections[i];

  var found;

  if (host.isInventoryServiceAvailable()) {

  found = host.getAllVirtualMachines(null, "matches(name, '" + vmname + "')");

  } else {

  found = host.getAllVirtualMachines(null, "xpath:matches(name, '" + vmname + "')");

  }

  for (var j in found) {

  vmidFromDB = found[j];

  }

}

System.log("VM-ID from UUID :"+vmidFromDB.id);

System.log("VM-Name from UUID :"+vmidFromDB.name);

System.log("VM-Host from UUID :"+vmidFromDB.vimHost);

0 Kudos
GrantOrchardVMw
Commander
Commander

Ah, you're not not starting with the vCAC Property dump.

Take a look at the package attached to this blog post - http://grantorchard.com/vcac/operations/vm-placement-vsphere-metro-storage-cluster-vcac/. Rip out the beginning to get the properties you need, you'll see how I've used it.

Grant

Grant http://grantorchard.com
0 Kudos
CKloseFUM
Enthusiast
Enthusiast

Thanks Grant,

it seems that i have to change to "vCAC Plugin Implementation" of Blueprint, Workflows and Advanced Services...

Christian

0 Kudos
Windspirit
Hot Shot
Hot Shot

Hi, (late answer...but maybe good for ppl now looking to vRA 7.2)

using vRO you can get the name of the Endpoint for a given VM

Input: vCACVirtualMachine (vCAC:VirtualMachine)

Output: Endpoint Name (String)

var vCACHost = Server.findAllForType("vCAC:VCACHost")[0];

var properties = new Properties();

properties.put("VirtualMachineID", vCACVirtualMachine.virtualMachineID);

var vmEntity = vCACEntityManager.readModelEntity(vCACHost.id, "ManagementModelEntities.svc", "VirtualMachines", properties, null);

var linkEntity = vmEntity.getLink(vCACHost, "VirtualMachineExt");

//Log snapshot properties to the console   

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

    var linkProperties = linkEntity[i].getProperties();

    for (var j = 0; j < linkProperties.keys.length; j++) {

        if (linkProperties.keys[j] == "EndpointName") {

            return linkProperties.get(linkProperties.keys[j]);

        }

    }

}

If you set up your vRA to use the hostname of your vCenter as Endpoint Name....you now can get the correct VM.

0 Kudos