The following script contains a simple example of how to modify the configuration of a cluster – in this case to add two advanced options to the HA settings. This uses the new ClusterConfigSpecEx object, which can be used with the more generic function to reconfigure a resource – ReconfigureComputeResource().
The options set in this example are the das.allowNetworkX options, configuring HA to set specific management networks/service consoles that are used for HA communication and heartbeats.
Consider the following scenario for a reason why you might want to use these options:
- Software iSCSI with ESX 3.x – using the service console for authentication, meaning you need a service console on your iSCSI network (or routes between your corporate network and iSCSI). The standard result is that HA could be used across this interface.
- You are progressing with an upgrade to ESXi 4.0, still using software iSCSI, which is improved to remove the need for a management interface on your iSCSI network
- You put an ESX 3.5 and ESXi 4.0 host in the same cluster, HA no longer works because your iSCSI service console on ESX 3.5 can’t talk to your ESXi 4.0 host.
- Adding the two options above (with names changed appropriately) would force HA to use the service console on ESX 3.5 and the equivalent management network on ESXi 4.0, ignoring the iSCSI service console on 3.5 - resolving HA issues.
# http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.ComputeResource.html#reconfigureEx
# http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.cluster.DasConfigInfo.html#field_detail
param (
$vcServerName = ""
)
$viServer = Connect-VIServer -server $vcServerName
$optionValue = New-Object Vmware.Vim.OptionValue
$optionValue.Key = "das.allowNetwork0"
$optionValue.Value = "Service Console"
$optionValue2 = New-Object Vmware.Vim.OptionValue
$optionValue2.Key = "das.allowNetwork1"
$optionValue2.Value = "Management Network"
[Vmware.Vim.OptionValue[]]$optionValues = $optionvalue, $optionValue2 # Create the array of the two new option values
$cluster = get-cluster -Name 'Cluster01' # Get the cluster
$clusterview = get-view $cluster.Id # Get the SDK object from the PowerCli object MO
$spec = New-Object Vmware.Vim.ClusterConfigSpecEx
$spec.dasConfig = New-Object Vmware.Vim.ClusterDasConfigInfo # New VMware HA config
$spec.dasConfig.option = $optionValues # Add the array of optionValues
$clusterview.ReconfigureComputeResource($spec, $true) # Modify the configuration. When configuring clusters, can be a ClusterConfigSpecEx object
# Check the settings were saved
$cluster = get-cluster -Name 'Cluster01' # Get the cluster
$clusterview = get-view $cluster.Id # Get the SDK object from the PowerCli object MO
$clusterview.Configuration.dasConfig.Option | format-list # Retrieve the advanced options
Wayne's World of IT (WWoIT), Copyright 2009 Wayne Martin.
No comments:
Post a Comment