Vered Volansky has uploaded a new change for review. Change subject: core: Allow activate an already active domain ......................................................................
core: Allow activate an already active domain Using rest to try to activate an already active domain was an illegal action. It's now allowed, with an AuditLog alert. Change-Id: Ibe8ad96a5bd40adb56b7a63c4ae5ef75a550e5b2 Bug-Url: https://bugzilla.redhat.com/849427 Signed-off-by: Vered Volansky <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageDomainCommandBase.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties 6 files changed, 22 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/20/21320/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java index 693c40e..014146c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java @@ -22,14 +22,15 @@ import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap; import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; -import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.ActivateStorageDomainVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.TransactionScopeOption; import org.ovirt.engine.core.dal.dbbroker.DbFacade; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; import org.ovirt.engine.core.utils.transaction.TransactionMethod; import org.ovirt.engine.core.utils.transaction.TransactionSupport; @@ -65,6 +66,13 @@ @Override protected void executeCommand() { + if (getStorageDomainStatus() == StorageDomainStatus.Active) + { + AuditLogDirector.log(this, AuditLogType.USER_ACTIVATE_STORAGE_DOMAIN_ALERT); + setSucceeded(true); + return; + } + final StoragePoolIsoMap map = DbFacade.getInstance() .getStoragePoolIsoMapDao() @@ -141,10 +149,10 @@ private boolean storageDomainStatusIsValid() { boolean returnValue; if (isInternalExecution()) { - returnValue = checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, + returnValue = checkStorageDomainStatus(StorageDomainStatus.Active, StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Locked, StorageDomainStatus.Maintenance); } else { - returnValue = checkStorageDomainStatus(StorageDomainStatus.InActive, StorageDomainStatus.Unknown, + returnValue = checkStorageDomainStatus(StorageDomainStatus.Active, StorageDomainStatus.InActive, StorageDomainStatus.Unknown, StorageDomainStatus.Maintenance); } return returnValue; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageDomainCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageDomainCommandBase.java index 08c7121..d463d4c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageDomainCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageDomainCommandBase.java @@ -163,12 +163,14 @@ if (status != null) { valid = Arrays.asList(statuses).contains(status); } + if (!valid) { if (status == StorageDomainStatus.Locked) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED); } addStorageDomainStatusIllegalMessage(); } + return valid; } @@ -370,7 +372,7 @@ }); } - private StorageDomainStatus getStorageDomainStatus() { + protected StorageDomainStatus getStorageDomainStatus() { StorageDomainStatus status = null; if (getStorageDomain() != null) { status = getStorageDomain().getStatus(); diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommandTest.java index 9739bc6..bca6def 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommandTest.java @@ -63,15 +63,13 @@ } @Test - public void activeDisallowed() { - testExecution(StorageDomainStatus.Active); - testActionDisallowed(); + public void nonInternalActiveAllowed() { + nonInternalActionAllowed(StorageDomainStatus.Active); } @Test - public void internalActiveDisallowed() { - testInternalExecution(StorageDomainStatus.Active); - testActionDisallowed(); + public void internalActiveAllowed() { + internalActionAllowed(StorageDomainStatus.Active); } @Test diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index acb79a6..ee09d39 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -737,6 +737,7 @@ USER_ACTIVATED_STORAGE_DOMAIN_ASYNC(9505, AuditLogTimeInterval.HOUR.getValue() * 3), USER_ACTIVATE_STORAGE_DOMAIN_FAILED_ASYNC(9506, AuditLogTimeInterval.HOUR.getValue() * 3), + USER_ACTIVATE_STORAGE_DOMAIN_ALERT(9507), IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES(9600, AuditLogTimeInterval.MINUTE.getValue()), VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS(9601, AuditLogTimeInterval.MINUTE.getValue()), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java index f0b6727..0484911 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java @@ -442,6 +442,7 @@ severities.put(AuditLogType.SYSTEM_CHANGE_STORAGE_POOL_STATUS_RESET_IRS, AuditLogSeverity.NORMAL); severities.put(AuditLogType.USER_ACTIVATED_STORAGE_DOMAIN_ASYNC, AuditLogSeverity.NORMAL); severities.put(AuditLogType.USER_ACTIVATE_STORAGE_DOMAIN_FAILED_ASYNC, AuditLogSeverity.WARNING); + severities.put(AuditLogType.USER_ACTIVATE_STORAGE_DOMAIN_ALERT, AuditLogSeverity.NORMAL); severities.put(AuditLogType.STORAGE_DOMAIN_TASKS_ERROR, AuditLogSeverity.WARNING); severities.put(AuditLogType.UPDATE_OVF_FOR_STORAGE_POOL_FAILED, AuditLogSeverity.WARNING); severities.put(AuditLogType.UPGRADE_STORAGE_POOL_ENCOUNTERED_PROBLEMS, AuditLogSeverity.WARNING); diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index 28a7e54..3af1aac 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -405,7 +405,8 @@ RECOVERY_STORAGE_POOL_FAILED=Failed to recover Data Center ${StoragePoolName} (User:${UserName}) USER_ACTIVATE_STORAGE_DOMAIN_FAILED=Failed to activate Storage Domain ${StorageDomainName} (Data Center ${StoragePoolName}) by ${UserName} USER_ACTIVATE_STORAGE_DOMAIN_FAILED_ASYNC=Failed to autorecover Storage Domain ${StorageDomainName} (Data Center ${StoragePoolName}). -USER_ADD_STORAGE_DOMAIN=Storage Domain ${StorageDomainName} was added by ${UserName} +USER_ACTIVATE_STORAGE_DOMAIN_ALERT=Storage Domain ${StorageDomainName} is already active. +USER_ADD_STORAGE_DOMAIN=Storage Domain ${StorageDomainName} was added by ${UserName} ${StorageDomainName} USER_ADD_STORAGE_DOMAIN_FAILED=Failed to add Storage Domain ${StorageDomainName}. (User: ${UserName}) USER_ADD_STORAGE_POOL=Data Center ${StoragePoolName} with Type ${StoragePoolType}, Compatibility Version ${CompatibilityVersion} and Quota Type ${QuotaEnforcementType} was added by ${UserName} USER_ADD_STORAGE_POOL_FAILED=Failed to add Data Center ${StoragePoolName}. (User: ${UserName}) -- To view, visit http://gerrit.ovirt.org/21320 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe8ad96a5bd40adb56b7a63c4ae5ef75a550e5b2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vered Volansky <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
