From 876d70ca476eaf1e3b2d4fcd6ea5f52f22bb4209 Mon Sep 17 00:00:00 2001 From: MTBoren Date: Wed, 25 Apr 2018 20:05:57 -0400 Subject: [PATCH] fix #12 (issues adding VM to empty DrsVMGroup) --- DRSRule.psm1 | 4 ++-- changelog.md | 1 + todo.md | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DRSRule.psm1 b/DRSRule.psm1 index 7153652..42a9f94 100644 --- a/DRSRule.psm1 +++ b/DRSRule.psm1 @@ -1084,8 +1084,8 @@ function Set-DrsVMGroup { ## if all VMs were specified to be remove from the group (if the $groupSpec.Info.VM value is $null), write warning and take no further action (may not be supported by vSphere API, seemingly; trying to do so via GUI returns message to the effect of, "Cannot remove all members of group") if ($null -eq $groupSpec.Info.VM) {Write-Warning "Removing all VMs from VMGroup not supported. Taking no action"} - ## if the VM list is the same between the existing VMGroup and the new ClusterGroupSpec, do not bother calling ReconfigureComputeResource() method - elseif ($null -eq (Compare-Object -ReferenceObject $arrOriginalVMIDsInTarget -DifferenceObject $groupSpec.Info.VM)) { + ## if the VMGroup had any VMs in it already, and the VM list is the same between the existing VMGroup and the new ClusterGroupSpec, do not bother calling ReconfigureComputeResource() method + elseif (($null -ne $arrOriginalVMIDsInTarget) -and $null -eq (Compare-Object -ReferenceObject $arrOriginalVMIDsInTarget -DifferenceObject $groupSpec.Info.VM)) { Write-Verbose "Not changing VMGroup (no new members added, and no members to remove)" } ## end if else { diff --git a/changelog.md b/changelog.md index 0fa41c4..2efced2 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ ### v1.2.1 Apr 2018 +- \[bugfix] fixed [Issue #12](https://github.com/PowerCLIGoodies/DRSRule/issues/12), "Error at addition in empty group the VM list" -- can now add a VM to a DrsVMGroup that has no VM members to start, for whatever reason (VM atrophy, maybe?) - \[bugfix] fixed [Issue #15](https://github.com/PowerCLIGoodies/DRSRule/issues/15), "Metadata file VMware.Vim.dll could not be found" -- now loads items properly for VMware PowerCLI version 10 as well, and on Windows PowerShell and PowerShell Core. ### v1.2.0 diff --git a/todo.md b/todo.md index c0f4e20..f620bd4 100644 --- a/todo.md +++ b/todo.md @@ -15,3 +15,4 @@ - update `Get-Drs*` behavior to match standard `Get-*` cmdlets' behavior of returning error when no item found of given name when `$Name` has no wildcard: - `Get-DrsVMGroup bogusGroupName` should throw error - add function to get objects from exported JSON, to essentially return info items that could be used for `New-Drs*`, but that would be useful to see what items are stored in given JSON +- maybe (if only for the sake of thoroughness): look into addressing potential issues that might arise from `Compare-Object` calls where a reference- or difference object might be $null (which would cause `Compare-Object` to throw an error) -- an example of where this was fixed: `Set-DrsVMGroup`; may be minimal chance of hitting bug, as DRS VM/VMHost groups should generally have members, but may be worth a look throughout rest of code