VMware Cloud Community
justin_emerson
Enthusiast
Enthusiast

Create Linked Clone?

When using View Composer with vCenter, a task it listed under recent tasks called "Create Linked Clone". There must be some vCenter API command to do this. I'm trying to figure out if there's a manual way to run this Create Linked Clone method from a Powershell script. As far as I know, View Composer itself shouldn't be required to create a Linked Clone; from what I understand it uses its database and such to just keep track of replicas and linekd clones and such.

Does anyone know what the API command to run this is? Or does it just become this task if you pass a funky VirtualMachineCloneSpec?

0 Kudos
5 Replies
LucD
Leadership
Leadership

Afaik there is no "clone" method in the SDK.

But something similar was discussed in .

As you can read there Carter wrote a function called New-TkeLinkedClone for the VITK Extensions.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

justin_emerson
Enthusiast
Enthusiast

LucD,

As always you're awesome. Don't know why I didn't think to look at the Tke pack.

I still think there must be an API command for it, otherwise why would it show up correctly in the Recent Tasks list in the VI Client with a nice pretty name? It must have been added in Update 2 (since that was the requirement during the VDM3 beta) so it may not be in the Docs. I've snooped around the MOB and I can't find it either...

Guess I'll have to go install PowerShell 2.0 CTP3

0 Kudos
LucD
Leadership
Leadership

I didn't see such a call (yet), I suspect it is a combination of calls from within the Composer.

To verify you could log all the SOAP calls that are made.

See Carter's blog entry VI Toolkit on PowerScripting Podcast


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

LucD
Leadership
Leadership

Perhaps I have to be a bit more specific, there is of course a "clone" method (see CloneVM_Task) but afaik there is no "linked clone" method in the APIs.

Hope this clarifies matters.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
admin
Immortal
Immortal

The following PowerShell code uses the vSphere CloneVM API to create a linked clone from a source VM’s current snapshot point. The clone will be located on the same host, datastore, and folder as the source VM. It requires a snapshot to exist on the source VM, and it requires vCenter Server.

connect-viserver "vCenter_hostname"

$sourceVM = Get-VM "source_vm_name" | Get-View

$cloneName = "linked_clone_name"

$cloneFolder = $sourceVM.parent

$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec

$cloneSpec.Snapshot = $sourceVM.Snapshot.CurrentSnapshot

$cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec

$cloneSpec.Location.DiskMoveType = "createNewChildDiskBacking"

$sourceVM.CloneVM_Task( $cloneFolder, $cloneName, $cloneSpec )

Note that DiskMoveType is not a string; it's of enumerated type VirtualMachineRelocateDiskMoveOptions.

-Keshav Attrey

http://www.vmdev.info

0 Kudos