Allon Mureinik has uploaded a new change for review. Change subject: core: Rename UpdateVmDiskCommand CDA methods ......................................................................
core: Rename UpdateVmDiskCommand CDA methods Renamed shouldUpdate*Properties() methods to update*RuntimeParametersRequested() which better reflects what these methods do - they check if an update to a certain parameter was requested, they do not decide if it's appropriate (as the "should" prefix would suggest). Change-Id: I91789866212b88e39b2e133c2d29c57475a7a624 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java 2 files changed, 13 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/25846/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java index c85c268..8445517 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java @@ -100,7 +100,7 @@ } } - if (shouldResizeDiskImage()) { + if (resizeDiskImageRequested()) { exclusiveLock.put(getOldDisk().getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, VdcBllMessages.ACTION_TYPE_FAILED_DISKS_LOCKED)); } @@ -112,7 +112,7 @@ protected void executeVmCommand() { ImagesHandler.setDiskAlias(getParameters().getDiskInfo(), getVm()); - if (shouldResizeDiskImage()) { + if (resizeDiskImageRequested()) { extendDiskImageSize(); } else { try { @@ -135,7 +135,7 @@ if (!vmsDiskOrSnapshotPluggedTo.isEmpty()) { // only virtual drive size can be updated when VMs is running - if (isAtLeastOneVmIsNotDown() && shouldUpdatePropertiesOtherThanSizeAndAlias()) { + if (isAtLeastOneVmIsNotDown() && updateRuntimeParametersRequested()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } @@ -258,7 +258,7 @@ } private boolean validateCanUpdateReadOnly() { - if (shouldUpdateReadOnly() && getVm().getStatus() != VMStatus.Down && vmDeviceForVm.getIsPlugged()) { + if (updateReadOnlyRequested() && getVm().getStatus() != VMStatus.Down && vmDeviceForVm.getIsPlugged()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } return true; @@ -354,7 +354,7 @@ } private void updateDeviceProperties() { - if (shouldUpdateReadOnly()) { + if (updateReadOnlyRequested()) { vmDeviceForVm.setIsReadOnly(getNewDisk().getReadOnly()); getVmDeviceDao().update(vmDeviceForVm); } @@ -527,16 +527,16 @@ return list; } - private boolean shouldResizeDiskImage() { + private boolean resizeDiskImageRequested() { return getNewDisk().getDiskStorageType() == DiskStorageType.IMAGE && vmDeviceForVm.getSnapshotId() == null && getNewDisk().getSize() != getOldDisk().getSize(); } - private boolean shouldUpdatePropertiesOtherThanSizeAndAlias() { - return shouldUpdateDiskProperties() || shouldUpdateImageProperties(); + private boolean updateRuntimeParametersRequested() { + return updateDiskRuntimeParametersRequested() || updateImageRuntimeParametersRequested(); } - private boolean shouldUpdateDiskProperties() { + private boolean updateDiskRuntimeParametersRequested() { return getOldDisk().isBoot() != getNewDisk().isBoot() || getOldDisk().getDiskInterface() != getNewDisk().getDiskInterface() || getOldDisk().getPropagateErrors() != getNewDisk().getPropagateErrors() || @@ -546,7 +546,7 @@ !StringUtils.equals(getOldDisk().getDiskDescription(), getNewDisk().getDiskDescription()); } - private boolean shouldUpdateImageProperties() { + private boolean updateImageRuntimeParametersRequested() { if (getOldDisk().getDiskStorageType() != DiskStorageType.IMAGE) { return false; } @@ -554,7 +554,7 @@ return !Objects.equals(oldQuotaId, getQuotaId()); } - protected boolean shouldUpdateReadOnly() { + protected boolean updateReadOnlyRequested() { return !vmDeviceForVm.getIsReadOnly().equals(getNewDisk().getReadOnly()); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java index 25ebf52..49bed75 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java @@ -408,8 +408,8 @@ initializeCommand(parameters); command.executeVmCommand(); - assertFalse(command.shouldUpdateReadOnly()); - verify(command, atLeast(1)).shouldUpdateReadOnly(); + assertFalse(command.updateReadOnlyRequested()); + verify(command, atLeast(1)).updateReadOnlyRequested(); verify(vmDeviceDAO, never()).update(any(VmDevice.class)); } -- To view, visit http://gerrit.ovirt.org/25846 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91789866212b88e39b2e133c2d29c57475a7a624 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
