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.4) uses CLI 1.1.4, commit dca13b1d898c80c0f7189b5adb4a5537685ad4a6. # 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($_) } } } } |