VMware Cloud Community
MartyG
Contributor
Contributor

Create a DRScluster group for vm with no vm

As we deploy virtual centers we create  standard groups and a rule for specific app servers. Is it possible to create a vm group with no virtual machines and assign a rule. The hosts exist but the vm come later. Nice to have the groups and rule in place when we start to build out the clusters

thanks

0 Kudos
1 Reply
LucD
Leadership
Leadership

Currently not with the cmdlets afaik, but with the API everything is 'posh'ible.

This will create a dummy VM and VMHost group, and then create a rule with both groups.

You can adapt the groups (for example add ESXi nodes) or change the type of rule

$clusterName = 'MyCluster'

$cluster = Get-Cluster -Name $clusterName


$spec = New-Object VMware.Vim.ClusterConfigSpecEx


$newVMGroup = New-Object VMware.Vim.ClusterVmGroup

$newVMGroup.Name = 'DummyVM'

$newVMGroup.UserCreated = $True

$newVMGroup.VM = $null

$groupSpec = New-Object VMware.Vim.ClusterGroupSpec

$groupSpec.Operation = [VMware.Vim.ArrayUpdateOperation]::Add

$groupSpec.Info = $newVMGroup

$spec.GroupSpec += $groupSpec


$newVMHostGroup = New-Object VMware.Vim.ClusterHostGroup

$newVMHostGroup.Name = 'DummyVMHost'

$newVMHostGroup.UserCreated = $True

$newVMHostGroup.Host = $null

$groupSpec = New-Object VMware.Vim.ClusterGroupSpec

$groupSpec.Operation = [VMware.Vim.ArrayUpdateOperation]::Add

$groupSpec.Info = $newVMHostGroup

$spec.GroupSpec += $groupSpec


$newRule = New-Object VMware.Vim.ClusterVmHostRuleInfo

$newRule.Name = 'Dummy Rule'

$newRule.Mandatory = $true

$newRule.Enabled = $false

$newRule.UserCreated = $True

$newRule.VmGroupName = 'DummyVM'

$newRule.AffineHostGroupName = 'DummyVMHost'


$ruleSpec = New-Object VMware.Vim.ClusterRuleSpec

$ruleSpec.Info = $newRule


$spec.RulesSpec += $ruleSpec


$cluster.ExtensionData.ReconfigureComputeResource($spec, $true)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos