use of org.ovirt.engine.core.utils.ovf.xml.XmlAttribute in project ovirt-engine by oVirt.
the class VmDevicesConverter method parseDiskPath.
private String parseDiskPath(XmlNode node) {
XmlNode sourceNode = node.selectSingleNode("source");
if (sourceNode == null) {
return "";
}
XmlAttribute attr = sourceNode.attributes.get("file");
if (attr != null) {
return attr.getValue();
}
attr = sourceNode.attributes.get("dev");
if (attr != null) {
return attr.getValue();
}
attr = sourceNode.attributes.get("name");
if (attr != null) {
return attr.getValue();
}
return "";
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlAttribute in project ovirt-engine by oVirt.
the class VmDevicesConverter method parseHostAddress.
private Map<String, String> parseHostAddress(XmlNode node) {
XmlNode sourceNode = node.selectSingleNode("source");
if (sourceNode == null) {
return null;
}
XmlNode addressNode = sourceNode.selectSingleNode("address");
if (addressNode == null) {
return null;
}
Map<String, String> address = new HashMap<>();
Arrays.asList("domain", "slot", "bus", "function", "device", "host", "target", "lun").forEach(key -> {
XmlAttribute attribute = addressNode.attributes.get(key);
if (attribute != null) {
String valStr = attribute.getValue();
boolean hex = valStr.startsWith("0x");
int val = Integer.parseInt(hex ? valStr.substring(2) : valStr, hex ? 16 : 10);
address.put(key, String.valueOf(val));
}
});
XmlAttribute uuidAttribute = addressNode.attributes.get("uuid");
if (uuidAttribute != null) {
address.put("uuid", uuidAttribute.getValue());
}
return address;
}
Aggregations