/** * gets device type for a given device name */ public static VmDeviceType getByName(String name) { for (VmDeviceType vmDeviceType : values()) { if (name.equals(vmDeviceType.getName())) { return vmDeviceType; } } return null; }
/** * gets sound device type for a given device name */ public static VmDeviceType getSoundDeviceType(String name) { for (VmDeviceType deviceType : values()) { if (deviceType.getName().equals(name)) { return deviceType; } } return VmDeviceType.ICH6; }
/** * Find a device in the map with the given type. */ public static VmDevice findVmDeviceByType(Map<?, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type.getName()); }
@Override public List<VmDevice> getVmDeviceByVmIdTypeAndDevice(Guid vmBaseId, VmDeviceGeneralType type, VmDeviceType device) { return getVmDeviceByVmIdTypeAndDevice(vmBaseId, type, device.getName()); }
public void setDeviceType(VmDeviceType type) { super.setDevice(type.getName()); }
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 isDisk(VmDevice device) { return device.getType() == VmDeviceGeneralType.DISK && device.getDevice().equals(VmDeviceType.DISK.getName()); }
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 isCD(VmDevice device) { return device.getType() == VmDeviceGeneralType.DISK && device.getDevice().equals(VmDeviceType.CDROM.getName()); }
public static boolean isMemory(VmDevice device) { return VmDeviceGeneralType.MEMORY == device.getType() && VmDeviceType.MEMORY.getName().equals(device.getDevice()); }
public static VmDevice createVirtioSerialDeviceForVm(Guid vmId) { return new VmDevice(new VmDeviceId(Guid.newGuid(), vmId), VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSERIAL.getName(), "", new HashMap<String, Object>(), true, true, false, "", null, null, null); }
@Test public void testIsBalloonEnabled() { boolean queryRes = dao.isMemBalloonEnabled(EXISTING_VM_ID); List<VmDevice> devices = dao.getVmDeviceByVmIdTypeAndDevice(EXISTING_VM_ID, VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON.getName()); assertTrue((queryRes && !devices.isEmpty()) || (!queryRes && devices.isEmpty())); }
private void writeCd() { Collection<VmDevice> devices = vmBase.getManagedDeviceMap().values(); for (VmDevice vmDevice : devices) { if (vmDevice.getDevice().equals(VmDeviceType.CDROM.getName())) { _writer.writeStartElement("Item"); _writer.writeElement(RASD_URI, "Caption", "CDROM"); _writer.writeElement(RASD_URI, "InstanceId", vmDevice.getId().getDeviceId().toString()); _writer.writeElement(RASD_URI, "ResourceType", OvfHardware.CD); writeVmDeviceInfo(vmDevice); _writer.writeEndElement(); // item break; // only one CD is currently supported } } }
public VmRngDevice(VmDeviceId id, Map<String, Object> specPars) { super(); setId(id); setDevice(VmDeviceType.VIRTIO.getName()); setType(VmDeviceGeneralType.RNG); setAddress(""); setPlugged(true); setManaged(true); setSpecParams(specPars); }
public static void addVirtIoScsiDevice(VmBase vmBase) { VmDevice vmDevice = new VmDevice(); vmDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); vmDevice.setType(VmDeviceGeneralType.CONTROLLER); vmDevice.setDevice(VmDeviceType.VIRTIOSCSI.getName()); vmDevice.setManaged(true); vmDevice.setPlugged(true); vmDevice.setReadOnly(false); vmDevice.setAddress(""); vmBase.getManagedDeviceMap().put(vmDevice.getDeviceId(), vmDevice); }
public static void addCdDevice(VmBase vmBase) { VmDevice vmDevice = new VmDevice(); vmDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); vmDevice.setType(VmDeviceGeneralType.DISK); vmDevice.setDevice(VmDeviceType.CDROM.getName()); vmDevice.setManaged(true); vmDevice.setPlugged(true); vmDevice.setReadOnly(true); vmDevice.setAddress(""); vmBase.getManagedDeviceMap().put(vmDevice.getDeviceId(), vmDevice); }
private VmDevice createNetworkInterfaceDevice(boolean plugged, Guid id) { VmDevice device = new VmDevice(); device.setType(VmDeviceGeneralType.INTERFACE); device.setDevice(VmDeviceType.BRIDGE.getName()); device.setPlugged(plugged); device.setId(new VmDeviceId(id, null)); return device; }
private VmDevice createCdRomDevice() { Guid id = Guid.newGuid(); VmDevice device = new VmDevice(); device.setType(VmDeviceGeneralType.DISK); device.setDevice(VmDeviceType.CDROM.getName()); device.setPlugged(true); device.setId(new VmDeviceId(id, null)); return device; } }
private VmDevice createDiskDevice(boolean boot, Map<VmDeviceId, DiskVmElement> idToDiskElement) { Guid id = Guid.newGuid(); VmDevice device = new VmDevice(); device.setType(VmDeviceGeneralType.DISK); device.setDevice(VmDeviceType.DISK.getName()); device.setId(new VmDeviceId(id, null)); DiskVmElement dve = new DiskVmElement(new VmDeviceId(id, null)); dve.setBoot(boot); idToDiskElement.put(dve.getId(), dve); return device; }