VMware Cloud Community
Henrique_Cicuto
Enthusiast
Enthusiast
Jump to solution

vSphere Linked Clones

Good evening,

I´m messing around a little with the APIs and decided to try something related to linked clones.

I know that Orchestrator already has some Linked Clones workflows but I wanted to try something from scratch because those already there are too confusing for me.

That being said, I noticed that the VcVirtualMachineSnapshot object has a createLinkedClone_Task method that returns a VcTask object and has 3 arguments:

  • arg0 - String: A name/prefix for the linked clone;
  • arg1 - String: Datastore name for provisioning;
  • arg2 - Boolean: Wether to overwrite if VM with same already exists.

Made a simple workflow to test it out and got the following:

  • Workflow run: Success (the task is created);
  • vCenter task information: Create Linked Clone - The operation is not supported on the object.
  • vpxd.log: vim.vm.Snapshot.createLinkedClone: vmodl.fault.NotSupported

(vmodl.fault.NotSupported) {

    faultCause = (vmodl.MethodFault) null,

    faultMessage = <unset>

    msg = "The operation is not supported on the object."

}

  • hostd.log: (Also see some "not supported" messages, but I can´t seen to find them again

Here´s what I´ve already tried:

  • Checked VM snapshotConfigSupported and snapshotOperationsSupported properties and they´re both OK;
  • Checked ESXi cloneFromSnapshotSupported property and also OK;
  • Checked VMware KB https://kb.vmware.com/s/article/1017380: Not appliable.

And for now I´ve basically ran out of options.

I couldn´t find much information about this createLinkedClone_Task method and what I needs to work.

Anyone could please shed some light into it?

Thank you very much.

Reply
0 Kudos
1 Solution

Accepted Solutions
filosmith
Enthusiast
Enthusiast
Jump to solution

Reply
0 Kudos
5 Replies
filosmith
Enthusiast
Enthusiast
Jump to solution

I know this doesn't directly answer your question, but the API explorer says that method is deprecated as of the 6.5 version of the plugin. It looks like com.vmware.library.vc.vm.linkedCloneVM() might work for you.

Reply
0 Kudos
Henrique_Cicuto
Enthusiast
Enthusiast
Jump to solution

Oh boy.

Could you show it, please?

I searched for it online here (https://www.vmware.com/support/orchestrator/doc/vro-vsphere65-api/html/VcVirtualMachineSnapshot.html... ) and it doesn´t say anything about being deprecated.

If that´s the case I´ll stick with the regular stuff then.

Thank you very much.

Reply
0 Kudos
filosmith
Enthusiast
Enthusiast
Jump to solution

pastedImage_0.png

Reply
0 Kudos
robrtb12
Enthusiast
Enthusiast
Jump to solution

Take a look at the workflow "Linked clone, no customization", its pretty straight forward and helped me to get a grasp on how to perform a linked clone in vRO.  The meat is in Scriptable task "Perform a Linked clone".

Create an array of Virtual Disks from the source VM

var  devices = vm.config.hardware.device;

var myDisks = new Array();

for (var i = 0; i< devices.length; i++) {

     if ( devices[i] instanceof VcVirtualDisk ) {

          myDisks.push(devices[i]);

     }

}

Create an array of 'VcVirtualMachineRelocateSpecDiskLocator' for each disk

var myVcVirtualMachineRelocateSpecDiskLocators = new Array();

for (var i = 0; i< myDisks.length; i++) {

     var myVcVirtualMachineRelocateSpecDiskLocator = new VcVirtualMachineRelocateSpecDiskLocator();

     myVcVirtualMachineRelocateSpecDiskLocator.datastore = datastore.reference;

     myVcVirtualMachineRelocateSpecDiskLocator.diskId = myDisks[i].key;

     myVcVirtualMachineRelocateSpecDiskLocator.diskMoveType = "createNewChildDiskBacking";

     myVcVirtualMachineRelocateSpecDiskLocators.push(myVcVirtualMachineRelocateSpecDiskLocator);

}

Get 'VcVirtualMachineRelocateSpec' and 'VcVirtualMachineCloneSpec'

var relocateSpec = System.getModule("com.vmware.library.vc.vm.spec").getRelocateSpec(datastore,myVcVirtualMachineRelocateSpecDiskLocators,host,pool,null);

var cloneSpec = System.getModule("com.vmware.library.vc.vm.spec").getCloneSpec(null,null,relocateSpec,powerOn,vm);

Add the snapshot reference to 'VcVirtualMachineCloneSpec' - https://www.vmware.com/support/orchestrator/doc/vro-vsphere65-api/html/VcVirtualMachineCloneSpec.htm...

cloneSpec.snapshot = snapshot.reference;

Create an array of 'VcTask' for the number of Linked clones specified

taskArray = new Array();

for (var i=0; i<numberOfLinkedClones ;i++){

     var linkedCloneName = name + "-"+i;

     var task = System.getModule("com.vmware.library.vc.vm").cloneVM(vm,folder,linkedCloneName,cloneSpec);

     taskArray.push(task);

}

Henrique_Cicuto
Enthusiast
Enthusiast
Jump to solution

Thanks for the direction guys.

Gave up on the deprecated method and went for the current workflows/actions as base.

Now I managed to create my own workflow from scratch that creates those clones, but now only the first one powers on. The rest returns with a "locked file" error message.

Working on that right now, but the question for this topic has been answered. So I´m marking this as answered and if I get stuck once again I´ll open a new one.

Thank you very much guys.

Reply
0 Kudos