HI All
I am getting same error while add rdm to vm.
Same eror : Invalid Operation for device '0'
I didn't set the controller key,unitnumber and key in virtualdevice object.
Where i find those info in mob.
VirtualDiskRawDiskMappingVer1BackingInfo rdm = new VirtualDiskRawDiskMappingVer1BackingInfo();
rdm.setLunUuid(scsiDisk.get(0).getUuid());
rdm.setFileName("[RDM]");
rdm.setDiskMode("independent_persistent");
rdm.setDeviceName(scsiDisk.get(0).getDeviceName());
rdm.setDatastore(ds);
rdm.setCompatibilityMode(VirtualDiskCompatibilityMode._physicalMode);
VirtualDeviceConnectInfo vdcinfo = new VirtualDeviceConnectInfo();
vdcinfo.setAllowGuestControl(false);
vdcinfo.setStartConnected(true);
vdcinfo.setConnected(true);
VirtualDevice vd = new VirtualDevice();
vd.setBacking(rdm);
vd.setConnectable(vdcinfo);
VirtualDeviceConfigSpec vdConfSpec = new VirtualDeviceConfigSpec();
vdConfSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
vdConfSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.create);
vdConfSpec.setDevice(vd);
VirtualMachineConfigSpec vmConf = new VirtualMachineConfigSpec();
vmConf.setDeviceChange(new VirtualDeviceConfigSpec[]{vdConfSpec});
VExecutor.getInstance().getServiceInstance().reconfigVM_Task(vm, vmConf);