public/Remove-Volume.ps1
|
function Remove-ZStackVolume { # .SYNOPSIS # Deletes a detached data volume under a recoverable deletion policy. # .DESCRIPTION # ZStack PowerCLI (ZStack.PowerCLI 1.1.5) uses CLI 1.1.5, commit 6fcf509ff540d0098f54c1c33609dbe9f572c837. # Connection configuration namespace: zstack-powershell. # .LINK # https://github.com/terraform-zstack-modules/zstack-cli-go/blob/main/docs/powershell.md [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] param( [Parameter(Mandatory, Position = 0, ValueFromPipeline)] [ValidateNotNullOrEmpty()] [object[]] $Volume, [ValidateRange(1, 3600)] [int] $TimeoutSeconds = 300, [object] $Server ) process { foreach ($item in $Volume) { try { $target = Get-CloudResourceSelection $item Volume $Server RemoveVolume $arguments = @('delete', 'volume', $target.Id) Invoke-CloudDeviceWrite $PSCmdlet $target $arguments delete-volume RemoveVolume 'Delete detached data volume to recycle bin' $TimeoutSeconds } catch { $PSCmdlet.WriteError($_) } } } } |