Gilad Chaplik has uploaded a new change for review. Change subject: core: handle unavilable ovf quota id ......................................................................
core: handle unavilable ovf quota id The fix in Ibcd0b29861a43bcb77acd7c3e0bae58d7b27b8f4 treats empty quota, but not handling other unavailable quota(s). Leaving the former change as well since it can prevent db queries for empty uuid as quota id. 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, 15 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/21332/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 4289e9a..10f1a73 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 @@ -18,6 +18,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; @@ -309,6 +311,7 @@ CompensationContext compensationContext, Version version, DbUser user) { boolean vmUpdatedFromConfiguration = false; if (snapshot.getVmConfiguration() != null) { + vmUpdatedFromConfiguration = updateVmFromConfiguration(vm, snapshot.getVmConfiguration()); } @@ -392,6 +395,14 @@ vm.setVdsGroupCpuName(vdsGroup.getcpu_name()); } } + // check if the quota saved in vm configuration is valid: + // in case it no longer available, reset the vm's quota. + if (vm.getQuotaId() != null) { + Quota quota = getQuotaDao().getById(vm.getQuotaId()); + if (quota == null) { + vm.setQuotaId(null); + } + } return true; } catch (OvfReaderException e) { log.errorFormat("Failed to update VM from the configuration: {0}).", configuration, e); @@ -399,6 +410,10 @@ } } + protected QuotaDAO getQuotaDao() { + return DbFacade.getInstance().getQuotaDao(); + } + /** * Synchronize the VM's {@link VmNetworkInterface}s with the ones from the snapshot.<br> * All existing NICs will be deleted, and the ones from the snapshot re-added.<br> -- To view, visit http://gerrit.ovirt.org/21332 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5de8f2c0cbc12405c34234958a61f61654f2d62d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
