Gilad Chaplik has uploaded a new change for review. Change subject: core: handle non existent OVF quota id ......................................................................
core: handle non existent OVF quota id The fix in Ibcd0b29861a43bcb77acd7c3e0bae58d7b27b8f4 treats empty quota, but not handling other un-existing quota(s) (i.e. quota that was assigned to the snapshot, and then was deleted from the setup). Leaving the former change as well since it can prevent db queries for empty UUID (quota id is set to null). Change-Id: I5de8f2c0cbc12405c34234958a61f61654f2d62d Bug-Url: https://bugzilla.redhat.com/1025773 Signed-off-by: Gilad Chaplik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java 1 file changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/21624/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java index 1bd4118..101316f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/snapshots/SnapshotsManager.java @@ -17,6 +17,7 @@ import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.ImageStatus; +import org.ovirt.engine.core.common.businessentities.Quota; import org.ovirt.engine.core.common.businessentities.Snapshot; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType; @@ -36,6 +37,7 @@ import org.ovirt.engine.core.dao.BaseDiskDao; import org.ovirt.engine.core.dao.DiskDao; import org.ovirt.engine.core.dao.DiskImageDAO; +import org.ovirt.engine.core.dao.QuotaDAO; import org.ovirt.engine.core.dao.SnapshotDao; import org.ovirt.engine.core.dao.VdsGroupDAO; import org.ovirt.engine.core.dao.VmDAO; @@ -392,10 +394,27 @@ vm.setVdsGroupCpuName(vdsGroup.getcpu_name()); } } + validateQuota(vm); return true; } catch (OvfReaderException e) { log.errorFormat("Failed to update VM from the configuration: {0}).", configuration, e); return false; + } + } + + /** + * Validate whether the quota supplied in snapshot configuration exists in<br> + * current setup, if not reset to null.<br> + * + * @param vm + * imported vm + */ + private void validateQuota(VM vm) { + if (vm.getQuotaId() != null) { + Quota quota = getQuotaDao().getById(vm.getQuotaId()); + if (quota == null) { + vm.setQuotaId(null); + } } } @@ -545,4 +564,8 @@ protected VmNetworkInterfaceDao getVmNetworkInterfaceDao() { return DbFacade.getInstance().getVmNetworkInterfaceDao(); } + + protected QuotaDAO getQuotaDao() { + return DbFacade.getInstance().getQuotaDao(); + } } -- To view, visit http://gerrit.ovirt.org/21624 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5de8f2c0cbc12405c34234958a61f61654f2d62d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Gilad Chaplik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
