VMware Cloud Community
vMarkusK1985
Expert
Expert

consolidate all Linked Clones

Hello,

I need to move away a whole vCD Provider VDC and its OrgVDC's from Fast Provisioning to Full VMs. So I changed all OrgVDC's and tried to consolidate all Linked Clones with my PowerCLI Script:

# Consolidate VMs

$vms = Get-OrgVdc | Get-CIVM | where {$_.ExtensionData.VCloudExtension.any.VirtualDisksMaxChainLength -ge 1} | Get-CIView

$vms_Success = @()

$vms_Failed = @()

Foreach ($vm in $vms) {

    Write-Output "Processing VM: $($VM.name)"

    try {

        $task = $vm.Consolidate_Task()

        Start-Sleep 1

        while ((Get-Task -Id $task.Id).State -ne "Success" ) {

            Write-Output "$($vm.name) - Percent: $((Get-Task -Id $task.Id).PercentComplete) / State: $((Get-Task -Id $task.Id).State)"

            Start-Sleep 1

            }

        $vms_Success += $vm

        } catch {

            Write-Output "      $($vm.name) Failed!"

            $vms_Failed += $vm

            } 

}

But consolidation via vCD API is ony possible for VMs in State 8 (POWERED_OFF ) and 3 (SUSPENDED). Most of the VMs are in State 4 (POWERED_ON), there is no consolidation possible...

Any workaround or recommendation how to handle that situation?

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK
Reply
0 Kudos
1 Reply
GScully42
Enthusiast
Enthusiast

I do it the old VM way on my cloud.

$vms = Get-DatastoreCluster  -Name superCluster | get-vm

foreach ($vm in $vms)

{

    $vm.ExtensionData.ConsolidateVMDisks()

}