Search in sources :

Example 1 with XmlNodeList

use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList 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 2 with XmlNodeList

use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList 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 3 with XmlNodeList

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

the class OvfReader method readDedicatedHostsList.

private void readDedicatedHostsList() {
    // initialize to empty list
    vmBase.setDedicatedVmForVdsList(new LinkedList<>());
    // search all dedicated hosts with xPath
    XmlNodeList hostsList = selectNodes(_document, "//*/Content/" + DEDICATED_VM_FOR_VDS);
    for (XmlNode hostNode : hostsList) {
        if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) {
            vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText));
        }
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 4 with XmlNodeList

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

the class OvfVmReader method readAffinityLabelsSection.

@Override
protected void readAffinityLabelsSection(XmlNode section) {
    XmlNodeList list = selectNodes(section, OvfProperties.AFFINITY_LABEL);
    List<Label> affinityLabels = new ArrayList<>();
    for (XmlNode node : list) {
        String affinityLabelName = node.attributes.get("ovf:name").innerText;
        LabelBuilder builder = new LabelBuilder();
        Label label = builder.name(affinityLabelName).build();
        affinityLabels.add(label);
    }
    fullEntityOvfData.setAffinityLabels(affinityLabels);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) Label(org.ovirt.engine.core.common.businessentities.Label) ArrayList(java.util.ArrayList) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 5 with XmlNodeList

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

the class OvfVmReader method readAffinityGroupsSection.

@Override
protected void readAffinityGroupsSection(XmlNode section) {
    XmlNodeList list = selectNodes(section, OvfProperties.AFFINITY_GROUP);
    List<AffinityGroup> affinityGroups = new ArrayList<>();
    for (XmlNode node : list) {
        String affinityGroupName = node.attributes.get("ovf:name").innerText;
        AffinityGroup affinityGroup = new AffinityGroup();
        affinityGroup.setName(affinityGroupName);
        affinityGroups.add(affinityGroup);
    }
    fullEntityOvfData.setAffinityGroups(affinityGroups);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) ArrayList(java.util.ArrayList) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Aggregations

XmlNode (org.ovirt.engine.core.utils.ovf.xml.XmlNode)13 XmlNodeList (org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)13 Guid (org.ovirt.engine.core.compat.Guid)5 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)1 Label (org.ovirt.engine.core.common.businessentities.Label)1 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)1 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)1 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)1 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1 AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)1