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:
Made a simple workflow to test it out and got the following:
(vmodl.fault.NotSupported) {
faultCause = (vmodl.MethodFault) null,
faultMessage = <unset>
msg = "The operation is not supported on the object."
}
Here´s what I´ve already tried:
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.
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.
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.
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);
}
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.