2 Replies Latest reply on Jun 13, 2013 1:06 PM by mcescalante

    List VMs in DRS Group

    mcescalante Novice

      In vSphere you can right click a Cluster, click "Edit Settings > DRS Groups Manager > (select a group), Edit" and see a list of virtual machines that are in the cluster.


      I am looking to get this same list with the SDK... I have been hunting for a way to get it but cannot find where in the API this might be, any ideas of how I could get the list?


      Glad to provide code so far, but it's just some simple cluster related statistics and information; nothing actually related to the question.

        • 1. Re: List VMs in DRS Group
          stumpr Master

          It's tucked away in the ClusterConfigInfoEx data.


          So you get your cluster(s) and then look at the following -




          There are two types of groups, Host and Vm.  You can then check the type for VM groups and get the list of members.  You may also have to look at $cluster->{configurationEx}->{rule} if you want to see if its an affine or disaffine rule group.

          • 2. Re: List VMs in DRS Group
            mcescalante Novice

            For anyone referring in the future, here is some fairly primitive code that should work (nearly) out of the box. This was quickly pulled and edited from a larger script, but should be ok.


            foreach my $vmsInCluster (@{$cluster_view->configurationEx->group}) {

                                   if (ref($vmsInCluster) eq "ClusterVmGroup") {

                                            print "DRS rule name is: ", $vmsInCluster->name, "\n";

                                            foreach my $vmNames (@{$vmsInCluster->vm}) {

                                                    my $vmMor = Vim::get_view(mo_ref => $vmNames);

                                                    print $vmMor->config->name, "\n";