Automation

 View Only
Expand all | Collapse all

Query and Set HA Settings

  • 1.  Query and Set HA Settings

    Posted Nov 05, 2017 11:48 PM

    Hi All,

    I need to query and possibly set HA settings in particular " Heartbeat Monitoring Sensitivity" (See Screenshot Attached)



  • 2.  RE: Query and Set HA Settings
    Best Answer

    Posted Nov 06, 2017 06:53 AM

    Try like this, there are in fact three possible combinationes (Low, Medium and High)

    $clusterName = 'MyCluster'

    $HMSensitivity = @(

        @{

        Name = 'Low'

        MinUptime = 480

        FailureInterval = 120

        MaxFailureWindow = 604800

        },

        @{

        Name = 'Medium'

        MinUptime = 240

        FailureInterval = 60

        MaxFailureWindow = 86400

        },

        @{

        Name = 'High'

        MinUptime = 120

        FailureInterval = 30

        MaxFailureWindow = 3600

        }

    )

    # Query the setting

    $cluster = Get-Cluster -Name $clusterName

    $cluster | Select Name,

        @{N='Heartbeat Monitoring Sensitivity';E={

            $sensitivity = $HMSensitivity | where{$_.MinUptime -eq $cluster.ExtensionData.ConfigurationEx.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.MinUpTime}

            $sensitivity['Name']

        }}

    # Change the setting

    $request = 'Low'   # Use Low, Medium or High

    $sensitivity = $HMSensitivity | where{$_.Name -eq $request}

    $spec = New-Object VMware.Vim.ClusterConfigSpec

    $spec.DasConfig = New-Object VMware.Vim.ClusterDasConfigInfo

    $spec.DasConfig.DefaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings

    $spec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings

    $spec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.MinUpTime = $sensitivity['MinUpTime']

    $spec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.FailureInterval = $sensitivity['FailureInterval']

    $spec.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.MaxFailureWindow = $sensitivity['MaxFailureWdinow']

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

    # Query the setting

    $cluster = Get-Cluster -Name $clusterName

    $cluster  | Select Name,

        @{N='Heartbeat Monitoring Sensitivity';E={

            $sensitivity = $HMSensitivity | where{$_.MinUptime -eq $cluster.ExtensionData.ConfigurationEx.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.MinUpTime}

            $sensitivity['Name']

        }}



  • 3.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 08:30 AM

    Thanks Luc, this looks like it will do the trick.

    On the flip side the amount of code required for just one cluster is overwhelming considering this is just a tiny bit of what I'm trying to build which a DSC health check.

    I might be back for more help if I can't work out the rest, thanks again Luc.



  • 4.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 08:33 AM

    That's the drawback when functionality is not available directly through a PowerCLI cmdlet.

    The API methods most of the time do require a bit more code I'm afraid.

    On the other hand it makes you appreciate the PowerCLI cmdlets even more :smileygrin:

    And sure, feel free to ask!



  • 5.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 08:43 AM

    Hi Luc,

    Just want say I tested it and works perfectly, in fact I was trying to query this last night but never thought to dive into "ConfigurationEx" of the extensionData. I also just checked out I can so many other things I need for my DSC health check. :smileyhappy:



  • 6.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 08:45 AM

    Quick question, does DSC stand for Desired State Configuration in this case?



  • 7.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 09:55 AM

    Yes, it does, I've recently become very fascinated with desired state. Imagine having to manage 200+ all flash VSAN nodes, NSX, Stretched vsan, the entire vRealize suite, 1000's VM's. desired state plays a huge role in maintaining compliance , resiliency, performance etc. I truly believe maintaining DSC against a VVD (VMware Validated Design) the end result is a robust bulletproof environment no matter big it is.

    As side note, after getting really interested in DSC for VMware Infrastructure I stumbled across the DSC stuff you've been working on. DSC might not be buzz concept yet when it comes to VMware, but its only a matter of time.



  • 8.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 09:59 AM

    Great to hear.

    I'm planning a major update of my DSC resources in the coming weeks (just need to find some time).

    The update will include guidelines on how to contribute.



  • 9.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 10:07 AM

    That's amazing, I totally get it, DSC is a beast and needs time, you've done amazing work Luc, looking forward to seeing more of this!

    As side question my powershell skills are very limited but currently super keen to keep learning, my end goal is codify/automate infrastructure and maintain DSC.

    Would you recommend this book, is there a new addition I should wait for?

    VMware vSphere PowerCLI Reference: Automating vSphere Administration



  • 10.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 10:12 AM

    That book is a reference, so it is not a learning guide.
    It tries to cover all aspects of your vSphere admin tasks. and how you can automate these through PowerCLI.

    Make sure to get the 2nd edition, which was released last year, and contains new and updated chapters.



  • 11.  RE: Query and Set HA Settings

    Posted Nov 06, 2017 10:14 AM

    Cheers Luc



  • 12.  RE: Query and Set HA Settings

    Posted Apr 01, 2019 05:36 AM

    If you want to add a Heartbeat Datastore,

    $spec.DasConfig.HeartbeatDatastore = $(Get-DataStore -Name “DatastoreName”).Id