Ravindra01
Enthusiast
Enthusiast

How to get List of VM's managed by vRA 7.2

Hello All,

   We have vRA 7.2 environment, during the issues couple of VM's has been restored from the snap shot based backup in the vcenter. later the VM's which are restored are not able to manage through the portal , cannot to do any action; since the actual VM's in the VC has the different UUID. We have exported the unmanaged vm list from Bulk export and imported.

  Now we have two vm with same name ( Not exactly .. like _old and the actual) , after importing we are able to manage the actual Vm running in the vc. as we have duplicate entries creating confusion.

   Is there any option to export list which come  Items > Machines tab ?? If we have the list we can force unregister the VM from cloud client. as the count is huge we cannot make a note manually.

Thank You !!

0 Kudos
4 Replies
eservent
Enthusiast
Enthusiast

Hello Ravindra01,

I'm not sure it's what you need, but here is some code to retrieve all managed VM.

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

var MODEL_MANAGEMENTMODELENTITIES = "ManagementModelEntities.svc";

var ENTITYSET_VIRTUALMACHINES = "VirtualMachines";

var virtualMachinesQueryProperties = new Properties();

var allVirtualMachineEntitiesList = vCACEntityManager.readModelEntitiesByCustomFilter(vcacHost.id, MODEL_MANAGEMENTMODELENTITIES, ENTITYSET_VIRTUALMACHINES, virtualMachinesQueryProperties, null);

var virtualMachineEntitiesList = [];

for each(var virtualMachine in allVirtualMachineEntitiesList) {

    if(virtualMachine.getProperty("IsManaged") === true) {

        virtualMachineEntitiesList.push(virtualMachine.getProperty("VirtualMachineName"));

    }

}

System.log("List of Managed VMs " + virtualMachineEntitiesList.join(", "));

Emmanuel.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Emmanuel.
darrenoid
Enthusiast
Enthusiast

This is not the same as the items tab for machines query, but it will show all VMs managed by vRA in the IaaS database. This might be helpful for you if the VM is not showing up in the items list, but is still managed by vRA (IaaS).

On the vra IaaS database:

SELECT VirtualMachineName, VirtualMachineID

FROM VirtualMachine

WHERE IsManaged =1;

Here is a sreenshot of running this command in MS SQL Management Studio

pastedImage_0.png

This is similar to going to Infrastructure > Managed Machines

0 Kudos
Gringo2u
Contributor
Contributor

Infrastructure view - > Managed Machines - > export ( in the right upper corner ) 

 

0 Kudos
DanMan3395
Enthusiast
Enthusiast

Can this be done via the REST API?

var vcacHost = Server.findAllForType("vCAC:VCACHost")

I need to get that list of hosts but not in vro.

0 Kudos