Arik Hadas has uploaded a new change for review. Change subject: core: Replace ImagesHandler#isVmDown method ......................................................................
core: Replace ImagesHandler#isVmDown method Replace ImagesHandler#isVmDown method with VM#isDown method. ImagesHander is not the place for utility method that checks VM status. VM status is a property of VM, thus VM instance should be able to express whether it's down or not, passing a VM instance to another class in order to check its status doesn't make sense. Change-Id: I3f15c8b9a307d5ecb239750dbdbac3faea7b802a Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java 3 files changed, 11 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/10779/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java index 703cb4e..8232922 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java @@ -272,7 +272,7 @@ // if live snapshot is not available, then if vm is up - snapshot is not possible so it needs to be // checked if vm up or not // if live snapshot is enabled, there is no need to check if vm is up since in any case snapshot is possible - if (!isLiveSnapshotEnabled() && !ImagesHandler.isVmDown(vm)) { + if (!isLiveSnapshotEnabled() && !vm.isDown()) { // if there is no live snapshot and the vm is up - snapshot is not possible return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DATA_CENTER_VERSION_DOESNT_SUPPORT_LIVE_SNAPSHOT); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java index e0d8c87..b09d34b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java @@ -447,11 +447,6 @@ } - public static boolean isVmDown(VM vm) { - return vm.getStatus() == VMStatus.Down; - } - - public static boolean isStoragePoolValid(Guid storagePoolId) { storage_pool pool = DbFacade.getInstance().getStoragePoolDao().get(storagePoolId); if (pool == null || pool.getstatus() != StoragePoolStatus.Up) { @@ -486,7 +481,7 @@ returnValue = checkImagesLocked(vm, messages, images); } - if (returnValue && checkVmIsDown && !isVmDown(vm)) { + if (returnValue && checkVmIsDown && !vm.isDown()) { returnValue = false; ListUtils.nullSafeAdd(messages, VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN.toString()); } 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 b3f9aab..2f3d304 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 @@ -1524,4 +1524,13 @@ public String getName() { return getVmName(); } + + /** + * Utility method for checking if the VM is with DOWN status + * + * @return true if the VM's status is DOWN, otherwise false + */ + public boolean isDown() { + return getStatus() == VMStatus.Down; + } } -- To view, visit http://gerrit.ovirt.org/10779 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3f15c8b9a307d5ecb239750dbdbac3faea7b802a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
