Automate Clusters Advanced Settings

Recently at one of the customer, we were tasked at deploying a greenfield environment based on the VVD framework.

As this environment was very big, we divided the task in smaller tasks, one such task was updating the cluster with uniform advance settings.

step one was to create clusters which was fairly simple and is not added in the script.

you can also include this step in the script.

following script was created to update the cluster settings.

<code>

connect-viserver -server vcsa-01a.corp.local -user “administrator@vsphere.local” -password “VMware1!”

$allClusters = Get-Cluster

foreach($indCluster in $allClusters)

{

$ClusterName = $indCluster.Name;

write-host $ClusterName;

$ConfigSpec = New-Object VMware.Vim.ClusterConfigSpec

$ConfigSpec.DasConfig = new-Object VMware.Vim.ClusterDasConfigInfo

$ConfigSpec.DrsConfig = new-Object VMware.Vim.ClusterDrsConfigInfo

$ConfigSpec.DasConfig.Enabled = new-Object System.Nullable[bool]

$ConfigSpec.DasConfig.Enabled = $true;

$d = “vmMonitoringOnly”;

$ConfigSpec.DasConfig.VmMonitoring = $d

$ConfigSpec.DrsConfig.Enabled = new-Object System.Nullable[bool]

$ConfigSpec.DrsConfig.Enabled = $true

$ConfigSpec.DasConfig.AdmissionControlEnabled = new-object System.Nullable[bool]

$ConfigSpec.DasConfig.AdmissionControlEnabled = $true

$ConfigSpec.DasConfig.HBDatastoreCandidatePolicy = “allFeasibleDs”

$ConfigSpec.DasConfig.HostMonitoring = “enabled”

$ConfigSpec.DasConfig.AdmissionControlEnabled = new-object System.Nullable[bool]

$ConfigSpec.DasConfig.AdmissionControlEnabled = $true

$ConfigSpec.DasConfig.DefaultVmSettings = new-object VMware.Vim.ClusterDasVmSettings

$ConfigSpec.DasConfig.DefaultVmSettings.IsolationResponse = “none”

$ConfigSpec.DasConfig.DefaultVmSettings.RestartPriority = “medium”

$ConfigSpec.DasConfig.DefaultVmSettings.VmComponentProtectionSettings = new-object VMware.Vim.ClusterVmComponentProtectionSettings

$ConfigSpec.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmStorageProtectionForAPD = “disabled”

$ConfigSpec.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmStorageProtectionForPDL = “disabled”

#$ConfigSpec.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmTerminateDelayForAPDSec = 180

$ConfigSpec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings = new-object VMware.Vim.ClusterVmToolsMonitoringSettings

$ConfigSpec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.VmMonitoring = “vmMonitoringOnly”

#>

$indCluster.ExtensionData.ReconfigureCluster($ConfigSpec, $true)

set-cluster -Cluster $ClusterName -HAFailoverLevel “2” -HAIsolationResponse “powerOff” -HARestartPriority “Medium” -VMSwapfilePolicy “WithVM” -DrsMode “FullyAutomated” -DrsAutomationLevel “FullyAutomated” -VsanEnabled:$false -Confirm:$false;

}

 

</code>

While you can use the script as is, I will explain the script in next post where we will also see how to build one such script.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s