tivs
Enthusiast
Enthusiast

list of VM's in a resource pool

Hi All,

    I am trying to display the list of VM's in a resource pool.

Input variables:-

  localparameter:- rpool

  Type:- VC:ResourcePool

Script:-

if (rpool.name == "ABC"){

var vms = VcPlugin.getAllVirtualMachines();

for(i in vms){

    var vm = vms[i];

            System.log("VM name : " + vm.name  );

            logtext = "VM name : " + vm.name  ;

}

}

  But the script is displaying  list of VM's in the vCenter but i need only VM's listed in the ABC resource pool. Please correct me, if i am wrong. Thank you in advance for the help.

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee

getAllVirtualMachines get all vCenters VM. This is expected.

To get vms from a resourcepool just use var vms = rpool.vm;

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
tivs
Enthusiast
Enthusiast

Hi,

  Thank you for the help.

var vms = rpool.vm;


The above helps in retrieving the list of VM in the resource pool. But this parameter is not listing the VM's under the nested repool or the VM's in the vApp.

For example:-

I have resource pool which contains only one vApp, the vApp contains two VM's. the rpool.vm is not able to display the vm's information.

Thank you in advance for the help.

Reply
0 Kudos