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);
}
}
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));
}
}
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);
}
Aggregations