From 6c63c2dba0454a141f0274cdae89ab21a6cdfcb7 Mon Sep 17 00:00:00 2001 From: David Stamen Date: Tue, 24 Mar 2020 16:12:52 -0400 Subject: [PATCH 1/5] Updated lines 687 and 715-722 to remove custom attributes on uninstall --- .../PureStorage.FlashArray.VMware.Software.psm1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 index 08b9094..2ede319 100644 --- a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 +++ b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 @@ -684,6 +684,7 @@ function Uninstall-PfavSpherePlugin { $extensionMgr = Get-view $services.Content.ExtensionManager $htmlPluginVersion = ($extensionMgr.FindExtension("com.purestorage.purestoragehtml")).version $flashPluginVersion = ($extensionMgr.FindExtension("com.purestorage.plugin.vsphere")).version + $customAttributes = "Pure Flash Array Key Count","Pure Flash Array Key0","Pure1Count","Pure1Key0" if (($html -ne $true) -and ($flash -ne $true)) { @@ -712,6 +713,13 @@ function Uninstall-PfavSpherePlugin { if ($PSCmdlet.ShouldProcess("","$($confirmText)`n`r","Please confirm uninstall.`n`r")) { $extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") + try { + $customAttributes | % {Get-CustomAttribute -Name $_} | Remove-CustomAttribute -Confirm:$false + } + catch { + $customAttributes = "Pure1Count","Pure1Key0" + $customAttributes | % {Get-CustomAttribute -Name $_} | Remove-CustomAttribute -Confirm:$false + } write-host "Pure Storage HTML-5 plugin has been uninstalled." } } From 4fe2bc7ea9fa29cf1ba3a479216700b855d2ba5f Mon Sep 17 00:00:00 2001 From: David Stamen Date: Wed, 25 Mar 2020 08:00:17 -0400 Subject: [PATCH 2/5] Added lines 716-735 to account for removing the custom attributes on plugin uninstall for Pure1 JWT. --- ...ureStorage.FlashArray.VMware.Software.psm1 | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 index 2ede319..dd5f6af 100644 --- a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 +++ b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 @@ -684,7 +684,6 @@ function Uninstall-PfavSpherePlugin { $extensionMgr = Get-view $services.Content.ExtensionManager $htmlPluginVersion = ($extensionMgr.FindExtension("com.purestorage.purestoragehtml")).version $flashPluginVersion = ($extensionMgr.FindExtension("com.purestorage.plugin.vsphere")).version - $customAttributes = "Pure Flash Array Key Count","Pure Flash Array Key0","Pure1Count","Pure1Key0" if (($html -ne $true) -and ($flash -ne $true)) { @@ -712,15 +711,29 @@ function Uninstall-PfavSpherePlugin { $confirmText = "Uninstall HTML-5 plugin version $($htmlPluginVersion) on vCenter $($global:DefaultVIServer.name)?" if ($PSCmdlet.ShouldProcess("","$($confirmText)`n`r","Please confirm uninstall.`n`r")) { - $extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") - try { - $customAttributes | % {Get-CustomAttribute -Name $_} | Remove-CustomAttribute -Confirm:$false - } - catch { - $customAttributes = "Pure1Count","Pure1Key0" - $customAttributes | % {Get-CustomAttribute -Name $_} | Remove-CustomAttribute -Confirm:$false + #extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") + #Remove Custom Attribute Keys + $customAttributes = Get-CustomAttribute Pure* + foreach ($attribute in $customAttributes) { + if ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Key0") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false } - write-host "Pure Storage HTML-5 plugin has been uninstalled." + elseif ($attribute.Name -like "Pure Flash Array Key Count") { + $fl = get-folder + $PureFlashArrayKeyCount = (Get-Annotation -CustomAttribute "Pure Flash Array Key Count" -Entity ($fl[0].Name)).value + foreach ($Key in 1..$PureFlashArrayKeyCount) { + Get-CustomAttribute -Name "Pure Flash Array Key[$($key - 1)]" | Remove-CustomAttribute -Confirm:$false + } + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + } + write-host "Pure Storage HTML-5 plugin has been uninstalled." } } else { From 2e3bda8e146db3f0c9e9b257ca3a935990862c92 Mon Sep 17 00:00:00 2001 From: David Stamen Date: Wed, 25 Mar 2020 08:02:25 -0400 Subject: [PATCH 3/5] Fixed accidentally commented line --- .../PureStorage.FlashArray.VMware.Software.psm1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 index dd5f6af..377188c 100644 --- a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 +++ b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 @@ -711,8 +711,9 @@ function Uninstall-PfavSpherePlugin { $confirmText = "Uninstall HTML-5 plugin version $($htmlPluginVersion) on vCenter $($global:DefaultVIServer.name)?" if ($PSCmdlet.ShouldProcess("","$($confirmText)`n`r","Please confirm uninstall.`n`r")) { - #extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") - #Remove Custom Attribute Keys + extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") + + #Remove Custom Attribute Keys $customAttributes = Get-CustomAttribute Pure* foreach ($attribute in $customAttributes) { if ($attribute.Name -like "Pure1Count") { From 238bdd5b8f9c19cbde90b138d5d2451e21d1246c Mon Sep 17 00:00:00 2001 From: David Stamen Date: Wed, 25 Mar 2020 11:25:11 -0400 Subject: [PATCH 4/5] Added ability to preserve attributes --- ...ureStorage.FlashArray.VMware.Software.psm1 | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 index 377188c..f910d1b 100644 --- a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 +++ b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 @@ -676,7 +676,10 @@ function Uninstall-PfavSpherePlugin { [switch]$html, [Parameter(ParameterSetName='Flash',Position=0)] - [switch]$flash + [switch]$flash, + + [Parameter(ParameterSetName='PreserveAuthentication',Position=0)] + [switch]$preserveAuthentication ) $ErrorActionPreference = "stop" #gather extension manager @@ -713,25 +716,31 @@ function Uninstall-PfavSpherePlugin { { extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") + if ($preserveAuthentication -eq $true) { + Write-Host "Preserving Authentication Attributes" + } + else { #Remove Custom Attribute Keys + Write-Host "Removing Authentication Attributes" $customAttributes = Get-CustomAttribute Pure* - foreach ($attribute in $customAttributes) { - if ($attribute.Name -like "Pure1Count") { - Remove-CustomAttribute $attribute.Name -Confirm:$false - } - elseif ($attribute.Name -like "Pure1Key0") { - Remove-CustomAttribute $attribute.Name -Confirm:$false - } - elseif ($attribute.Name -like "Pure1Count") { - Remove-CustomAttribute $attribute.Name -Confirm:$false - } - elseif ($attribute.Name -like "Pure Flash Array Key Count") { - $fl = get-folder - $PureFlashArrayKeyCount = (Get-Annotation -CustomAttribute "Pure Flash Array Key Count" -Entity ($fl[0].Name)).value - foreach ($Key in 1..$PureFlashArrayKeyCount) { - Get-CustomAttribute -Name "Pure Flash Array Key[$($key - 1)]" | Remove-CustomAttribute -Confirm:$false + foreach ($attribute in $customAttributes) { + if ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Key0") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure Flash Array Key Count") { + $fl = get-folder + $PureFlashArrayKeyCount = (Get-Annotation -CustomAttribute "Pure Flash Array Key Count" -Entity ($fl[0].Name)).value + foreach ($Key in 1..$PureFlashArrayKeyCount) { + Get-CustomAttribute -Name "Pure Flash Array Key[$($key - 1)]" | Remove-CustomAttribute -Confirm:$false + } + Remove-CustomAttribute $attribute.Name -Confirm:$false } - Remove-CustomAttribute $attribute.Name -Confirm:$false } } write-host "Pure Storage HTML-5 plugin has been uninstalled." From ae0abf8bb1522d5bcbf9bcee6054f771008e08f8 Mon Sep 17 00:00:00 2001 From: David Stamen Date: Wed, 25 Mar 2020 12:49:38 -0400 Subject: [PATCH 5/5] Updated for HTML and Flash --- ...ureStorage.FlashArray.VMware.Software.psm1 | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 index f910d1b..0b7e658 100644 --- a/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 +++ b/PureStorage.FlashArray.VMware.Software/PureStorage.FlashArray.VMware.Software.psm1 @@ -674,13 +674,13 @@ function Uninstall-PfavSpherePlugin { Param( [Parameter(ParameterSetName='HTML',Position=0)] [switch]$html, - [Parameter(ParameterSetName='Flash',Position=0)] [switch]$flash, - - [Parameter(ParameterSetName='PreserveAuthentication',Position=0)] - [switch]$preserveAuthentication + [Parameter(ParameterSetName='HTML',Position=1)] + [Parameter(ParameterSetName='Flash',Position=1)] + [switch]$PreserveAuthentication ) + $ErrorActionPreference = "stop" #gather extension manager $services = Get-view 'ServiceInstance' @@ -716,7 +716,7 @@ function Uninstall-PfavSpherePlugin { { extensionMgr.UnregisterExtension("com.purestorage.purestoragehtml") - if ($preserveAuthentication -eq $true) { + if ($PreserveAuthentication -eq $true) { Write-Host "Preserving Authentication Attributes" } else { @@ -755,6 +755,33 @@ function Uninstall-PfavSpherePlugin { if ($PSCmdlet.ShouldProcess("","$($confirmText)`n`r","Please confirm uninstall.`n`r")) { $extensionMgr.UnregisterExtension("com.purestorage.plugin.vsphere") + if ($PreserveAuthentication -eq $true) { + Write-Host "Preserving Authentication Attributes" + } + else { + #Remove Custom Attribute Keys + Write-Host "Removing Authentication Attributes" + $customAttributes = Get-CustomAttribute Pure* + foreach ($attribute in $customAttributes) { + if ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Key0") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure1Count") { + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + elseif ($attribute.Name -like "Pure Flash Array Key Count") { + $fl = get-folder + $PureFlashArrayKeyCount = (Get-Annotation -CustomAttribute "Pure Flash Array Key Count" -Entity ($fl[0].Name)).value + foreach ($Key in 1..$PureFlashArrayKeyCount) { + Get-CustomAttribute -Name "Pure Flash Array Key[$($key - 1)]" | Remove-CustomAttribute -Confirm:$false + } + Remove-CustomAttribute $attribute.Name -Confirm:$false + } + } + } write-host "Pure Storage flash plugin has been uninstalled." } }