Search in sources :

Example 11 with XmlNodeList

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

the class OvfOvirtReader method buildFileReference.

@Override
protected void buildFileReference() {
    XmlNodeList list = selectNodes(_document, "//*/File", _xmlNS);
    for (XmlNode node : list) {
        // If the disk storage type is Cinder then override the disk image with Cinder object, otherwise use the
        // disk image.
        DiskImage disk = new DiskImage();
        // image.
        if (node.attributes.get("ovf:disk_storage_type") != null) {
            String diskStorageType = node.attributes.get("ovf:disk_storage_type").getValue();
            if (diskStorageType != null) {
                if (diskStorageType.equals(DiskStorageType.LUN.name())) {
                    LunDisk lun = new LunDisk();
                    lun.setId(OvfParser.getImageGroupIdFromImageFile(node.attributes.get("ovf:href").getValue()));
                    luns.add(lun);
                    continue;
                } else if (diskStorageType.equals(DiskStorageType.CINDER.name())) {
                    disk = new CinderDisk();
                    if (node.attributes.get("ovf:cinder_volume_type") != null) {
                        String cinderVolumeType = node.attributes.get("ovf:cinder_volume_type").getValue();
                        disk.setCinderVolumeType(cinderVolumeType);
                    }
                }
            }
        }
        disk.setImageId(new Guid(node.attributes.get("ovf:id").getValue()));
        disk.setId(OvfParser.getImageGroupIdFromImageFile(node.attributes.get("ovf:href").getValue()));
        disk.setDescription(node.attributes.get("ovf:description").getValue());
        _images.add(disk);
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 12 with XmlNodeList

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

the class OvfOvirtReader method buildDisk.

@Override
public void buildDisk() {
    XmlNodeList list = selectNodes(_document, "//*/Section/Disk");
    for (XmlNode node : list) {
        Guid guid = new Guid(node.attributes.get("ovf:diskId").getValue());
        _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().ifPresent(img -> readDisk(node, img));
        luns.stream().filter(d -> d.getId().equals(guid)).findFirst().ifPresent(lun -> readLunDisk(node, lun));
    }
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) Guid(org.ovirt.engine.core.compat.Guid) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 13 with XmlNodeList

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

the class OvfParser method isTemplate.

public boolean isTemplate() {
    String id1 = "1";
    String id2 = "2";
    XmlNode node = _document.selectSingleNode("//*/Content/TemplateId");
    if (!StringUtils.isBlank(node.innerText)) {
        id1 = node.innerText;
    }
    XmlNodeList list = _document.selectNodes("//*/Content/Section");
    for (XmlNode section : list) {
        String value = section.attributes.get("xsi:type").getValue();
        if (StringUtils.equals(value, "ovf:OperatingSystemSection_Type")) {
            id2 = section.attributes.get("ovf:id").getValue();
        }
    }
    return StringUtils.equals(id1, id2);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) 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