private static int getMaxNodesPerControllerOfType(VirtualController controller) { int count = 0; if ( VirtualSCSIController.class.isInstance(controller) ) { // The actual device nodes of SCSI controller are 16 // but one of them is reserved for the controller itself // so this means that the maximum free nodes are 15. count = 16; } else if (VirtualIDEController.class.isInstance(controller)) { count = 2; } else { throw new RuntimeException("Unknown controller type - " + controller.getDeviceInfo().getLabel()); } return count; }
public int getIDEControllerKey(int ideUnitNumber) throws Exception { List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient(). getDynamicProperty(_mor, "config.hardware.device"); int requiredIdeController = ideUnitNumber / VmwareHelper.MAX_IDE_CONTROLLER_COUNT; int ideControllerCount = 0; if(devices != null && devices.size() > 0) { for(VirtualDevice device : devices) { if(device instanceof VirtualIDEController) { if (ideControllerCount == requiredIdeController) { return ((VirtualIDEController)device).getKey(); } ideControllerCount++; } } } assert(false); throw new Exception("IDE Controller Not Found"); }
public static VirtualIDEController getFirstIdeController(ArrayOfVirtualDevice devices) { for (VirtualDevice dev : devices.getVirtualDevice()) { if (dev instanceof VirtualIDEController) { return (VirtualIDEController) dev; } } throw new IllegalStateException("No IDE controller found"); }
static VirtualDevice getIDEController(VirtualMachine vm) throws Exception { VirtualDevice ideController = null; VirtualDevice [] defaultDevices = getDefaultDevices(vm); for (int i = 0; i < defaultDevices.length; i++) { if (defaultDevices[i] instanceof VirtualIDEController) { ideController = defaultDevices[i]; break; } } return ideController; }
private String getDeviceBusName(List<VirtualDevice> allDevices, VirtualDevice theDevice) throws Exception { for (VirtualDevice device : allDevices) { if (device.getKey() == theDevice.getControllerKey().intValue()) { if (device instanceof VirtualIDEController) { return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), theDevice.getUnitNumber()); } else if (device instanceof VirtualSCSIController) { return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), theDevice.getUnitNumber()); } else { throw new Exception("Device controller is not supported yet"); } } } throw new Exception("Unable to find device controller"); }
public int tryGetIDEDeviceControllerKey() throws Exception { List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); if (devices != null && devices.size() > 0) { for (VirtualDevice device : devices) { if (device instanceof VirtualIDEController) { return ((VirtualIDEController)device).getKey(); } } } return -1; }
public int getIDEDeviceControllerKey() throws Exception { List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); if (devices != null && devices.size() > 0) { for (VirtualDevice device : devices) { if (device instanceof VirtualIDEController) { return ((VirtualIDEController)device).getKey(); } } } assert (false); throw new Exception("IDE Controller Not Found"); }
public int getNumberOfIDEDevices() throws Exception { int ideDeviceCount = 0; List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient(). getDynamicProperty(_mor, "config.hardware.device"); if (devices != null && devices.size() > 0) { for (VirtualDevice device : devices) { if (device instanceof VirtualIDEController) { ideDeviceCount += ((VirtualIDEController)device).getDevice().size(); } } } return ideDeviceCount; }
public static String getDeviceBusName(List<VirtualDevice> allDevices, VirtualDisk disk) throws Exception { for (VirtualDevice device : allDevices) { if (device.getKey() == disk.getControllerKey()) { if (device instanceof VirtualIDEController) { return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), disk.getUnitNumber()); } else if (device instanceof VirtualSCSIController) { return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), disk.getUnitNumber()); } else { throw new Exception("The device controller is not supported."); } } } throw new Exception("The device controller could not be located."); }