use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class HotPlugDiskToVmCommandTest method mockVmDevice.
protected void mockVmDevice(boolean plugged) {
vmDevice = new VmDevice();
vmDevice.setId(new VmDeviceId());
vmDevice.setPlugged(plugged);
when(vmDeviceDao.get(any())).thenReturn(vmDevice);
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class OvfReader method readUnmanagedVmDevice.
protected VmDevice readUnmanagedVmDevice(XmlNode node, Guid deviceId) {
VmDevice vmDevice = readVmDevice(node, deviceId);
vmBase.getUnmanagedDeviceList().add(vmDevice);
return vmDevice;
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class OvfReader method readHardwareSection.
protected void readHardwareSection(XmlNode section) {
boolean readVirtioSerial = false;
int nicIdx = 0;
for (XmlNode item : selectNodes(section, "Item")) {
String resourceType = selectSingleNode(item, "rasd:ResourceType", _xmlNS).innerText;
resourceType = adjustHardwareResourceType(resourceType);
switch(resourceType) {
case OvfHardware.CPU:
readCpuItem(item);
break;
case OvfHardware.Memory:
readMemoryItem(item);
break;
case OvfHardware.DiskImage:
readDiskImageItem(item);
break;
case OvfHardware.Network:
/**
* If NIC items are found in the hardware section of the OVF, they are the real ones,
* so clear the NIC references found in the <NetworkSection> of the OVF which are used
* only to map networks, but should not be used to create NICs. Clear() is performed only
* upon finding the first NIC item.
*/
if (nicIdx == 0) {
interfaces.clear();
}
readNetworkItem(item, ++nicIdx);
break;
case OvfHardware.USB:
readUsbItem(item);
break;
case OvfHardware.Monitor:
readMonitorItem(item);
break;
case OvfHardware.Graphics:
// so far graphics doesn't contain anything special
readManagedVmDevice(item, Guid.newGuid());
break;
case OvfHardware.CD:
readCdItem(item);
break;
case OvfHardware.OTHER:
VmDevice vmDevice = readOtherHardwareItem(item);
readVirtioSerial = readVirtioSerial || VmDeviceType.VIRTIOSERIAL.getName().equals(vmDevice.getDevice());
break;
}
}
if (!readVirtioSerial) {
addManagedVmDevice(VmDeviceCommonUtils.createVirtioSerialDeviceForVm(vmBase.getId()));
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class OvfReader method readVmDevice.
/**
* Reads vm device attributes from OVF and stores it in the collection
*/
private VmDevice readVmDevice(XmlNode node, Guid deviceId) {
VmDevice vmDevice = new VmDevice();
vmDevice.setId(new VmDeviceId(deviceId, vmBase.getId()));
if (selectSingleNode(node, VMD_ADDRESS, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_ADDRESS, _xmlNS).innerText)) {
vmDevice.setAddress(String.valueOf(selectSingleNode(node, VMD_ADDRESS, _xmlNS).innerText));
} else {
vmDevice.setAddress("");
}
if (selectSingleNode(node, VMD_ALIAS, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_ALIAS, _xmlNS).innerText)) {
vmDevice.setAlias(String.valueOf(selectSingleNode(node, VMD_ALIAS, _xmlNS).innerText));
} else {
vmDevice.setAlias("");
}
XmlNode specParamsNode = selectSingleNode(node, VMD_SPEC_PARAMS, _xmlNS);
if (specParamsNode != null && !StringUtils.isEmpty(specParamsNode.innerText)) {
vmDevice.setSpecParams(getMapNode(specParamsNode));
} else {
// Empty map
vmDevice.setSpecParams(Collections.emptyMap());
}
if (selectSingleNode(node, VMD_TYPE, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_TYPE, _xmlNS).innerText)) {
vmDevice.setType(VmDeviceGeneralType.forValue(String.valueOf(selectSingleNode(node, VMD_TYPE, _xmlNS).innerText)));
} else {
int resourceType = getResourceType(node, VMD_RESOURCE_TYPE);
vmDevice.setType(VmDeviceGeneralType.forValue(VmDeviceType.getoVirtDevice(resourceType)));
}
if (selectSingleNode(node, VMD_DEVICE, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_DEVICE, _xmlNS).innerText)) {
vmDevice.setDevice(String.valueOf(selectSingleNode(node, VMD_DEVICE, _xmlNS).innerText));
} else {
setDeviceByResource(node, vmDevice);
}
if (selectSingleNode(node, VMD_IS_PLUGGED, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_IS_PLUGGED, _xmlNS).innerText)) {
vmDevice.setPlugged(Boolean.valueOf(selectSingleNode(node, VMD_IS_PLUGGED, _xmlNS).innerText));
} else {
vmDevice.setPlugged(Boolean.TRUE);
}
if (selectSingleNode(node, VMD_IS_READONLY, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_IS_READONLY, _xmlNS).innerText)) {
vmDevice.setReadOnly(Boolean.valueOf(selectSingleNode(node, VMD_IS_READONLY, _xmlNS).innerText));
} else {
vmDevice.setReadOnly(Boolean.FALSE);
}
if (selectSingleNode(node, VMD_CUSTOM_PROP, _xmlNS) != null && StringUtils.isNotEmpty(selectSingleNode(node, VMD_CUSTOM_PROP, _xmlNS).innerText)) {
vmDevice.setCustomProperties(DevicePropertiesUtils.getInstance().convertProperties(String.valueOf(selectSingleNode(node, VMD_CUSTOM_PROP, _xmlNS).innerText)));
} else {
vmDevice.setCustomProperties(null);
}
if (selectSingleNode(node, VMD_SNAPSHOT_PROP, _xmlNS) != null && StringUtils.isNotEmpty(selectSingleNode(node, VMD_SNAPSHOT_PROP, _xmlNS).innerText)) {
vmDevice.setSnapshotId(new Guid(String.valueOf(selectSingleNode(node, VMD_CUSTOM_PROP, _xmlNS).innerText)));
}
return vmDevice;
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class OvfWriter method writeGraphics.
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);
// item
_writer.writeEndElement();
}
}
}
Aggregations