Maor Lipchuk has uploaded a new change for review. Change subject: core: Add the correlated OVF write logic for Cinder ......................................................................
core: Add the correlated OVF write logic for Cinder We should support diskStorageType for each disk in OVF to support snapshots of cinder disk. We need this for snapshots for the following scenrio: 1. Create a snapshot from a VM with image disk 2. Create a Cinder disk 3. Preview the snapshot 4. Undo the preview The engine then should get the Cinder disk back to the VM as Cinder from the OVF. Change-Id: Idd1b99979e067af41b9d37a982be6da406a9e7e1 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Maor Lipchuk <[email protected]> --- M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java 1 file changed, 21 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/40982/1 diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java index 48d1832..3c12049 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java @@ -25,8 +25,10 @@ import org.ovirt.engine.core.common.businessentities.VmType; import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; +import org.ovirt.engine.core.common.businessentities.storage.CinderDisk; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.DiskInterface; +import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; import org.ovirt.engine.core.common.businessentities.storage.VolumeFormat; import org.ovirt.engine.core.common.businessentities.storage.VolumeType; @@ -862,14 +864,26 @@ private void buildImageReference() { XmlNodeList list = _document.SelectNodes("//*/File", _xmlNS); for (XmlNode node : list) { - DiskImage image = new DiskImage(); - image.setImageId(new Guid(node.attributes.get("ovf:id").getValue())); - image.setId(OvfParser.GetImageGrupIdFromImageFile(node.attributes.get("ovf:href").getValue())); + // If the disk storage type is Cinder then override the disk image with Cinder object, otherwise use the disk image. + DiskImage disk = new DiskImage(); + + // If the OVF is old and does not contain any storage type reference then we assume we can only have disk image. + XmlNode xmlDiskStorageType = node.SelectSingleNode("rasd:DiskStorageType", _xmlNS); + String diskStorageTypeFromOvf = xmlDiskStorageType != null ? xmlDiskStorageType.innerText : null; + if (StringUtils.isNotEmpty(diskStorageTypeFromOvf)) { + DiskStorageType diskStorageType = DiskStorageType.valueOf(diskStorageTypeFromOvf); + if (diskStorageType == DiskStorageType.CINDER) { + disk = new CinderDisk(); + } + } + + disk.setImageId(new Guid(node.attributes.get("ovf:id").getValue())); + disk.setId(OvfParser.GetImageGrupIdFromImageFile(node.attributes.get("ovf:href").getValue())); // Default values: - image.setActive(true); - image.setImageStatus(ImageStatus.OK); - image.setDescription(node.attributes.get("ovf:description").getValue()); - _images.add(image); + disk.setActive(true); + disk.setImageStatus(ImageStatus.OK); + disk.setDescription(node.attributes.get("ovf:description").getValue()); + _images.add(disk); } } -- To view, visit https://gerrit.ovirt.org/40982 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idd1b99979e067af41b9d37a982be6da406a9e7e1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
