/** * Check if device with the general type given exists in the map. */ public static boolean isVmDeviceExists(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceGeneralType generalType) { return findVmDeviceByGeneralType(vmManagedDeviceMap, generalType) != null; }
/** * Libvirt doesn't specify what values of xml snippet it actually uses to identify memory device to hot unplug. Thus * all values need to be provided to build complete xml representation of memory device. */ public static boolean isMemoryDeviceHotUnpluggable(VmDevice memoryDevice) { if (!isMemory(memoryDevice)) { throw new IllegalArgumentException("Memory device expected but device " + memoryDevice + " obtained."); } return getSpecParamsIntValue(memoryDevice, SPEC_PARAM_SIZE).isPresent() && getSpecParamsIntValue(memoryDevice, SPEC_PARAM_NODE).isPresent(); } }
/** * Check if device with the type given exists in the map. */ public static boolean isVmDeviceExists(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type) != null; }
/** * updates network devices boot order */ private static int setNetworkBootOrder(Collection<VmDevice> devices, int bootOrder, List<VmNetworkInterface> interfaces) { for (VmDevice pluggedInterface : sortInterfacesByName(getPluggedManagedInterfaces(devices), interfaces)) { pluggedInterface.setBootOrder(++bootOrder); } return bootOrder; }
private static List<VmDevice> getPluggedManagedInterfaces(Collection<VmDevice> devices) { List<VmDevice> result = new ArrayList<>(); for (VmDevice device : devices) { if ((isHostDevInterface(device) || isBridge(device)) && device.isPlugged() && device.isManaged()) { result.add(device); } } return result; }
private boolean specParamsMissing(VmDevice vmDevice) { return !VmDeviceCommonUtils.getSpecParamsIntValue(vmDevice, VmDeviceCommonUtils.SPEC_PARAM_SIZE).isPresent() || !VmDeviceCommonUtils.getSpecParamsIntValue(vmDevice, VmDeviceCommonUtils.SPEC_PARAM_NODE).isPresent(); }
public static boolean isInWhiteList(VmDeviceGeneralType type, String device) { String expr = getDeviceTypeSearchExpr(type, device); String whiteList = Config.getValue(ConfigValues.ManagedDevicesWhiteList); return whiteList.indexOf(expr) >= 0; }
/** * updates CD boot order */ private static int setCDBootOrder(Collection<VmDevice> devices, int bootOrder) { for (VmDevice device : devices) { if (isCD(device) && device.isPlugged()) { device.setBootOrder(++bootOrder); } } return bootOrder; }
public void onHotUnplug(VmDeviceFeEntity deviceEntity) { if (getEntity() == null) { return; } if (deviceEntity == null || deviceEntity.getVmDevice().getType() != VmDeviceGeneralType.MEMORY) { return; } final Optional<Integer> memorySizeOptional = VmDeviceCommonUtils.getSizeOfMemoryDeviceMb(deviceEntity.getVmDevice()); if (!memorySizeOptional.isPresent()) { return; } final int memorySizeMb = memorySizeOptional.get(); setSelectedItem(deviceEntity); ConfirmationModel confirmationModel = new ConfirmationModel(); confirmationModel.setTitle(constants.memoryHotUnplug()); confirmationModel.setHelpTag(HelpTag.template_not_found_on_export_domain); confirmationModel.setMessage(messages.memoryHotUnplugConfirmation(memorySizeMb, getEntity().getName())); confirmationModel.getCommands().add(memoryHotUnplugCommand); confirmationModel.getCommands().add(cancelMemoryHotUnplugCommand); setConfirmWindow(confirmationModel); }
addManagedVmDevice(VmDeviceCommonUtils.createVirtioSerialDeviceForVm(vmBase.getId()));
} else { deactivate(); VmDevice rngDevice = VmDeviceCommonUtils.findVmDeviceByGeneralType( vmBase.getManagedDeviceMap(), VmDeviceGeneralType.RNG); getModel().getIsRngEnabled().setEntity(rngDevice != null);
/** * Spec param "size" may not always be present. See BZ#1452631. * * @return size of memory device in MB */ public static Optional<Integer> getSizeOfMemoryDeviceMb(VmDevice memoryDevice) { if (!isMemory(memoryDevice)) { throw new RuntimeException("Memory device expected but device " + memoryDevice + " passed of type " + memoryDevice.getType()); } return getSpecParamsIntValue(memoryDevice, SPEC_PARAM_SIZE); }
/** * Find a device in the map with the given type. */ public static VmDevice findVmDeviceByType(Map<?, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type.getName()); }
private void addDefaultGraphicsDevice() { VmDevice device = VmDeviceCommonUtils.findVmDeviceByGeneralType( vmBase.getManagedDeviceMap(), VmDeviceGeneralType.GRAPHICS); if (device != null) {