public/Restore-VM.ps1
|
function Restore-ZStackVM { # .SYNOPSIS # Recovers a deleted VM to Stopped. # .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(DefaultParameterSetName = 'VM', SupportsShouldProcess, ConfirmImpact = 'Medium')] param( [Parameter(Mandatory, Position = 0, ValueFromPipeline, ParameterSetName = 'VM')] [ValidateNotNullOrEmpty()] [object[]] $VM, [Parameter(Mandatory, ParameterSetName = 'Id')] [ValidateNotNullOrEmpty()] [ValidatePattern('\A[A-Za-z0-9-]{1,128}\z')] [string[]] $Id, [ValidateRange(1, 3600)] [int] $TimeoutSeconds = 300, [ValidateRange(1, 60)] [int] $PollSeconds = 2, [object] $Server ) process { $parameter = $PSCmdlet.ParameterSetName Invoke-CloudVMLifecycle -Caller $PSCmdlet -ParameterSet $parameter -Selectors $PSBoundParameters[$parameter] -Server $Server -Command recover -Operation RestoreVM -Description 'Recover deleted VM' -State Stopped -TimeoutSeconds $TimeoutSeconds -PollSeconds $PollSeconds } } |