From 4855fe77b33128663653cc679aa0f51ba8618fe3 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 13:45:40 +0100 Subject: [PATCH 01/18] Removed whitespace --- Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index b7da43a07..bdd1c3dc6 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -19,7 +19,7 @@ - + @@ -35,7 +35,7 @@ id - + From ffda3895f37ba7343d7fada0f22f330879c2182f Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 13:55:04 +0100 Subject: [PATCH 02/18] Updated default output --- Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index bdd1c3dc6..2b98f50e5 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -17,6 +17,9 @@ + + + @@ -33,6 +36,9 @@ effectiveSlaDomainName + + if ($_.volumes) {$.volumes.mountPoints} else {(Get-RubrikVolumeGroup -Id $_.id).volumes.mountPoints} + id From 8e1dc480b9cddc2b797fe27f9c72c80a427bb38a Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 13:56:10 +0100 Subject: [PATCH 03/18] Displaying by default slow down query --- Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index 2b98f50e5..d88d870d4 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -37,7 +37,7 @@ effectiveSlaDomainName - if ($_.volumes) {$.volumes.mountPoints} else {(Get-RubrikVolumeGroup -Id $_.id).volumes.mountPoints} + if ($_.volumes) {$.volumes.mountPoints} id From 91b90c5549c6f106aaec50347368286c91dedfd5 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 13:59:31 +0100 Subject: [PATCH 04/18] Added detailedobject code block --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 4fff58dcd..7a930f250 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -91,7 +91,15 @@ function Get-RubrikVolumeGroup $result = Test-FilterObject -filter ($resources.Filter) -result $result $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result - return $result - + # If the Get-RubrikVolumeGroup function has been called with the -DetailedObject parameter a separate API query will be performed if the initial query was not based on ID + if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) { + for ($i = 0; $i -lt @($result).Count; $i++) { + $Percentage = [int]($i/@($result).count*100) + Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage + Get-RubrikVolumeGroup -id $result[$i].id + } + } else { + return $result + } } # End of process } # End of function From 96f5d45bb9270a47b86fe2fc65c27bae13b87207 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:00:13 +0100 Subject: [PATCH 05/18] Added detailedobject parameter --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 7a930f250..753f58549 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -48,6 +48,8 @@ function Get-RubrikVolumeGroup # SLA id value [Alias('effective_sla_domain_id')] [String]$SLAID, + # DetailedObject will retrieved the detailed VolumeGroup object, the default behavior of the API is to only retrieve a subset of the full VolumeGroup object unless we query directly by ID. Using this parameter does affect performance as more data will be retrieved and more API-queries will be performed. + [Switch]$DetailedObject, # Rubrik server IP or FQDN [String]$Server = $global:RubrikConnection.server, # API version From 8bbfefdfca870baac9574be1a382ed7084f8ea93 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:03:41 +0100 Subject: [PATCH 06/18] Updated to compare to $null --- Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index d88d870d4..5ed2b26b9 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -37,7 +37,7 @@ effectiveSlaDomainName - if ($_.volumes) {$.volumes.mountPoints} + if ($null -ne $_.volumes) {$.volumes.mountPoints} id From b62e65f5a2d8cb2dc01e322c9547eed62f8d0999 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:04:46 +0100 Subject: [PATCH 07/18] Fixed typo --- Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index 5ed2b26b9..ebe1366cc 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -37,7 +37,7 @@ effectiveSlaDomainName - if ($null -ne $_.volumes) {$.volumes.mountPoints} + if ($null -ne $_.volumes) {$_.volumes.mountPoints} id From ca12631e47784c2c2e3e7869d577b7e64a4734ab Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:15:18 +0100 Subject: [PATCH 08/18] Added help section --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 753f58549..18ea856f1 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -6,7 +6,7 @@ function Get-RubrikVolumeGroup Retrieves details on one or more volume groups known to a Rubrik cluster .DESCRIPTION - The Get-RubrikVolumeGroup cmdlet is used to pull a detailed data set from a Rubrik cluster on any number of volume groups + The Get-RubrikVolumeGroup cmdlet is used to pull a detailed data set from a Rubrik cluster on any number of volume groups. By default the 'Includes' property is not populated, unless when querying by ID or by using the -DetailedObject parameter .NOTES Written by Pierre Flammer for community usage @@ -26,6 +26,14 @@ function Get-RubrikVolumeGroup .EXAMPLE Get-RubrikVolumeGroup -Relic This will return all removed volume groups that were formerly protected by Rubrik. + + .EXAMPLE + Get-RubrikVolumeGroup -DetailedObject + This will return full details on all volume groups available on the Rubrik Cluster, this query will take longer as multiple API calls are required. The 'Includes' property will be populated + + .EXAMPLE + Get-RubrikVolumeGroup -Id VolumeGroup:::205b0b65-b90c-48c5-9cab-66b95ed18c0f + This will return full details on for the specified VolumeGroup ID #> [CmdletBinding()] From acff3f6006302f3d140ab7d5b8fbdf21cc62d3c6 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:19:11 +0100 Subject: [PATCH 09/18] Added exactly and validation for Get-RubrikSLA --- Tests/Get-RubrikVolumeGroup.Tests.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/Get-RubrikVolumeGroup.Tests.ps1 b/Tests/Get-RubrikVolumeGroup.Tests.ps1 index 583ab74a5..8c09c09c8 100644 --- a/Tests/Get-RubrikVolumeGroup.Tests.ps1 +++ b/Tests/Get-RubrikVolumeGroup.Tests.ps1 @@ -79,7 +79,8 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr Should -Throw "Missing an argument for parameter 'name'. Specify a parameter of type 'System.String' and try again." } Assert-VerifiableMock - Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Times 1 - Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Times 1 + Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 3 + Assert-MockCalled -CommandName Test-RubrikSLA -ModuleName 'Rubrik' -Exactly 1 + Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 3 } } \ No newline at end of file From 36dc47786329afa800ca8ae23d38acf83fb5a56d Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:30:59 +0100 Subject: [PATCH 10/18] Added unit tests for detailedobject / id --- Tests/Get-RubrikVolumeGroup.Tests.ps1 | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Tests/Get-RubrikVolumeGroup.Tests.ps1 b/Tests/Get-RubrikVolumeGroup.Tests.ps1 index 8c09c09c8..13385e6b9 100644 --- a/Tests/Get-RubrikVolumeGroup.Tests.ps1 +++ b/Tests/Get-RubrikVolumeGroup.Tests.ps1 @@ -83,4 +83,38 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr Assert-MockCalled -CommandName Test-RubrikSLA -ModuleName 'Rubrik' -Exactly 1 Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 3 } + Context -Name 'DetailedObject querying' { + Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith {} + Mock -CommandName Test-RubrikSLA -Verifiable -ModuleName 'Rubrik' -MockWith { + @{ 'slaid' = 'SLA1' } + } + Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { + @{ + 'name' = 'VG01' + 'id' = 'VolumeGroup:::11111' + 'hostname' = 'VG01.domain.local' + 'effectiveSlaDomainName' = 'Gold' + 'effectiveSlaDomainId' = 'SLA1' + 'hostId' = 'host01' + 'volumes' = @{ + 'mountPoints' = '/etc' + } + } + } + + It -Name 'Requesting all should return count of 1' -Test { + @( Get-RubrikVolumeGroup).Count | + Should -BeExactly 1 + } + + It -Name 'Requesting volumes property should be empty by default' -Test { + ( Get-RubrikVolumeGroup -id VolumeGroup:::11111).Volumes.mountPoints | + Should -BeExactly '/etc' + } + + It -Name 'Requesting volumes property should be empty by default' -Test { + ( Get-RubrikVolumeGroup -DetailedObject).Volumes.mountPoints | + Should -BeExactly '/etc' + } + } } \ No newline at end of file From 6daa57a2117ac894b5058336d256925be88a775e Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:37:26 +0100 Subject: [PATCH 11/18] Updated tests --- Tests/Get-RubrikVolumeGroup.Tests.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Get-RubrikVolumeGroup.Tests.ps1 b/Tests/Get-RubrikVolumeGroup.Tests.ps1 index 13385e6b9..ce812b27d 100644 --- a/Tests/Get-RubrikVolumeGroup.Tests.ps1 +++ b/Tests/Get-RubrikVolumeGroup.Tests.ps1 @@ -85,9 +85,6 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr } Context -Name 'DetailedObject querying' { Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith {} - Mock -CommandName Test-RubrikSLA -Verifiable -ModuleName 'Rubrik' -MockWith { - @{ 'slaid' = 'SLA1' } - } Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { @{ 'name' = 'VG01' @@ -107,14 +104,17 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr Should -BeExactly 1 } - It -Name 'Requesting volumes property should be empty by default' -Test { + It -Name 'Requesting volumes property should be /etc when queried by id' -Test { ( Get-RubrikVolumeGroup -id VolumeGroup:::11111).Volumes.mountPoints | Should -BeExactly '/etc' } - It -Name 'Requesting volumes property should be empty by default' -Test { + It -Name 'Requesting volumes property should be /etc when using -DetailedObject' -Test { ( Get-RubrikVolumeGroup -DetailedObject).Volumes.mountPoints | Should -BeExactly '/etc' } + Assert-VerifiableMock + Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 4 + Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 4 } } \ No newline at end of file From f405f6ff00e56c2b1df18b39c24a44f1e1a3d251 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 14:38:05 +0100 Subject: [PATCH 12/18] Fixed whitespace --- Tests/Get-RubrikVolumeGroup.Tests.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Get-RubrikVolumeGroup.Tests.ps1 b/Tests/Get-RubrikVolumeGroup.Tests.ps1 index ce812b27d..bffc9e9b4 100644 --- a/Tests/Get-RubrikVolumeGroup.Tests.ps1 +++ b/Tests/Get-RubrikVolumeGroup.Tests.ps1 @@ -25,7 +25,7 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr @{ 'slaid' = 'SLA1' } } Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { - @{ + @{ 'name' = 'VG01' 'id' = 'VolumeGroup:::11111' 'hostname' = 'VG01.domain.local' @@ -41,7 +41,7 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr 'effectiveSlaDomainId' = 'SLA1' 'hostId' = 'host02' }, - @{ + @{ 'name' = 'VG03' 'id' = 'VolumeGroup:::33333' 'hostname' = 'VG03.domain.local' @@ -49,7 +49,7 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr 'effectiveSlaDomainId' = 'SLA2' 'hostId' = 'host03' }, - @{ + @{ 'name' = 'VG04' 'id' = 'VolumeGroup:::44444' 'hostname' = 'VG04.domain.local' @@ -73,11 +73,11 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr It -Name 'Missing ID Exception' -Test { { Get-RubrikVolumeGroup -id } | Should -Throw "Missing an argument for parameter 'id'. Specify a parameter of type 'System.String' and try again." - } + } It -Name 'Missing Name Exception' -Test { { Get-RubrikVolumeGroup -name } | Should -Throw "Missing an argument for parameter 'name'. Specify a parameter of type 'System.String' and try again." - } + } Assert-VerifiableMock Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 3 Assert-MockCalled -CommandName Test-RubrikSLA -ModuleName 'Rubrik' -Exactly 1 From 87180dda15149b91bf2562f13db3194f33e6a53d Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 15:06:31 +0100 Subject: [PATCH 13/18] Made changes to make includes an added property rather than only visual --- .../Rubrik.VolumeGroup.ps1xml | 2 +- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml index ebe1366cc..05cdcebf5 100644 --- a/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml +++ b/Rubrik/ObjectDefinitions/Rubrik.VolumeGroup.ps1xml @@ -37,7 +37,7 @@ effectiveSlaDomainName - if ($null -ne $_.volumes) {$_.volumes.mountPoints} + includes id diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 18ea856f1..5be388910 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -81,7 +81,6 @@ function Get-RubrikVolumeGroup $resources = Get-RubrikAPIData -endpoint $function Write-Verbose -Message "Load API data for $($resources.Function)" Write-Verbose -Message "Description: $($resources.Description)" - } Process { @@ -99,17 +98,32 @@ function Get-RubrikVolumeGroup $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body $result = Test-ReturnFormat -api $api -result $result -location $resources.Result $result = Test-FilterObject -filter ($resources.Filter) -result $result - $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result - + # If the Get-RubrikVolumeGroup function has been called with the -DetailedObject parameter a separate API query will be performed if the initial query was not based on ID if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) { - for ($i = 0; $i -lt @($result).Count; $i++) { + $result = for ($i = 0; $i -lt @($result).Count; $i++) { $Percentage = [int]($i/@($result).count*100) Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage - Get-RubrikVolumeGroup -id $result[$i].id + Get-RubrikVolumeGroup -id $result[$i].id | ForEach-Object { + Select-Object -InputObject $_ -Property *,@{ + name = 'includes' + expression = { + if ($null -ne $_.volumes) {$_.volumes.mountPoints} + } + } + } } } else { - return $result + $selectsplat + $result = $result | Select-Object -Property *,@{ + name = 'includes' + expression = { + if ($null -ne $_.volumes) {$_.volumes.mountPoints} + } + } } + + $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result + return $result } # End of process } # End of function From a8ec3202780528bdb3151f2375d9ce86421c6560 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 15:08:08 +0100 Subject: [PATCH 14/18] Updated changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfac0585b..1b5368250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## 2019-10-30 + +### Added [-DetailedObject parameter in Get-RubrikVolumeGroup] + +* Changed default display +* Added `-DetailedObject` parameter to `Get-RubrikVolumeGroup` +* Addresses [Issue 487](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/487) + ## 2019-10-29 ### Changed [-Limit parameter in Get-RubrikReportData] From e1071b841a11e1821dbf6e4a86071ba0bcd891c3 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Wed, 30 Oct 2019 15:26:43 +0100 Subject: [PATCH 15/18] Fixed -DetailedObject bug --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index c6e1a4a55..40c737649 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -47,7 +47,7 @@ function Get-RubrikVolumeGroup [Switch]$Relic, # SLA Domain policy assigned to the volume group [String]$SLA, - # Filter the summary information based on the primarycluster_id of the primary Rubrik cluster. Use 'local' as the primary_cluster_id of the Rubrik cluster that is hosting the current REST API session. + # Filter the summary information based on the primarycluster_id of the primary Rubrik cluster. Use **_local** as the primary_cluster_id of the Rubrik cluster that is hosting the current REST API session. [Alias('primary_cluster_id')] [String]$PrimaryClusterID, # Volume group id @@ -101,10 +101,10 @@ function Get-RubrikVolumeGroup # If the Get-RubrikVolumeGroup function has been called with the -DetailedObject parameter a separate API query will be performed if the initial query was not based on ID if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) { - $result = for ($i = 0; $i -lt @($result).Count; $i++) { + for ($i = 0; $i -lt @($result).Count; $i++) { $Percentage = [int]($i/@($result).count*100) Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage - Get-RubrikVolumeGroup -id $result[$i].id | ForEach-Object { + $updatedresult = Get-RubrikVolumeGroup -id $result[$i].id | ForEach-Object { Select-Object -InputObject $_ -Property *,@{ name = 'includes' expression = { @@ -112,18 +112,11 @@ function Get-RubrikVolumeGroup } } } + Set-ObjectTypeName -TypeName $resources.ObjectTName -result $updatedresult } } else { - $selectsplat - $result = $result | Select-Object -Property *,@{ - name = 'includes' - expression = { - if ($null -ne $_.volumes) {$_.volumes.mountPoints} - } - } + $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result + return $result } - - $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result - return $result } # End of process } # End of function From 74c09e9ba13343d0d30ca8c3bfe1226baeb81d3e Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 31 Oct 2019 09:09:33 +0100 Subject: [PATCH 16/18] Fixed empty includes on -id --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 40c737649..90300f3f1 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -114,6 +114,15 @@ function Get-RubrikVolumeGroup } Set-ObjectTypeName -TypeName $resources.ObjectTName -result $updatedresult } + } elseif ($PSBoundParameters.containskey('id')) { + $result = $result | Select-Object -Property *,@{ + name = 'includes' + expression = { + if ($null -ne $_.volumes) {$_.volumes.mountPoints} + } + } + $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result + return $result } else { $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result return $result From 9a1502678b7d3cb21df21d80614e414b1aaa6d30 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 31 Oct 2019 09:17:45 +0100 Subject: [PATCH 17/18] Removed redundant piece of code --- Rubrik/Public/Get-RubrikVolumeGroup.ps1 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 index 90300f3f1..f0969d562 100644 --- a/Rubrik/Public/Get-RubrikVolumeGroup.ps1 +++ b/Rubrik/Public/Get-RubrikVolumeGroup.ps1 @@ -104,17 +104,10 @@ function Get-RubrikVolumeGroup for ($i = 0; $i -lt @($result).Count; $i++) { $Percentage = [int]($i/@($result).count*100) Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage - $updatedresult = Get-RubrikVolumeGroup -id $result[$i].id | ForEach-Object { - Select-Object -InputObject $_ -Property *,@{ - name = 'includes' - expression = { - if ($null -ne $_.volumes) {$_.volumes.mountPoints} - } - } - } + $updatedresult = Get-RubrikVolumeGroup -id $result[$i].id Set-ObjectTypeName -TypeName $resources.ObjectTName -result $updatedresult } - } elseif ($PSBoundParameters.containskey('id')) { + } elseif ($PSBoundParameters.containskey('id') -and (-not $DetailedObject)) { $result = $result | Select-Object -Property *,@{ name = 'includes' expression = { From 54e834ce1aabad85a857070a242d75701a2b3c36 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 31 Oct 2019 09:17:54 +0100 Subject: [PATCH 18/18] Updated tests for cross version compat --- Tests/Get-RubrikVolumeGroup.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Get-RubrikVolumeGroup.Tests.ps1 b/Tests/Get-RubrikVolumeGroup.Tests.ps1 index bffc9e9b4..ccc9cac13 100644 --- a/Tests/Get-RubrikVolumeGroup.Tests.ps1 +++ b/Tests/Get-RubrikVolumeGroup.Tests.ps1 @@ -105,12 +105,12 @@ Describe -Name 'Public/Get-RubrikVolumeGroup' -Tag 'Public', 'Get-RubrikVolumeGr } It -Name 'Requesting volumes property should be /etc when queried by id' -Test { - ( Get-RubrikVolumeGroup -id VolumeGroup:::11111).Volumes.mountPoints | + ( Get-RubrikVolumeGroup -id VolumeGroup:::11111).includes | Should -BeExactly '/etc' } It -Name 'Requesting volumes property should be /etc when using -DetailedObject' -Test { - ( Get-RubrikVolumeGroup -DetailedObject).Volumes.mountPoints | + ( Get-RubrikVolumeGroup -Name VG01 -DetailedObject).includes | Should -BeExactly '/etc' } Assert-VerifiableMock