I wrote a java code with vijava to create a VM.
But vCenter throws error "The operation is not supported on the object."
How do I know which I make mistake which part? This error message says nothing.
I wrote following codes:
si = new ServiceInstance( new URL("https://16.147.137.28/sdk"), "Administrator", "Passw0rd", true); Folder rootFolder = si.getRootFolder(); InventoryNavigator rootNavi = new InventoryNavigator(rootFolder); VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec(); vmConfig.setName("test"); vmConfig.setMemoryMB(500l); vmConfig.setNumCPUs(4); VirtualMachineFileInfo vmfi = new VirtualMachineFileInfo(); vmfi.setVmPathName("[datastore1]"); vmConfig.setFiles(vmfi); VirtualDeviceConfigSpec vDiskConfigSpec = new VirtualDeviceConfigSpec(); vDiskConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.add); vDiskConfigSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.create); VirtualDisk vDisk = new VirtualDisk(); vDisk.setCapacityInKB(1024 * 1024 * 16); vDisk.setKey(0); int ctrlKey = 0; vDisk.setControllerKey(ctrlKey); vDiskConfigSpec.setDevice(vDisk); VirtualDiskFlatVer2BackingInfo vDiskFileBackInfo = new VirtualDiskFlatVer2BackingInfo(); vDiskFileBackInfo.setThinProvisioned(true); vDiskFileBackInfo.setFileName("[datastore1]"); VirtualSCSIController vScsiCtrl = new VirtualLsiLogicController(); vScsiCtrl.setBusNumber(0); vDisk.setUnitNumber(0); vScsiCtrl.setKey(ctrlKey); vScsiCtrl.setSharedBus(VirtualSCSISharing.noSharing); vDiskFileBackInfo.setDiskMode(VirtualDiskMode.persistent.toString()); vDisk.setBacking(vDiskFileBackInfo); VirtualDeviceConfigSpec vScsiConfigSpec = new VirtualDeviceConfigSpec(); vScsiConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.add); vScsiConfigSpec.setDevice(vScsiCtrl); VirtualDeviceConfigSpec[] vDeviceConfigSpecs = new VirtualDeviceConfigSpec[]{ vDiskConfigSpec ,vScsiConfigSpec}; vmConfig.setDeviceChange(vDeviceConfigSpecs); ResourcePool pool = (ResourcePool)rootNavi.searchManagedEntity("ResourcePool", "resource1"); Task task = pool.createChildVM_Task(vmConfig, null); System.out.println(task.waitForTask());