Skip to content

Updated lines 687 and 715-722 to remove custom attributes on uninstall #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,13 @@ function Uninstall-PfavSpherePlugin {
Param(
[Parameter(ParameterSetName='HTML',Position=0)]
[switch]$html,

[Parameter(ParameterSetName='Flash',Position=0)]
[switch]$flash
[switch]$flash,
[Parameter(ParameterSetName='HTML',Position=1)]
[Parameter(ParameterSetName='Flash',Position=1)]
[switch]$PreserveAuthentication
)

$ErrorActionPreference = "stop"
#gather extension manager
$services = Get-view 'ServiceInstance'
Expand Down Expand Up @@ -711,8 +714,36 @@ 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")
write-host "Pure Storage HTML-5 plugin has been uninstalled."
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
}
Remove-CustomAttribute $attribute.Name -Confirm:$false
}
}
}
write-host "Pure Storage HTML-5 plugin has been uninstalled."
}
}
else {
Expand All @@ -724,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."
}
}
Expand Down