Tal Nisan has uploaded a new change for review. Change subject: core: Disallow force select SPM when Data Center is not up ......................................................................
core: Disallow force select SPM when Data Center is not up Change-Id: I9f59f891d392fbc7c80cc21df3672d328221c007 Bug-Url: https://bugzilla.redhat.com/987875 Signed-off-by: Tal Nisan <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ForceSelectSPMCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ForceSelectSPMCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 23 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/19123/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ForceSelectSPMCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ForceSelectSPMCommand.java index 9c91d1d..1601304 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ForceSelectSPMCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ForceSelectSPMCommand.java @@ -10,6 +10,7 @@ import org.ovirt.engine.core.common.businessentities.ActionGroup; import org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VdsSpmStatus; import org.ovirt.engine.core.common.errors.VdcBllMessages; @@ -49,6 +50,10 @@ return failCanDoAction(VdcBllMessages.CANNOT_FORCE_SELECT_SPM_VDS_MARKED_AS_NEVER_SPM); } + if (getStoragePoolForVds().getstatus() != StoragePoolStatus.Up) { + return failCanDoAction(VdcBllMessages.CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP); + } + if (isAsyncTasksRunningOnPool(getStoragePoolForVds().getId())) { return failCanDoAction(VdcBllMessages.CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_HAS_RUNNING_TASKS); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ForceSelectSPMCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ForceSelectSPMCommandTest.java index c5fb913..fb64307 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ForceSelectSPMCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/ForceSelectSPMCommandTest.java @@ -17,6 +17,7 @@ import org.ovirt.engine.core.common.action.ForceSelectSPMParameters; import org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions; import org.ovirt.engine.core.common.businessentities.StoragePool; +import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VdsSpmStatus; @@ -90,6 +91,13 @@ } @Test + public void testCDAStoragePoolNotUp() { + storagePool.setstatus(StoragePoolStatus.Uninitialized); + assertFalse("canDoAction did not fail on a Storage Pool which is not up", command.canDoAction()); + checkMessagesContains(command, VdcBllMessages.CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP); + } + + @Test public void testCDAStoragePoolHasTasks() { List<Guid> tasks = Arrays.asList(Guid.newGuid()); doReturn(tasks).when(asyncTaskDAOMock).getAsyncTaskIdsByStoragePoolId(storagePoolId); @@ -108,6 +116,7 @@ storagePool = new StoragePool(); storagePool.setId(storagePoolId); + storagePool.setstatus(StoragePoolStatus.Up); } private void mockCommand() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 9d78564..756104c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -242,6 +242,7 @@ CANNOT_FORCE_SELECT_SPM_VDS_NOT_UP(ErrorType.CONFLICT), CANNOT_FORCE_SELECT_SPM_VDS_ALREADY_SPM(ErrorType.CONFLICT), CANNOT_FORCE_SELECT_SPM_VDS_MARKED_AS_NEVER_SPM(ErrorType.CONSTRAINT_VIOLATION), + CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP(ErrorType.CONFLICT), CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_HAS_RUNNING_TASKS(ErrorType.CONFLICT), CANNOT_FORCE_SELECT_SPM_VDS_NOT_IN_POOL(ErrorType.CONFLICT), VDS_NO_VDS_PROXY_FOUND(ErrorType.CONFLICT), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 214e79a..e7e6a2c 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -83,6 +83,7 @@ CANNOT_FORCE_SELECT_SPM_VDS_NOT_UP=Cannot ${action} ${type}. The Host ${VdsName} is not active. CANNOT_FORCE_SELECT_SPM_VDS_ALREADY_SPM=Cannot ${action} ${type}. The Host ${VdsName} is already SPM or contending. CANNOT_FORCE_SELECT_SPM_VDS_MARKED_AS_NEVER_SPM=Cannot ${action} ${type}. The SPM priority of Host ${VdsName} is set to 'never'. This Host cannot be elected as SPM. +CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP=Cannot ${action} ${type}. The Host's Data Center is not up. CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_HAS_RUNNING_TASKS=Cannot ${action} ${type}. The Storage Pool has running tasks. CANNOT_FORCE_SELECT_SPM_VDS_NOT_IN_POOL=Cannot ${action} ${type}. The Host is not a part of a Storage Pool. VDS_PROTOCOL_ERROR=Internal error: Host protocol error. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index edb4b67..ac5ee96 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -191,13 +191,16 @@ String CANNOT_FORCE_SELECT_SPM_VDS_NOT_UP(); @DefaultStringValue("Cannot ${action} ${type}. The Host ${VdsName} is already SPM or contending.") - String CANNOT_FORCE_SELECT__SPM_VDS_ALREADY_SPM(); + String CANNOT_FORCE_SELECT_SPM_VDS_ALREADY_SPM(); @DefaultStringValue("Cannot ${action} ${type}. The SPM priority of Host ${VdsName} is set to 'never'. This Host cannot be elected as SPM.") - String CANNOT_FORCE_SELECT__SPM_VDS_MARKED_AS_NEVER_SPM(); + String CANNOT_FORCE_SELECT_SPM_VDS_MARKED_AS_NEVER_SPM(); + + @DefaultStringValue("Cannot ${action} ${type}. The Host's Data Center is not up.") + String CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP(); @DefaultStringValue("Cannot ${action} ${type}. The Storage Pool has running tasks.") - String CANNOT_FORCE_SELECT__SPM_STORAGE_POOL_HAS_RUNNING_TASKS(); + String CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_HAS_RUNNING_TASKS(); @DefaultStringValue("Cannot ${action} ${type}. The Host is not a part of a Storage Pool.") String CANNOT_FORCE_SELECT_SPM_VDS_NOT_IN_POOL(); diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 939800c..b4986a7 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -83,6 +83,7 @@ CANNOT_FORCE_SELECT_SPM_VDS_NOT_UP=Cannot ${action} ${type}. The Host ${VdsName} is not active. CANNOT_FORCE_SELECT_SPM_VDS_ALREADY_SPM=Cannot ${action} ${type}. The Host ${VdsName} is already SPM or contending. CANNOT_FORCE_SELECT_SPM_VDS_MARKED_AS_NEVER_SPM=Cannot ${action} ${type}. The SPM priority of Host ${VdsName} is set to 'never'. This Host cannot be elected as SPM. +CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_NOT_UP=Cannot ${action} ${type}. The Host's Data Center is not up. CANNOT_FORCE_SELECT_SPM_STORAGE_POOL_HAS_RUNNING_TASKS=Cannot ${action} ${type}. The Storage Pool has running tasks. CANNOT_FORCE_SELECT_SPM_VDS_NOT_IN_POOL=Cannot ${action} ${type}. The Host is not a part of a Storage Pool. VDS_PROTOCOL_ERROR=Internal error: Host protocol error. -- To view, visit http://gerrit.ovirt.org/19123 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9f59f891d392fbc7c80cc21df3672d328221c007 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
