Allon Mureinik has uploaded a new change for review. Change subject: core: RemoveDiskCommand: only validate images once ......................................................................
core: RemoveDiskCommand: only validate images once RemoveDiskCommand.canRemoveVmImageDisk() called ImageHandler.PerformImagesChecks in a loop, for each VM attached to the disk. Since the VM checks have been extracted from ImageHandler.PerformImagesChecks in commit 69b515c3a30b0185f05b3b7d3451806f2b5b86cb, this is no longer required, can the validation can be called a single time. Change-Id: I8c0408db32415785bfe36d144b08a6f6c9f0aefc Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java 1 file changed, 18 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/13266/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java index f024bd3..9dbe45e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskCommand.java @@ -209,34 +209,36 @@ } private boolean canRemoveVmImageDisk() { - boolean firstTime = true; - SnapshotsValidator snapshotsValidator = new SnapshotsValidator(); List<Disk> diskList = Arrays.asList(getDisk()); if (!listVms.isEmpty()) { - storage_pool sp = getStoragePoolDAO().get(listVms.get(0).getStoragePoolId()); + Guid storagePoolId = listVms.get(0).getStoragePoolId(); + storage_pool sp = getStoragePoolDAO().get(storagePoolId); if (!validate(new StoragePoolValidator(sp).isUp())) { + return false; + } + + if (!ImagesHandler.PerformImagesChecks( + getReturnValue().getCanDoActionMessages(), + storagePoolId, + getParameters().getStorageDomainId(), + false, + true, + false, + false, + false, + true, + diskList)) { return false; } } + SnapshotsValidator snapshotsValidator = new SnapshotsValidator(); for (VM vm : listVms) { if (!validate(snapshotsValidator.vmNotDuringSnapshot(vm.getId())) || - !validate(snapshotsValidator.vmNotInPreview(vm.getId())) || - !ImagesHandler.PerformImagesChecks( - getReturnValue().getCanDoActionMessages(), - vm.getStoragePoolId(), - getParameters().getStorageDomainId(), - false, - firstTime, - false, - false, - false, - firstTime, - diskList)) { + !validate(snapshotsValidator.vmNotInPreview(vm.getId()))) { return false; } - firstTime = false; } return true; } -- To view, visit http://gerrit.ovirt.org/13266 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8c0408db32415785bfe36d144b08a6f6c9f0aefc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches