Automation

 View Only
  • 1.  Get & Document DRS Rules

    Posted May 16, 2008 05:15 PM

    Can you provide an example for capturing, for system documentation purposes, the DRS rules for cluster?

    Thanks,



  • 2.  RE: Get & Document DRS Rules

    Posted May 16, 2008 05:21 PM

    I would start simply with Get-Cluster. What are you looking for in addition to this?

    45# "administrator" | Get-VIServer vcenter
    46# Get-Cluster
    
    Name                           HAEnabled  HAFailover DRSEnabled DRSMode
                                              Level
    ----                           ---------  ---------- ---------- -------
    HA-Cluster                     False      1          True       Manual
    

    Hal Rottenberg

    Co-Host, PowerScripting Podcast (http://powerscripting.net)



  • 3.  RE: Get & Document DRS Rules

    Posted May 16, 2008 05:33 PM

    Affinity, anti-affinity rules.



  • 4.  RE: Get & Document DRS Rules
    Best Answer

    Posted May 19, 2008 09:43 AM

    The following script lists for all cluster all rules and for each rule the guests involved.

    Get-Cluster | %{Get-View $_.ID} | %{
      $confEx = $_.ConfigurationEx
      if($confEx.Rule -is [array]){
        foreach($rule in $confEx.Rule){
          Write-Host "Rule : " $rule.Name "/Enabled : " $rule.Enabled
          foreach($vmMoref in $rule.Vm){
            $vm = Get-View $vmMoref
            Write-Host "VM : " $vm.Name
          }
    	}
      }
    }
    

    The script uses the ClusterConfigInfoEx object to get to the rules.

    Note that the API v2.5 advises to use this object instead of the ClusterConfigInfo object.

    The test if($confEx.Rule -is [array]) avoids running through the loop when there are no rules defined.



  • 5.  RE: Get & Document DRS Rules

    Posted May 19, 2008 11:15 PM

    Thank you