public static boolean isNetwork(VmDevice device) { return device.getType() == VmDeviceGeneralType.INTERFACE; }
public static boolean isSound(VmDevice device) { return device.getType() == VmDeviceGeneralType.SOUND; }
public static boolean isGraphics(VmDevice device) { return device.getType() == VmDeviceGeneralType.GRAPHICS; }
public static boolean isHotUnpluggable(VmDevice vmDevice) { return vmDevice.getType() == VmDeviceGeneralType.MEMORY; }
public static boolean isMemoryBalloon(VmDevice device) { return device.getType() == VmDeviceGeneralType.BALLOON; }
/** * Find a device in the map with the given general type. */ public static VmDevice findVmDeviceByGeneralType(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceGeneralType generalType) { for (VmDevice vmDevice : vmManagedDeviceMap.values()) { if (vmDevice.getType() == generalType) { return vmDevice; } } return null; }
private boolean isVMDeviceTypeExist(Map<Guid, VmDevice> deviceMap, VmDeviceGeneralType deviceType) { return deviceMap != null && deviceMap.values().stream().anyMatch(d -> d.getType().equals(deviceType)); }
public static boolean isMemory(VmDevice device) { return VmDeviceGeneralType.MEMORY == device.getType() && VmDeviceType.MEMORY.getName().equals(device.getDevice()); }
public static boolean isVirtIoScsiDeviceExists(Collection<VmDevice> devices) { for (VmDevice device : devices) { if (device.getType() == VmDeviceGeneralType.CONTROLLER && device.getDevice().equals(VmDeviceType.VIRTIOSCSI.getName())) { return true; } } return false; }
public static boolean isBridge(VmDevice device) { return device.getType() == VmDeviceGeneralType.INTERFACE && device.getDevice().equals(VmDeviceType.BRIDGE.getName()); }
public static boolean isHostDevInterface(VmDevice device) { return device.getType() == VmDeviceGeneralType.INTERFACE && device.getDevice().equals(VmDeviceType.HOST_DEVICE.getName()); }
public static boolean isDisk(VmDevice device) { return device.getType() == VmDeviceGeneralType.DISK && device.getDevice().equals(VmDeviceType.DISK.getName()); }
public static boolean isCD(VmDevice device) { return device.getType() == VmDeviceGeneralType.DISK && device.getDevice().equals(VmDeviceType.CDROM.getName()); }
/** * 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); }
public void makeSortable() { makeSortable(Comparator.comparing((T o) -> getDeviceFromObject(o) != null) .thenComparing(o -> getDeviceFromObject(o).getType().getValue(), new LexoNumericComparator())); }
@SuppressWarnings("unchecked") public VmPayload(VmDevice dev) { super(dev.getId(), dev.getType(), dev.getDevice(), dev.getAddress(), dev.getSpecParams(), dev.isManaged(), dev.isPlugged(), dev.getReadOnly(), dev.getAlias(), dev.getCustomProperties(), dev.getSnapshotId(), dev.getLogicalName()); if (dev.getSpecParams() != null) { Map<String, Object> payload = (Map<String, Object>)dev.getSpecParams().get(SpecParamsPayload); this.volumeId = (String)payload.get(SpecParamsVolumeIdType); this.files = (HashMap<String, String>)payload.get(SpecParamsFileType); } }
private void writeOtherDevices() { List<VmDevice> devices = vmBase.getUnmanagedDeviceList(); Collection<VmDevice> managedDevices = vmBase.getManagedDeviceMap().values(); for (VmDevice device : managedDevices) { if (VmDeviceCommonUtils.isSpecialDevice(device.getDevice(), device.getType())) { devices.add(device); } } for (VmDevice vmDevice : devices) { _writer.writeStartElement("Item"); _writer.writeElement(RASD_URI, "ResourceType", OvfHardware.OTHER); _writer.writeElement(RASD_URI, "InstanceId", vmDevice.getId().getDeviceId().toString()); writeVmDeviceInfo(vmDevice); _writer.writeEndElement(); // item } }
private void writeGraphics() { Collection<VmDevice> devices = vmBase.getManagedDeviceMap().values(); for (VmDevice vmDevice : devices) { if (vmDevice.getType() == VmDeviceGeneralType.GRAPHICS) { _writer.writeStartElement("Item"); _writer.writeElement(RASD_URI, "Caption", "Graphical Framebuffer"); _writer.writeElement(RASD_URI, "InstanceId", vmDevice.getId().getDeviceId().toString()); _writer.writeElement(RASD_URI, "ResourceType", adjustHardwareResourceType(OvfHardware.Graphics)); writeVmDeviceInfo(vmDevice); _writer.writeEndElement(); // item } } }
private void onMemoryHotUnplugConfirmed() { setConfirmWindow(null); final VmDeviceFeEntity deviceEntity = getSelectedItem(); if (deviceEntity == null || deviceEntity.getVmDevice().getType() != VmDeviceGeneralType.MEMORY) { return; } idsOfDevicesBeingUnplugged.add(deviceEntity.getVmDevice().getId(), removedItem -> updateItems()); updateItems(); Frontend.getInstance().runAction( ActionType.HotUnplugMemory, new HotUnplugMemoryParameters(deviceEntity.getVmDevice().getId()), true); }
@Override protected MapSqlParameterSource createFullParametersMapper(VmDevice entity) { return createIdParameterMapper(entity.getId()) .addValue("device", entity.getDevice()) .addValue("type", entity.getType().getValue()) .addValue("address", entity.getAddress()) .addValue("spec_params", SerializationFactory.getSerializer().serialize(entity.getSpecParams())) .addValue("is_managed", entity.isManaged()) .addValue("is_plugged", entity.isPlugged()) .addValue("is_readonly", entity.getReadOnly()) .addValue("alias", entity.getAlias()) .addValue("custom_properties", SerializationFactory.getSerializer().serialize(entity.getCustomProperties())) .addValue("snapshot_id", entity.getSnapshotId()) .addValue("logical_name", entity.getLogicalName()) .addValue("host_device", entity.getHostDevice()); }