use of com.vmware.vim25.VirtualMachineConfigSpec in project cloudstack by apache.
the class VirtualMachineMO method ensureScsiDeviceControllers.
public void ensureScsiDeviceControllers(int count, int availableBusNum) throws Exception {
int scsiControllerKey = getScsiDeviceControllerKeyNoException();
if (scsiControllerKey < 0) {
VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
int busNum = availableBusNum;
while (busNum < count) {
VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
scsiController.setBusNumber(busNum);
scsiController.setKey(busNum - VmwareHelper.MAX_SCSI_CONTROLLER_COUNT);
VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
scsiControllerSpec.setDevice(scsiController);
scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
vmConfig.getDeviceChange().add(scsiControllerSpec);
busNum++;
}
if (configureVm(vmConfig)) {
throw new Exception("Unable to add Scsi controllers to the VM " + getName());
} else {
s_logger.info("Successfully added " + count + " SCSI controllers.");
}
}
}
Aggregations