Search in sources :

Example 1 with XmlNamespaceManager

use of org.ovirt.engine.core.utils.ovf.xml.XmlNamespaceManager in project ovirt-engine by oVirt.

the class VmDevicesConverter method parseDiskMapping.

@SuppressWarnings("unchecked")
private Map<String, Object> parseDiskMapping(XmlNode metadata) throws Exception {
    if (metadata == null) {
        return null;
    }
    XmlNamespaceManager xmlNS = new XmlNamespaceManager();
    xmlNS.addNamespace(LibvirtVmXmlBuilder.OVIRT_VM_PREFIX, LibvirtVmXmlBuilder.OVIRT_VM_URI);
    XmlNode vm = metadata.selectSingleNode("ovirt-vm:vm", xmlNS);
    if (vm == null) {
        return null;
    }
    Map<String, Object> result = new HashMap<>();
    for (XmlNode node : vm.selectNodes("ovirt-vm:device", xmlNS)) {
        if (!VmDeviceGeneralType.DISK.getValue().equals(parseAttribute(node, "devtype"))) {
            continue;
        }
        XmlNode guestNameNode = node.selectSingleNode("ovirt-vm:guestName", xmlNS);
        if (guestNameNode != null) {
            // guest disk mapping is not available for LUNs at the moment
            result.put(node.selectSingleNode("ovirt-vm:imageID", xmlNS).innerText, Collections.singletonMap(VdsProperties.Name, guestNameNode.innerText));
        }
    }
    return result;
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNamespaceManager(org.ovirt.engine.core.utils.ovf.xml.XmlNamespaceManager) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 XmlNamespaceManager (org.ovirt.engine.core.utils.ovf.xml.XmlNamespaceManager)1 XmlNode (org.ovirt.engine.core.utils.ovf.xml.XmlNode)1