Omer Frenkel has uploaded a new change for review. Change subject: core: ImportVm - use device info only if supported ......................................................................
core: ImportVm - use device info only if supported vm devices were intoduced only in 3.1 when importing vm, check ovf version to know if to use devices information from it. Change-Id: I5f57aad01383b8a3238030b1bae5b6f8a5e1481a Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java 4 files changed, 41 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/10625/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java index 625d20d..dfb4f5e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java @@ -30,6 +30,7 @@ import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils; import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dao.VmDAO; import org.ovirt.engine.core.dao.VmDeviceDAO; @@ -589,14 +590,21 @@ return new HashSet<BaseDisk>(diskMap.values()); } - private static <T extends VmBase> void updateVmDevice(T entity, VmDevice vmDevice, Guid deviceId, List<VmDevice> vmDeviceToUpdate) { - VmDevice exportedDevice = entity.getManagedVmDeviceMap().get(deviceId); - if (exportedDevice != null) { - vmDevice.setAddress(exportedDevice.getAddress()); - vmDevice.setBootOrder(exportedDevice.getBootOrder()); - vmDevice.setIsPlugged(exportedDevice.getIsPlugged()); - vmDevice.setIsReadOnly(exportedDevice.getIsReadOnly()); - vmDeviceToUpdate.add(vmDevice); + private static <T extends VmBase> void updateVmDevice(T entity, + VmDevice vmDevice, + Guid deviceId, + List<VmDevice> vmDeviceToUpdate) { + // update device information only if ovf support devices - from 3.1 + Version ovfVer = new Version(entity.getOvfVersion()); + if (!VmDeviceCommonUtils.isOldClusterVersion(ovfVer)) { + VmDevice exportedDevice = entity.getManagedVmDeviceMap().get(deviceId); + if (exportedDevice != null) { + vmDevice.setAddress(exportedDevice.getAddress()); + vmDevice.setBootOrder(exportedDevice.getBootOrder()); + vmDevice.setIsPlugged(exportedDevice.getIsPlugged()); + vmDevice.setIsReadOnly(exportedDevice.getIsReadOnly()); + vmDeviceToUpdate.add(vmDevice); + } } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java index e260a4e..a32684f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java @@ -1511,4 +1511,12 @@ public void setBalloonEnabled(boolean isBallonEnabled) { balloonEnabled = isBallonEnabled; } + + public String getOvfVersion() { + return vmStatic.getOvfVersion(); + } + + public void setOvfVersion(String ovfVersion) { + vmStatic.setOvfVersion(ovfVersion); + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java index 1844fcc..85ed2c5 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java @@ -139,6 +139,12 @@ @Column(name = "allow_console_reconnect") private boolean allowConsoleReconnect; + /** + * this field is used to save the ovf version, + * in case the vm object was built from ovf + */ + private String ovfVersion; + // not persisted to db private Date exportDate; @@ -769,4 +775,12 @@ public void setdefault_display_type(DisplayType value) { defaultDisplayType = value; } + + public String getOvfVersion() { + return ovfVersion; + } + + public void setOvfVersion(String ovfVersion) { + this.ovfVersion = ovfVersion; + } } 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 3b6f641..29007d0 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 @@ -290,6 +290,9 @@ XmlNode content = _document.SelectSingleNode("//*/Content"); XmlNode node; + // set ovf version to the ovf object + vmBase.setOvfVersion(getVersion()); + node = content.SelectSingleNode("Description"); if (node != null) { vmBase.setdescription(node.InnerText); -- To view, visit http://gerrit.ovirt.org/10625 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5f57aad01383b8a3238030b1bae5b6f8a5e1481a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches