Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

New test for DPM state #223

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Vester/Tests/Cluster/DPM-Enabled.Vester.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Test file for the Vester module - https://github.com/WahlNetwork/Vester
# Called via Invoke-Pester VesterTemplate.Tests.ps1

# Test title, e.g. 'DNS Servers'
$Title = 'DPM State'

# Test description: How New-VesterConfig explains this value to the user
$Description = 'Enables Distributed Power Managment (DPM) on the cluster'

# The config entry stating the desired values
$Desired = $cfg.cluster.dpmenable

# The test value's data type, to help with conversion: bool/string/int
$Type = 'bool'

# The command(s) to pull the actual value for comparison
# $Object will scope to the folder this test is in (Cluster, Host, etc.)
[ScriptBlock]$Actual = {
$Object.ExtensionData.ConfigurationEx.DpmConfigInfo.Enabled
}

# The command(s) to match the environment to the config
# Use $Object to help filter, and $Desired to set the correct value
[ScriptBlock]$Fix = {
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.dpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo
$spec.dpmConfig.enabled = $Desired
(Get-View -VIObject $Object).ReconfigureComputeResource_Task($spec, $true)
}