VMware {code} Community
mcescalante
Contributor
Contributor
Jump to solution

List VMs in DRS Group

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
stumpr
Virtuoso
Virtuoso
Jump to solution

It's tucked away in the ClusterConfigInfoEx data.

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

$cluster->{configurationEx}->{group}

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.

Reuben Stump | http://www.virtuin.com | @ReubenStump

View solution in original post

Reply
0 Kudos
2 Replies
stumpr
Virtuoso
Virtuoso
Jump to solution

It's tucked away in the ClusterConfigInfoEx data.

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

$cluster->{configurationEx}->{group}

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.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
mcescalante
Contributor
Contributor
Jump to solution

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";

                                }

                         }

}

Reply
0 Kudos