Search in sources :

Example 11 with XmlNode

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

the class OvfOvaReader method readCpuItem.

@Override
protected void readCpuItem(XmlNode node) {
    XmlNode virtualQuantity = selectSingleNode(node, "rasd:VirtualQuantity", _xmlNS);
    if (virtualQuantity != null) {
        vm.setNumOfSockets(Integer.parseInt(virtualQuantity.innerText));
        vm.setCpuPerSocket(1);
        vm.setThreadsPerCpu(1);
    } else {
        super.readCpuItem(node);
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode)

Example 12 with XmlNode

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

the class OvfOvirtReader method buildNicReference.

protected void buildNicReference() {
    XmlNodeList list = selectNodes(_document, "//*/Nic", _xmlNS);
    for (XmlNode node : list) {
        VmNetworkInterface iface = new VmNetworkInterface();
        iface.setId(new Guid(node.attributes.get("ovf:id").getValue()));
        interfaces.add(iface);
    }
    if (!list.iterator().hasNext()) {
        String pattern = "//*/Item[" + VMD_RESOURCE_TYPE + "=" + OvfHardware.Network + "]";
        list = selectNodes(_document, pattern, _xmlNS);
        int nicIdx = 0;
        for (XmlNode node : list) {
            VmNetworkInterface iface = new VmNetworkInterface();
            iface.setId(Guid.newGuid());
            updateSingleNic(node, iface, ++nicIdx);
            interfaces.add(iface);
        }
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 13 with XmlNode

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

the class OvfOvirtReader method readLunDisk.

@Override
protected void readLunDisk(XmlNode node, LunDisk lun) {
    lun.setDiskVmElements(Collections.singletonList(new DiskVmElement(lun.getId(), fullEntityOvfData.getVmBase().getId())));
    LUNs luns = new LUNs();
    consumeReadXmlAttribute(node, OVF_PREFIX + COLON + LUN_ID, val -> luns.setLUNId(val));
    ArrayList<StorageServerConnections> lunConnections = new ArrayList<>();
    for (XmlNode connNode : selectNodes(node, LUN_CONNECTION)) {
        StorageServerConnections conn = new StorageServerConnections();
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_CONNECTION, val -> conn.setConnection(val));
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_IQN, val -> conn.setIqn(val));
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_PORT, val -> conn.setPort(val));
        consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_STORAGE_TYPE, val -> conn.setStorageType(StorageType.valueOf(val)));
        consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_PORTAL, val -> conn.setPortal(val));
        lunConnections.add(conn);
    }
    luns.setLunConnections(lunConnections);
    lun.setLun(luns);
    DiskVmElement dve = lun.getDiskVmElementForVm(fullEntityOvfData.getVmBase().getId());
    initGeneralDiskAttributes(node, lun, dve);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 14 with XmlNode

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

the class OvfOvirtReader method buildVirtualSystem.

@Override
public void buildVirtualSystem() {
    XmlNode virtualSystem = selectSingleNode(_document, "//*/Content");
    consumeReadProperty(virtualSystem, NAME, val -> fullEntityOvfData.getVmBase().setName(val));
    // set ovf version to the ovf object
    fullEntityOvfData.getVmBase().setOvfVersion(getVersion());
    XmlNodeList list = selectNodes(virtualSystem, "Section");
    if (list != null) {
        // The Os need to be read before the hardware
        XmlNode node = getNode(list, "xsi:type", "ovf:OperatingSystemSection_Type");
        if (node != null) {
            readOsSection(node);
            if (!osRepository.isLinux(fullEntityOvfData.getVmBase().getOsId()) || fullEntityOvfData.getVmBase().getDefaultDisplayType() != DisplayType.qxl) {
                fullEntityOvfData.getVmBase().setSingleQxlPci(false);
            }
        }
        node = getNode(list, "xsi:type", "ovf:VirtualHardwareSection_Type");
        if (node != null) {
            readHardwareSection(node);
        }
        node = getNode(list, "xsi:type", "ovf:SnapshotsSection_Type");
        if (node != null) {
            readSnapshotsSection(node);
        }
        node = getNode(list, "xsi:type", "ovf:AffinityGroupsSection_Type");
        if (node != null) {
            readAffinityGroupsSection(node);
        }
        node = getNode(list, "xsi:type", "ovf:AffinityLabelsSection_Type");
        if (node != null) {
            readAffinityLabelsSection(node);
        }
        node = getNode(list, "xsi:type", "ovf:UserDomainsSection_Type");
        if (node != null) {
            readUserDomainsSection(node);
        }
    }
    readGeneralData(virtualSystem);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 15 with XmlNode

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

the class OvfReader method readUsbItem.

private void readUsbItem(XmlNode node) {
    XmlNode usbPolicy = selectSingleNode(node, "rasd:UsbPolicy", _xmlNS);
    vmBase.setUsbPolicy(usbPolicy != null ? UsbPolicy.forStringValue(usbPolicy.innerText) : UsbPolicy.ENABLED_NATIVE);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode)

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