VMware Cloud Community
ITSnoesberger
Enthusiast
Enthusiast

vCloud Director sVmotion over Powercli

I've created a Script to move VM's over the vCloud Director API to an other Datastore in the same PvDC. (Datastore with the lowest UsedSpace)

Here the most important parts:

$civm = get-civm <VMName>

$datastore = $civm.Orgvdc.ProviderVdc | Get-CIDatastore | Where-Object {$_.Name -like "<search Criteria>"} | Sort-Object UsedSpaceGB | Select-Object -First 1

$civm.ExtensionData.Relocate($datastore.href)

But when I try to move a vShield Edge, I get the following error:

Exception calling "Relocate" with "1" argument(s): "Access is forbidden"

The same error I get when I try to move a template in the catalog.

$template = get-org <org> | get-catalog | Get-CIVAppTemplate <name>

$template.ExtensionData.Relocate($datastore.href)

How can I move Edges and Templates over the vCloud API with Powershell?

I don't would like to do it directly over vSphere because we have a strechted cluster and 2 ProviderVDC's that have seperated datastores. When our support is moving the VM's in vSphere to a wrong datastores, the vCloud Director can't find the VM anymore. Over the API of the vCloud Director this will be checked by default from VMWare.

Thanks for your help.

0 Kudos
1 Reply
TomRalph
VMware Employee
VMware Employee

I know this is about a year late... but your start helped me solve it.

$template.ExtensionData.Children.VM | % {

     $_.Relocate($datastore.href)

     $_.Consolidate()

}

Change the last portion to the above and it will go through. 

0 Kudos