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

Add VDS Membership Test #176

Merged
merged 2 commits into from
Sep 18, 2017
Merged
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
41 changes: 41 additions & 0 deletions Vester/Tests/Host/vDS-HostMembership.Vester.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 = 'vDS Membership'

# Test description: How New-VesterConfig explains this value to the user
$Description = 'vDS(es) that the ESXi host should use.'

# The config entry stating the desired values
$Desired = $cfg.host.vdswitch

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

# 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 = {
(Get-VDSwitch -VMHost $Object).name
}

# The command(s) to match the environment to the config
# Use $Object to help filter, and $Desired to set the correct value
[ScriptBlock]$Fix = {
write-warning "VDSwitch Memership remediation is not yet implemented, please resolve manually for host $($object.name)"
# # Add missing vdswitches
# $currentSwitches = Get-VDSwitch -VMHost $Object
# foreach ($vdswitchStr in $cfg.host.vdswitch){
# if (!($currentSwitches.name -contains $vdswitchStr)){
# if ($vdswitch = get-vdswitch $vdswitchStr -erroraction stop){
# Add-VDSwitchVMHost -VMHost $Object -VDSwitch $vdswitch -erroraction stop
# }
# }
# }
# # Remove excessive vdswitches
# foreach ($switch in $currentSwitches){
# if (!($cfg.host.vdswitch -contains $switch.name)){
# Remove-VDSwitchVMHost -vmhost $Object -VDSwitch $switch -confirm:$false
# }
# }
}