From 43c3c33ab2a0791fca8d33a97ade713782c53478 Mon Sep 17 00:00:00 2001 From: Jason Coleman Date: Thu, 14 Sep 2017 12:48:39 -0700 Subject: [PATCH 1/2] Add VDS Membership Check --- .../Tests/Host/vDS-HostMembership.Vester.ps1 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Vester/Tests/Host/vDS-HostMembership.Vester.ps1 diff --git a/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 b/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 new file mode 100644 index 0000000..fe5bf38 --- /dev/null +++ b/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 @@ -0,0 +1,36 @@ +# 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).name | sort + # foreach ($vdswitchStr in $cfg.host.vdswitch){ + # if (!($currentSwitches -contains $vdswitchStr)){ + # if ($vdswitch = get-vdswitch $vdswitchStr -erroraction stop){ + # Add-VDSwitchVMHost -VMHost $Object -VDSwitch $vdswitch -erroraction stop + # } + # } + # } + # # Remove excessive vdswitches +} From 054104f88907f48de268f3de9dbd73f02ab237cc Mon Sep 17 00:00:00 2001 From: Jason Coleman Date: Thu, 14 Sep 2017 13:17:51 -0700 Subject: [PATCH 2/2] Add inactive prototype fix code --- Vester/Tests/Host/vDS-HostMembership.Vester.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 b/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 index fe5bf38..a246264 100644 --- a/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 +++ b/Vester/Tests/Host/vDS-HostMembership.Vester.ps1 @@ -24,13 +24,18 @@ $Type = 'string[]' [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).name | sort + # $currentSwitches = Get-VDSwitch -VMHost $Object # foreach ($vdswitchStr in $cfg.host.vdswitch){ - # if (!($currentSwitches -contains $vdswitchStr)){ + # 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 + # } + # } }