/** * is special device - device which is managed, but contains the general properties */ public static boolean isSpecialDevice(String device, VmDeviceGeneralType type) { if (VmDeviceType.USB.getName().equals(device)) { return true; } switch(type) { case SOUND: return true; case CONSOLE: return VmDeviceType.CONSOLE.getName().equals(device); case SMARTCARD: return VmDeviceType.SMARTCARD.getName().equals(device); case REDIR: return VmDeviceType.SPICEVMC.getName().equals(device); case BALLOON: return VmDeviceType.MEMBALLOON.getName().equals(device); case WATCHDOG: return VmDeviceType.WATCHDOG.getName().equals(device); case RNG: return VmDeviceType.VIRTIO.getName().equals(device); case CONTROLLER: return VmDeviceType.VIRTIOSERIAL.getName().equals(device) || VmDeviceType.VIRTIOSCSI.getName().equals(device); default: return false; } }
public VmDeviceType getDeviceType() { return VmDeviceType.getByName(super.getDevice()); }
selectSingleNode(node, VMD_VIRTUAL_QUANTITY, _xmlNS).innerText); if (virtualQuantity > 1) { vmDevice.setDevice(VmDeviceType.QXL.getName()); } else { if (!supportedGraphicsAndDisplays.isEmpty()) { DisplayType firstDisplayType = supportedGraphicsAndDisplays.get(0).getSecond(); vmDevice.setDevice(firstDisplayType.getDefaultVmDeviceType().getName()); } else { vmDevice.setDevice(VmDeviceType.QXL.getName()); vmDevice.setDevice(VmDeviceType.QXL.getName()); vmDevice.setDevice(VmDeviceType.getoVirtDevice(Integer.parseInt(resourceType)).getName()); vmDevice.setDevice(VmDeviceType.HOST_DEVICE.getName()); } else { vmDevice.setDevice(VmDeviceType.BRIDGE.getName());
public GraphicsDevice(VmDeviceType type) { setType(VmDeviceGeneralType.GRAPHICS); setDevice(type.name().toLowerCase()); setId(new VmDeviceId()); setAddress(""); setPlugged(true); setManaged(true); }
/** * This method maps OVF Resource Types to oVirt devices. */ public static VmDeviceType getoVirtDevice(int resourceType) { for (VmDeviceType deviceType : values()) { if (deviceType.ovfResourceType != null && Integer.parseInt(deviceType.ovfResourceType) == resourceType) { return deviceType; } } return UNKNOWN; }
} else { int resourceType = getResourceType(node, VMD_RESOURCE_TYPE); vmDevice.setType(VmDeviceGeneralType.forValue(VmDeviceType.getoVirtDevice(resourceType)));
@Test public void testVmPayloadMapToPaylod() { VmPayload vmPayload = new VmPayload(); vmPayload.setDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType.CDROM); vmPayload.setVolumeId("CD-VOL"); Payload payload = VmMapper.map(vmPayload, null); assertEquals(vmPayload.getDeviceType().name(), payload.getType().name()); assertEquals(vmPayload.getVolumeId(), payload.getVolumeId()); }
/** * Find a device in the map with the given type. */ public static VmDevice findVmDeviceByType(Map<?, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type.getName()); }
@Test public void testPayloadMapToVmPaylod() { Payload payload = new Payload(); payload.setType(VmDeviceType.CDROM); payload.setVolumeId("CD-VOL"); VmPayload vmPayload = VmMapper.map(payload, null); assertEquals(payload.getType().name(), vmPayload.getDeviceType().name()); assertEquals(payload.getVolumeId(), vmPayload.getVolumeId()); }
@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 isCD(VmDevice device) { return device.getType() == VmDeviceGeneralType.DISK && device.getDevice().equals(VmDeviceType.CDROM.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 isMemory(VmDevice device) { return VmDeviceGeneralType.MEMORY == device.getType() && VmDeviceType.MEMORY.getName().equals(device.getDevice()); }
type = forValue(value.getName()); break;