I am working on a script and a PowerCLI commandlet seems to already be written for it. The script adds an existing vm to an existing DRS Rule.
Here is the code for the commandlet I would like to replicate:
$spec=New-ObjectVMware.Vim.ClusterConfigSpecEx
$spec.groupSpec =New-ObjectVMware.Vim.ClusterGroupSpec[] (1)
$spec.groupSpec[0] =New-ObjectVMware.Vim.ClusterGroupSpec
$spec.groupSpec[0].operation ="edit"
$spec.groupSpec[0].info =$DrsGroup
$spec.groupSpec[0].info.vm +=$VM.ExtensionData.MoRef
$Cluster.ExtensionData.ReconfigureComputeResource_Task($spec, $true)
To my understanding, something along the following lines can be done to translate this to Perl:
1. Create a ClusterGroupSpec object with the correct information. I fail here, and am unsure of how to add "info.vm" into ClusterGroupSpec in Perl.
my $cluster_group_spec = ClusterGroupSpec->new(operation => "edit", info => $drs_rule_name...
2. Pass this as a ClusterConfigSpecEx object into rulesSpec
my $cluster_config_spec = ClusterConfigSpecEx->new(rulesSpec => [$cluster_group_spec]);
3. Reconfigure with spec as $cluster_config_spec.
What I am confused about is how to pass in info.vm from the PowerCLI. There is no member of info or ClusterConfigInfo called "vm". How would I tell the Group Spec what VM to use?