Add enhancements to module VMCPFunctions
This commit is contained in:
@@ -7,38 +7,70 @@
|
||||
Twitter: @vBrianGraf
|
||||
VMware Blog: blogs.vmware.com/powercli
|
||||
Personal Blog: www.vtagion.com
|
||||
|
||||
Modified on: 10/11/2016
|
||||
Modified by: Erwan Quélin
|
||||
Twitter: @erwanquelin
|
||||
Github: https://github.com/equelin
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
This function will allow users to view the VMCP settings for their clusters
|
||||
|
||||
.Example
|
||||
# This will show you the VMCP settings of your cluster
|
||||
.PARAMETER Cluster
|
||||
Cluster Name or Object
|
||||
|
||||
.PARAMETER Server
|
||||
vCenter server object
|
||||
|
||||
.EXAMPLE
|
||||
Get-VMCPSettings
|
||||
|
||||
This will show you the VMCP settings for all the clusters
|
||||
|
||||
.EXAMPLE
|
||||
Get-VMCPSettings -cluster LAB-CL
|
||||
|
||||
.Example
|
||||
# This will show you the VMCP settings of your cluster
|
||||
This will show you the VMCP settings of your cluster
|
||||
|
||||
.EXAMPLE
|
||||
Get-VMCPSettings -cluster (Get-Cluster Lab-CL)
|
||||
|
||||
This will show you the VMCP settings of your cluster
|
||||
|
||||
.EXAMPLE
|
||||
Get-Cluster | Get-VMCPSettings
|
||||
|
||||
This will show you the VMCP settings for all the clusters
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory=$True,
|
||||
[Parameter(Mandatory=$False,
|
||||
ValueFromPipeline=$True,
|
||||
ValueFromPipelineByPropertyName=$True,
|
||||
HelpMessage='What is the Cluster Name?')]
|
||||
$cluster
|
||||
$cluster = (Get-Cluster -Server $Server),
|
||||
|
||||
[Parameter(Mandatory=$False)]
|
||||
[VMware.VimAutomation.Types.VIServer[]]$Server = $global:DefaultVIServers
|
||||
)
|
||||
Begin {
|
||||
# Determine input and convert to ClusterImpl object
|
||||
Switch ($cluster.GetType().Name)
|
||||
{
|
||||
"string" {$CL = Get-Cluster $cluster}
|
||||
"ClusterImpl" {$CL = $cluster}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
|
||||
Foreach ($Clus in $Cluster) {
|
||||
|
||||
Write-Verbose "Processing Cluster $($Clus.Name)"
|
||||
|
||||
# Determine input and convert to ClusterImpl object
|
||||
Switch ($Clus.GetType().Name)
|
||||
{
|
||||
"string" {$CL = Get-Cluster $Clus -Server $Server -ErrorAction SilentlyContinue}
|
||||
"ClusterImpl" {$CL = $Clus}
|
||||
}
|
||||
|
||||
If ($CL) {
|
||||
# Work with the Cluster View
|
||||
$ClusterMod = Get-View -Id "ClusterComputeResource-$($cl.ExtensionData.MoRef.Value)"
|
||||
$ClusterMod = Get-View -Id "ClusterComputeResource-$($CL.ExtensionData.MoRef.Value)" -Server $Server
|
||||
|
||||
# Create Hashtable with desired properties to return
|
||||
$properties = [ordered]@{
|
||||
@@ -55,10 +87,10 @@
|
||||
$object = New-Object -TypeName PSObject -Prop $properties
|
||||
|
||||
# Show object
|
||||
return $object
|
||||
$object
|
||||
}
|
||||
}
|
||||
}
|
||||
End {}
|
||||
|
||||
}
|
||||
|
||||
function Set-VMCPSettings {
|
||||
@@ -70,6 +102,11 @@ function Set-VMCPSettings {
|
||||
Twitter: @vBrianGraf
|
||||
VMware Blog: blogs.vmware.com/powercli
|
||||
Personal Blog: www.vtagion.com
|
||||
|
||||
Modified on: 10/11/2016
|
||||
Modified by: Erwan Quélin
|
||||
Twitter: @erwanquelin
|
||||
Github: https://github.com/equelin
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
This function will allow users to enable/disable VMCP and also allow
|
||||
@@ -77,26 +114,65 @@ function Set-VMCPSettings {
|
||||
For each parameter, users should use the 'Tab' button to auto-fill the
|
||||
possible values.
|
||||
|
||||
.Example
|
||||
# This will enable VMCP and configure the Settings
|
||||
.PARAMETER Cluster
|
||||
Cluster Name or Object
|
||||
|
||||
.PARAMETER enableVMCP
|
||||
Enable or disable VMCP
|
||||
|
||||
.PARAMETER VmStorageProtectionForPDL
|
||||
VM Storage Protection for PDL settings. Might be:
|
||||
- disabled
|
||||
- warning
|
||||
- restartAggressive
|
||||
|
||||
.PARAMETER VmStorageProtectionForAPD
|
||||
VM Storage Protection for APD settings. Might be:
|
||||
- disabled
|
||||
- restartConservative
|
||||
- restartAggressive
|
||||
- warning
|
||||
|
||||
.PARAMETER VmTerminateDelayForAPDSec
|
||||
VM Terminate Delay for APD (seconds).
|
||||
|
||||
.PARAMETER VmReactionOnAPDCleared
|
||||
VM reaction on APD Cleared. Might be:
|
||||
- reset
|
||||
- none
|
||||
|
||||
.PARAMETER Server
|
||||
vCenter server object
|
||||
|
||||
.EXAMPLE
|
||||
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$True -VmStorageProtectionForPDL `
|
||||
restartAggressive -VmStorageProtectionForAPD restartAggressive `
|
||||
-VmTerminateDelayForAPDSec 2000 -VmReactionOnAPDCleared reset
|
||||
|
||||
.Example
|
||||
# This will disable VMCP and configure the Settings
|
||||
This will enable VMCP and configure the Settings on cluster LAB-CL
|
||||
|
||||
.EXAMPLE
|
||||
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$False -VmStorageProtectionForPDL `
|
||||
disabled -VmStorageProtectionForAPD disabled `
|
||||
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
|
||||
|
||||
This will disable VMCP and configure the Settings on cluster LAB-CL
|
||||
|
||||
.EXAMPLE
|
||||
Set-VMCPSettings -enableVMCP:$False -VmStorageProtectionForPDL `
|
||||
disabled -VmStorageProtectionForAPD disabled `
|
||||
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
|
||||
|
||||
This will disable VMCP and configure the Settings on all clusters available
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="High")]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory=$True,
|
||||
ValueFromPipeline=$True,
|
||||
ValueFromPipelineByPropertyName=$True,
|
||||
HelpMessage='What is the Cluster Name?')]
|
||||
$cluster,
|
||||
$cluster= (Get-Cluster -Server $Server),
|
||||
|
||||
[Parameter(Mandatory=$True,
|
||||
ValueFromPipeline=$False,
|
||||
@@ -124,19 +200,26 @@ function Set-VMCPSettings {
|
||||
ValueFromPipeline=$False,
|
||||
HelpMessage='This setting will instruct vSphere HA to take a certain action if an APD event is cleared')]
|
||||
[ValidateSet("reset","none")]
|
||||
[string]$VmReactionOnAPDCleared
|
||||
[string]$VmReactionOnAPDCleared,
|
||||
|
||||
[Parameter(Mandatory=$False)]
|
||||
[VMware.VimAutomation.Types.VIServer[]]$Server = $global:DefaultVIServers
|
||||
)
|
||||
Begin{
|
||||
|
||||
Process {
|
||||
|
||||
Foreach ($Clus in $Cluster) {
|
||||
|
||||
Write-Verbose "Processing Cluster $Clus"
|
||||
|
||||
# Determine input and convert to ClusterImpl object
|
||||
Switch ($cluster.GetType().Name)
|
||||
Switch ($Clus.GetType().Name)
|
||||
{
|
||||
"string" {$CL = Get-Cluster $cluster}
|
||||
"ClusterImpl" {$CL = $cluster}
|
||||
"string" {$CL = Get-Cluster $Clus -Server $Server -ErrorAction SilentlyContinue}
|
||||
"ClusterImpl" {$CL = $Clus}
|
||||
}
|
||||
}
|
||||
Process{
|
||||
|
||||
If ($CL) {
|
||||
# Create the object we will configure
|
||||
$settings = New-Object VMware.Vim.ClusterConfigSpecEx
|
||||
$settings.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
|
||||
@@ -189,32 +272,15 @@ Process{
|
||||
|
||||
# Execute API Call
|
||||
$modify = $true
|
||||
$ClusterMod = Get-View -Id "ClusterComputeResource-$($cl.ExtensionData.MoRef.Value)"
|
||||
$ClusterMod = Get-View -Id "ClusterComputeResource-$($CL.ExtensionData.MoRef.Value)" -Server $Server
|
||||
|
||||
If ($pscmdlet.ShouldProcess($CL.Name,"Modify VMCP configuration")) {
|
||||
$ClusterMod.ReconfigureComputeResource_Task($settings, $modify) | out-null
|
||||
|
||||
|
||||
|
||||
}
|
||||
End{
|
||||
# Update variable data after API call
|
||||
$ClusterMod.updateViewData()
|
||||
|
||||
# Create Hashtable with desired properties to return
|
||||
$properties = [ordered]@{
|
||||
'Cluster' = $ClusterMod.Name;
|
||||
'VMCP Status' = $clustermod.Configuration.DasConfig.VmComponentProtecting;
|
||||
'Protection For APD' = $clustermod.Configuration.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmStorageProtectionForAPD;
|
||||
'APD Timeout Enabled' = $clustermod.Configuration.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.EnableAPDTimeoutForHosts;
|
||||
'APD Timeout (Seconds)' = $clustermod.Configuration.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmTerminateDelayForAPDSec;
|
||||
'Reaction on APD Cleared' = $clustermod.Configuration.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmReactionOnAPDCleared;
|
||||
'Protection For PDL' = $clustermod.Configuration.DasConfig.DefaultVmSettings.VmComponentProtectionSettings.VmStorageProtectionForPDL
|
||||
}
|
||||
|
||||
# Create PSObject with the Hashtable
|
||||
$object = New-Object -TypeName PSObject -Prop $properties
|
||||
|
||||
# Show object
|
||||
return $object
|
||||
|
||||
}
|
||||
# Show result
|
||||
Get-VMCPSettings -Cluster $CL -Server $Server
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user