Hi,
I'm using VMO to clone and sysprep VMs.
The workflow works fine but now customers requested larger os disks.
The clone from template task will create a 20GB Disk (Harddisk 1) and sysprep.inf is customized to extend os partition (ExtendOEMPartition=1). When I pause the workflow and grow the disk manually using vmkfstools -X or the vCenter API and then restart the workflow I end up with a larger os disk, just as I wanted.
How can I do the disk resizing part in vmo to automate the whole workflow again?
Here's the code I was working on, the replace and edit operations throw errors in VC (the workflow ends successfully):
var devices=vm.config.hardware.device;
//getting OS disk
for (i in devices){
var device=devices;
if (device.deviceInfo.label == "Hard Disk 1" && System.getObjectClassName(device)=="VimVirtualDisk") {
var disk=device;
+System.log("Disk: " + disk);+
break;
}
}
+
//create spec
if (device != null) {+
var configSpec = new VimVirtualMachineConfigSpec();
var deviceConfigSpecs = new Array();
+var deviceConfigSpec;
var capacityInKb = parseInt( "" + (capacityInGB10241024) );+
disk.capacityInKB = capacityInKb;
+System.log(disk.capacityInKB);
deviceConfigSpec = new VimVirtualDeviceConfigSpec();+
deviceConfigSpec.device = disk;
deviceConfigSpec.fileOperation = VimVirtualDeviceConfigSpecFileOperation.replace;
deviceConfigSpec.operation = VimVirtualDeviceConfigSpecOperation.edit;
+deviceConfigSpecs[0] = deviceConfigSpec;
// List of devices+
+configSpec.deviceChange = deviceConfigSpecs;
// Launch the reconfigVM task+
+task = vm.reconfigVM_Task( configSpec );
}
Error in VC either "Invalid operation for device '0' " or "Invalid configuration for device '0' ".
Thanks for help.+
+Irene
+
Hi,
Maybe you could a simple clone operation, reconfig the virtual machine and then call the "customize vm without clone" workflow.
Hi Cédric,
I don't see where I could configure a bigger hard disk. Could you specify your idea a bit more?
Thanks.
I think you can use the ReconfigVM_Task equivalent to reconfigure a VM.
I will try to see if I can come up with a workflow that allows you to do that.
Sia
Hi all,
I found a solution to my problem! Quite simple actually.
I used the line
deviceConfigSpec.fileOperation = VimVirtualDeviceConfigSpecFileOperation.replace;
because I thougt it is a file operation im doing here, but it is not needed. So I simply skiped this line and used only this:
deviceConfigSpec.operation = VimVirtualDeviceConfigSpecOperation.edit;
and voilà it worked.
Thanks for your suggestions,
Irene