Skip to content

Commit

Permalink
Merge branch 'gpduck-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtboren committed Jul 1, 2015
2 parents 646541d + 9458311 commit 0027e4d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DRSRule.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'DRSRule.psm1'

# Version number of this module.
ModuleVersion = '1.0.0'
ModuleVersion = '1.0.1'

# ID used to uniquely identify this module
GUID = 'f7edec59-261e-43e3-818c-6d92653ff05c'
Expand Down
18 changes: 6 additions & 12 deletions DRSRule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ Function Get-DrsVMGroup
## updated to use $oThisCluster, instead of $Cluster, which would get all cluster names if more than one cluster
Cluster = $oThisCluster.Name
VM = $(
if($_.Vm)
{
Get-View $_.Vm -Property Name | Select-Object -ExpandProperty Name
}
if($_.Vm) {Get-View $_.Vm -Property Name | Select-Object -ExpandProperty Name}
else {$null}
)
VMId = $_.Vm
UserCreated = [Boolean]$_.UserCreated
Expand Down Expand Up @@ -78,10 +76,8 @@ Function Get-DrsVMHostGroup
Name = $_.Name
Cluster = $oThisCluster.Name
VMHost = $(
if($_.Host)
{
Get-View $_.Host -Property Name | Select-Object -ExpandProperty Name
}
if($_.Host) {Get-View $_.Host -Property Name | Select-Object -ExpandProperty Name}
else {$null}
)
VMHostId = $_.Host
UserCreated = [Boolean]$_.UserCreated
Expand Down Expand Up @@ -127,10 +123,8 @@ Function Get-DrsVMToVMRule
Enabled = [Boolean]$_.Enabled
KeepTogether = $($_ -is [VMware.Vim.ClusterAffinityRuleSpec])
VM = $(
if($_.VM)
{
Get-View $_.VM -Property Name | Select-Object -ExpandProperty Name
}
if($_.VM) {Get-View $_.VM -Property Name | Select-Object -ExpandProperty Name}
else {$null}
)
VMId = $_.VM
UserCreated = [Boolean]$_.UserCreated
Expand Down
13 changes: 13 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## DRSRule PowerShell module ##

### Changelog ###

### v1.0.1 ###

30 Jun 2015

- \[bugfix] fixed rare problem with creating new `DRSRule.VMHostGroup` for VMHost group item where `Host` property of corresponding `VMware.Vim.ClusterHostGroup` object is empty and user is using PowerShell v5 (credit [gpduck](https://github.com/gpduck)). This was in `Get-DrsVMHostGroup`. Updated similar situation for functions `Get-DrsVMGroup` and `Get-DrsVMToVMRule`.

### v1.0.0 ###

Initial release, 21 Jan 2015.
19 changes: 10 additions & 9 deletions tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Get-DrsVMtoVMHostRule -Cluster dcluster[01]
Get-Cluster $strCluster | Get-DrsVMtoVMHostRule

New-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -VM VM0,VM1,VM2
New-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -VM VM10,VM11,VM12
--Get-Cluster $strCluster | Get-VM VM0,VM1,VM2 | New-DrsVMGroup -Name VmGrp1
New-DrsVMGroup -Name VmGrp1 -Cluster $strCluster -VM VM10,VM11,fakeVMName ## should throw error -- no such VM
New-DrsVMGroup -Name VmGrp1 -Cluster $strCluster -VM VM10,VM11,VM12
--Get-Cluster $strCluster | Get-VM VM0,VM1,VM2 | New-DrsVMGroup -Name VmGrp2 ## not taking from pipeline
New-DrsVMGroup -Name VmGrpNew -Cluster $strCluster -VM VM10,VM11,fakeVMName ## should throw error -- no such VM
Set-DrsVMGroup -Name nonexistentVMGroup -Cluster $strCluster -VM VM10,VM11 ## should throw error -- no such VMGroup
Set-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -VM VM1[01] ## removing one VM
Set-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -VM VM12 -Append ## adding back a VM
Expand All @@ -28,9 +28,9 @@ Set-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -VM fakeVMName -Append ## shoul
??Get-Cluster $strCluster | Get-VM VM0,VM1 | Set-DrsVMGroup -Name VmGrp0 -Cluster $strCluster -WhatIf
Set-DrsVMGroup -Name VmGrp0 -Cluster (Get-Cluster $strCluster) -VM (Get-VM VM10,VM11) -Append
Remove-DrsVMGroup -Name VmGrp0 -Cluster $strCluster
Remove-DrsVMGroup -Name fakeGroupName -Cluster $strCluster ## should throw error -- no such group
--Remove-DrsVMGroup -Name fakeGroupName -Cluster $strCluster ## should throw error -- no such group; doesn't throw error
Get-DrsVMGroup VmGrp0 -Cluster $strCluster | Remove-DrsVMGroup
Remove-DrsVMGroup -Name VmGrp0 -Cluster (Get-Cluster $strCluster)
--Remove-DrsVMGroup -Name VmGrp0 -Cluster (Get-Cluster $strCluster) ## problem: if group VmGrp0 does not exist, should error to that effect; currently continues as if actually removing such a group

New-DrsVMhostGroup -Name VMHostGrp0 -Cluster $strCluster -VMHost *
New-DrsVMhostGroup -Name VMHostGrp0 -Cluster $strCluster -VMHost * ## should throw error -- dupe group name
Expand All @@ -43,8 +43,8 @@ Set-DrsVMhostGroup -Name VMHostGrp0 -Cluster $strCluster -VMHost fakeVMHostName
Get-DrsVMHostGroup -Cluster $strCluster | Set-DrsVMHostGroup -VMHost dev0d,dev0y ## should throw error -- invalid VMHost name
Remove-DrsVMhostGroup -Name VMHostGrp0 -Cluster $strCluster
Get-DrsVMHostGroup -Cluster $strCluster | Remove-DrsVMhostGroup
Remove-DrsVMhostGroup -Name VMHostGrp0 -Cluster (Get-Cluster $strCluster)
Remove-DrsVMhostGroup -Name fakeGroupname -Cluster $strCluster ## should throw error -- invalid group name
--Remove-DrsVMhostGroup -Name VMHostGrp0 -Cluster (Get-Cluster $strCluster) ## problem: if group VmGrp0 does not exist, should error to that effect; currently continues as if actually removing such a group
--Remove-DrsVMhostGroup -Name fakeGroupname -Cluster $strCluster ## should throw error -- invalid group name; doesn't throw error

New-DrsVMtoVMHostRule -Name VmToHostRule0 -Cluster $strCluster -Enabled -Mandatory -VMGroupName VmGrp0 -AffineHostGroupName VMHostGrp0 -WhatIf
New-DrsVMtoVMHostRule -Name VmToHostRule0 -Cluster $strCluster -Enabled -Mandatory -VMGroupName VmGrp0 -AffineHostGroupName VMHostGrp0 ## should throw error -- dupe rule name
Expand All @@ -59,8 +59,9 @@ Set-DrsVMtoVMHostRule -Name VmToHostRule0 -Cluster $strCluster -VMGroup fakeGrou
Set-DrsVMtoVMHostRule -Name VmToHostRule0 -Cluster $strCluster -VMHostGroup fakeGroupName ## should throw error -- invalid VMHostgroup name
Get-Cluster $strCluster | Get-DrsVMToVMHostRule VmToHostRule0 | Set-DrsVMtoVMHostRule -Mandatory | fl *
Remove-DrsVMtoVMHostRule -Cluster $strCluster -Name VmToHostRule0
--Remove-DrsVMtoVMHostRule -Cluster $strCluster -Name VmToHostRule0 ## should throw error on 2nd run -- invalid rule name, as it was already removed; doesn't throw error
Get-Cluster $strCluster | Get-DrsVMtoVMHostRule -Name VmToHostRule0 | Remove-DrsVMtoVMHostRule
Remove-DrsVMtoVMHostRule -Cluster (Get-Cluster $strCluster) -Name nonExistentRuleName -Verbose ## should throw error -- no such rule
--Remove-DrsVMtoVMHostRule -Cluster (Get-Cluster $strCluster) -Name nonExistentRuleName -Verbose ## should throw error -- no such rule; does not

New-DrsVMtoVMRule -Name VmToVmRule0 -Cluster $strCluster -Enabled -KeepTogether -VM VM10,VM11
New-DrsVMtoVMRule -Name VmToVmRule0 -Cluster $strCluster -Enabled -KeepTogether -VM VM10,VM11 ## should throw error -- dupe rule name
Expand All @@ -70,7 +71,7 @@ Set-DrsVMtoVMRule -Name VmToVmRule0 -Cluster $strCluster -VM VM13 -Append
Set-DrsVMtoVMRule -Name VmToVmRule0 -Cluster $strCluster -Enabled -KeepTogether:$false -VM fakeVMName ## should throw error -- invalid VM name
Set-DrsVMtoVMRule -Name fakeRuleName -Cluster $strCluster -Enabled ## should throw error -- invalid rule name
Get-Cluster $strCluster | Get-DrsVMToVMRule VMToVmRule0 | Set-DrsVMtoVMRule -Mandatory:$false -KeepTogether -VM VM1[12]
Remove-DrsVMToVMRule fakeRuleName ## should throw error -- invalid rule name
--Remove-DrsVMToVMRule fakeRuleName ## should throw error -- invalid rule name; does not
Get-Cluster $strCluster | Get-DrsVMToVMRule VMToVmRule0 | Remove-DrsVMToVMRule

Export-DrsRule -Path c:\rules.json
Expand Down

0 comments on commit 0027e4d

Please sign in to comment.