Search in sources :

Example 26 with XmlNode

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

the class OvfUtils method getOsSection.

private ArchitectureType getOsSection(XmlDocument xmlDocument) {
    ArchitectureType archType = null;
    XmlNode content = xmlDocument.selectSingleNode("//*/Content");
    XmlNodeList nodeList = content.selectNodes("Section");
    XmlNode selectedSection = null;
    if (nodeList != null) {
        for (XmlNode section : nodeList) {
            String value = section.attributes.get("xsi:type").getValue();
            if (value.equals("ovf:OperatingSystemSection_Type")) {
                selectedSection = section;
                break;
            }
        }
        if (selectedSection != null) {
            int osId = osRepository.getOsIdByUniqueName(selectedSection.innerText);
            archType = osRepository.getArchitectureFromOS(osId);
        }
    }
    return archType;
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 27 with XmlNode

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

the class OvfOvaReader method readDiskImageItem.

protected void readDiskImageItem(XmlNode node) {
    XmlNode hostResourceNode = selectSingleNode(node, "rasd:HostResource", _xmlNS);
    String hostResourceText = hostResourceNode.innerText;
    String diskId = hostResourceText.substring(hostResourceText.lastIndexOf('/') + 1);
    DiskImage image = _images.stream().filter(d -> d.getDescription().equals(diskId)).findFirst().orElse(null);
    if (image == null) {
        return;
    }
    super.readDiskImageItem(node, image);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 28 with XmlNode

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

the class OvfOvaReader method buildDisk.

@Override
public void buildDisk() {
    XmlNode diskSection = selectSingleNode(_document, "//*/DiskSection");
    XmlNodeList list = diskSection.selectNodes("Disk");
    for (XmlNode node : list) {
        readDisk(node, null);
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 29 with XmlNode

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

the class OvfOvaReader method updateSingleNic.

@Override
protected void updateSingleNic(XmlNode node, VmNetworkInterface iface, int nicIdx) {
    super.updateSingleNic(node, iface, nicIdx);
    XmlNode macNode = selectSingleNode(node, "rasd:MACAddress", _xmlNS);
    iface.setMacAddress(macNode != null ? macNode.innerText : "");
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode)

Example 30 with XmlNode

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

the class OvfOvirtReader method readUserDomainsSection.

protected void readUserDomainsSection(@SuppressWarnings("unused") XmlNode section) {
    XmlNodeList list = selectNodes(section, OvfProperties.USER);
    Set<DbUser> dbUsers = new HashSet<>();
    Map<String, Set<String>> userToRoles = new HashMap<>();
    for (XmlNode node : list) {
        String userDomain = selectSingleNode(node, OvfProperties.USER_DOMAIN, _xmlNS).innerText;
        DbUser dbUser = new DbUser();
        dbUser.setLoginName(userDomain.split("@")[0]);
        dbUser.setDomain(userDomain.split("@")[1]);
        dbUsers.add(dbUser);
        XmlNode rolesElement = selectSingleNode(node, OvfProperties.USER_ROLES);
        XmlNodeList roleNodes = selectNodes(rolesElement, OvfProperties.ROLE_NAME);
        Set<String> roleNames = new HashSet<>();
        for (XmlNode roleNode : roleNodes) {
            String roleName = roleNode.innerText;
            roleNames.add(roleName);
        }
        userToRoles.put(dbUser.getLoginName(), roleNames);
    }
    fullEntityOvfData.setDbUsers(dbUsers);
    fullEntityOvfData.setUserToRoles(userToRoles);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Aggregations

XmlNode (org.ovirt.engine.core.utils.ovf.xml.XmlNode)50 XmlNodeList (org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)23 Guid (org.ovirt.engine.core.compat.Guid)19 HashMap (java.util.HashMap)16 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)14 ArrayList (java.util.ArrayList)13 XmlAttribute (org.ovirt.engine.core.utils.ovf.xml.XmlAttribute)12 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 XmlDocument (org.ovirt.engine.core.utils.ovf.xml.XmlDocument)10 Map (java.util.Map)9 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)9 DiskLunMap (org.ovirt.engine.core.common.businessentities.storage.DiskLunMap)9 MemoizingSupplier (org.ovirt.engine.core.utils.MemoizingSupplier)9 XmlNamespaceManager (org.ovirt.engine.core.utils.ovf.xml.XmlNamespaceManager)9 Arrays (java.util.Arrays)8 Collections (java.util.Collections)8 Comparator (java.util.Comparator)8 List (java.util.List)8 Objects (java.util.Objects)8 Optional (java.util.Optional)8