I'm trying to create a new VMDK on a datastore attached to an ESX host. When I try to use the createVirtualDisk_Task method of my VirtualDiskManager, the task returns a result of "error", and the Recent Tasks pane of my vSphere Client connected to my vCenter Server shows the "Create virtual disk" task with a status of "The requested operation is not implemented by the server."
Here is a sample of my code, for comparison.
VirtualDiskSpec spec = new VirtualDiskSpec();spec.setDiskType(VirtualDiskType.thin.toString());spec.setAdapterType(VirtualDiskAdapterType.busLogic.toString());VirtualDiskManager diskManager = myServiceInstance.getVirtualDiskManager();Task task = diskManager.createVirtualDisk_Task(name, datacenter, spec);String result = task.waitForTask(); //result == "error"
Browsing the VDDK documentation, it can clearly accomplish the task of creating a VMDK. Additionally, the VI Java SDK docs for this method blithely state that the method is "Experimental. Subject to change."
So, does this particular facet of the VI SDK (invoked via VIJava) just not work? Is the VDDK, and statically compiled (oh no!) C code my only hope?
Hi,
createVirtualDisk operation will support while using ESX server logins instead of vcenter login. I think this may help u.
Hi,
How to specify the size of the vmdk file while creating the disk?
Looks like the parameters/specs doesnt take the capacity.
Regards,
Naresh
Hi,
Below code may help you:
VirtualDisk newDisk = new VirtualDisk();
newDisk.setControllerKey(controllerKey);
newDisk.setKey(Integer.parseInt("-13"));
newDisk.setUnitNumber(Integer.parseInt("13"));
newDisk.setCapacityInKB(dSize);
deviceConfigSpec.setDevice(newDisk);
deviceConfigSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.fromString("create"));
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.fromString("add"));
deviceConfigSpecArray[0] = deviceConfigSpec;
reConfigSpec.setDeviceChange(deviceConfigSpecArray);
ManagedObjectReference task =
ecb.getServiceConnection3().getService().reconfigVM_Task(vmMor,reConfigSpec);
Thanks,
Vijaya