VMware {code} Community
cabryant
Contributor
Contributor

Locking VMs to specific hosts to prevent migration.

Obviously the forums don't like chrome, had most of this typed then it locked up. Couldn't even do a copy/paste.

New at using perl SDK and deal with VMWare.

I'm trying to lock down a subset of VMs to specific hosts.

I currently have a list of mo_refs for the VMs grouped by hosts and I have an example of how to create the ClusterConfigSpec/ClusterRuleSpec.

The example I found uses a reference to a ClusterComputerResource.

Do I need to create one for each host or just one for the group of hosts I'm dealing with?

Can hosts be referenced by multiple ClusterComputerResources?

How do I create a ClusterComputerResource?

Some additional code/explanation to follow...

Reply
0 Kudos
2 Replies
cabryant
Contributor
Contributor

      my $ccr = new ClusterComputeResource();

     ## some initialization of $ccr, but what is required?I

     ## Do I need to add the $ccr before doing the following?

    my $aff_rule_spec = new ClusterAffinityRuleSpec( name      => $rule_name,

                                                      enabled   => "TRUE",

                                                     mandatory => "TRUE",

                                                     vm        => \@vm_morefs  );

my $array_update_operation = new ArrayUpdateOperation( "add" );
my $clus_rule_spec = new ClusterRuleSpec( operation => $array_update_operation, info => $aff_rule_spec );
my @clus_rule_specs;
push( @clus_rule_specs, $clus_rule_spec );

my $cluster_config_spec = new ClusterConfigSpec( rulesSpec => \@clus_rule_specs );
$cluster_view->ReconfigureCluster_Task( spec => $cluster_config_spec,
                                                                            modify => "TRUE"  ) );
Reply
0 Kudos
cabryant
Contributor
Contributor

Nevermind,

I realized that cluster computer resources are the clusters created to group hosts into vmotion sets so I just needed to walk through all configured clusters to look for the VMs for which I need to set DRS to manual to prevent vmotion.

Reply
0 Kudos