public Guid getDeviceId() { return id.getDeviceId(); }
public HotUnplugMemoryParameters(VmDeviceId vmDeviceId) { super(vmDeviceId.getVmId()); this.deviceId = vmDeviceId.getDeviceId(); }
public Guid getDiskId() { return getId().getDeviceId(); }
private static List<VmDevice> sortInterfacesByName(List<VmDevice> pluggedInterfaces, List<VmNetworkInterface> interfaces) { if (pluggedInterfaces.size() < 2) { return pluggedInterfaces; } final Map<Guid, String> deviceIdToIfaceName = new HashMap<>(); for (VmNetworkInterface iface : interfaces) { deviceIdToIfaceName.put(iface.getId(), iface.getName()); } Collections.sort(pluggedInterfaces, Comparator.comparing(d -> deviceIdToIfaceName.get(d.getId().getDeviceId()))); return pluggedInterfaces; }
@Override public int compareTo(VmDeviceId other) { int vmComparsion = getVmId().compareTo(other.getVmId()); if (vmComparsion == 0) { return getDeviceId().compareTo(other.getDeviceId()); } else { return vmComparsion; } } }
@Override protected MapSqlParameterSource createIdParameterMapper(VmDeviceId id) { return getCustomMapSqlParameterSource() .addValue("disk_id", id.getDeviceId()) .addValue("vm_id", id.getVmId()); }
@Override protected MapSqlParameterSource createIdParameterMapper(VmDeviceId id) { return getCustomMapSqlParameterSource() .addValue("device_id", id.getDeviceId()) .addValue("vm_id", id.getVmId()); }
@Override public DiskVmElement resolve(VmDeviceId id) throws BackendFailureException { VmDeviceId vmDeviceId = new VmDeviceId(diskId, vmId); return getEntity( DiskVmElement.class, QueryType.GetDiskVmElementById, new VmDeviceIdQueryParameters(vmDeviceId), vmDeviceId.getDeviceId().toString(), true ); } }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("deviceId", getDeviceId()) .append("vmId", getVmId()) .build(); }
public static DiskVmElement copyOf(DiskVmElement diskVmElement) { DiskVmElement newDve = new DiskVmElement(diskVmElement.getId().getDeviceId(), diskVmElement.getId().getVmId()); copyProperties(diskVmElement, newDve); return newDve; }
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 } } }
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 writeMonitors() { Collection<VmDevice> devices = vmBase.getManagedDeviceMap().values(); int numOfMonitors = vmBase.getNumOfMonitors(); int i = 0; for (VmDevice vmDevice : devices) { if (vmDevice.getType() == VmDeviceGeneralType.VIDEO) { _writer.writeStartElement("Item"); _writer.writeElement(RASD_URI, "Caption", "Graphical Controller"); _writer.writeElement(RASD_URI, "InstanceId", vmDevice.getId().getDeviceId().toString()); _writer.writeElement(RASD_URI, "ResourceType", adjustHardwareResourceType(OvfHardware.Monitor)); // we should write number of monitors for each entry for backward compatibility _writer.writeElement(RASD_URI, "VirtualQuantity", String.valueOf(numOfMonitors)); _writer.writeElement(RASD_URI, "SinglePciQxl", String.valueOf(vmBase.getSingleQxlPci())); writeVmDeviceInfo(vmDevice); _writer.writeEndElement(); // item if (i++ == numOfMonitors) { break; } } } }
/** * Test clearing a device address */ @Test public void clearDeviceAddress() { // before: check we have a device with a non-blank address VmDevice vmDevice = dao.get(getExistingEntityId()); assertTrue(StringUtils.isNotBlank(vmDevice.getAddress())); // clear the address and check its really cleared dao.clearDeviceAddress(getExistingEntityId().getDeviceId()); assertTrue(StringUtils.isBlank(dao.get(getExistingEntityId()).getAddress())); }