Maor Lipchuk has uploaded a new change for review. Change subject: core: Add a CDA on attach to an uninitialized Data Center ......................................................................
core: Add a CDA on attach to an uninitialized Data Center Adding a validation message when trying to attach a Storage Domain which already have a storage pool id initiliazed in its meta data. Storage Domain which have storage pool id already initialized in its meta data (For example after disaster), needs to be detached first and then to be attached to the relevant Data Center, since the detach operation is an SPM operation, an un-initialized Data Center can't perform this operation since it does not have an SPM yet. Change-Id: I13ec66cc7ff4773221cc994cb4f0be1886ed9a6b Bug-Url: https://bugzilla.redhat.com/1138126 Signed-off-by: Maor Lipchuk <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStoragePoolWithStoragesCommand.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/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 43 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/36454/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStoragePoolWithStoragesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStoragePoolWithStoragesCommand.java index a7e7855..b376903 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStoragePoolWithStoragesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddStoragePoolWithStoragesCommand.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.bll.storage; import java.util.Collections; +import java.util.List; import java.util.Map; import org.ovirt.engine.core.bll.Backend; @@ -13,20 +14,22 @@ import org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase; import org.ovirt.engine.core.common.action.StoragePoolWithStoragesParameter; import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.StorageFormatType; +import org.ovirt.engine.core.common.businessentities.StoragePool; +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.businessentities.VDS; -import org.ovirt.engine.core.common.businessentities.StorageDomain; -import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; -import org.ovirt.engine.core.common.businessentities.StoragePool; -import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap; import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.locks.LockingGroup; +import org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters; +import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.utils.VersionStorageFormatUtil; import org.ovirt.engine.core.common.vdscommands.CreateStoragePoolVDSCommandParameters; @@ -297,7 +300,7 @@ protected boolean canDoAction() { boolean returnValue = super.canDoAction() && checkStoragePool() && checkStoragePoolStatus(StoragePoolStatus.Uninitialized) && initializeVds() - && checkStorageDomainsInPool(); + && checkStorageDomainsInPool() && isDomainAttachedToDifferentStoragePool(); return returnValue; } @@ -306,4 +309,26 @@ return Collections.singletonMap(getStoragePoolId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.POOL, VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED)); } + + private boolean isDomainAttachedToDifferentStoragePool() { + if (getStoragePool().getStatus() == StoragePoolStatus.Uninitialized) { + for (Guid storageDomainId : getParameters().getStorages()) { + StorageDomain domain = DbFacade.getInstance().getStorageDomainDao().get(storageDomainId); + if (domain.getStorageDomainType().isDataDomain() && isStorageDomainAttachedToStoragePool(domain)) { + return failCanDoAction(VdcBllMessages.ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN); + } + } + } + return true; + } + + private boolean isStorageDomainAttachedToStoragePool(StorageDomain storageDomain) { + List<StorageDomain> storageDomainList = + (List<StorageDomain>) getBackend().runInternalQuery(VdcQueryType.GetStorageDomainsWithAttachedStoragePoolGuid, + new StorageDomainsAndStoragePoolIdQueryParameters(storageDomain, + getStoragePoolId(), + getVds().getId())) + .getReturnValue(); + return !storageDomainList.isEmpty(); + } } 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 478b0d8..02d9d69 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 @@ -631,6 +631,7 @@ ERROR_CANNOT_DEACTIVATE_MASTER_DOMAIN_WITH_TASKS_ON_POOL(ErrorType.CONFLICT), ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_AND_ISO_DOMAINS(ErrorType.BAD_PARAMETERS), ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_DOMAIN(ErrorType.CONFLICT), + ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN(ErrorType.CONFLICT), ERROR_CANNOT_ADD_STORAGE_POOL_WITH_DIFFERENT_STORAGE_FORMAT(ErrorType.CONFLICT), ERROR_CANNOT_CREATE_STORAGE_DOMAIN_WITHOUT_VG_LV(ErrorType.BAD_PARAMETERS), ERROR_CANNOT_REMOVE_POOL_WITH_NETWORKS(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 96ba500..5b61861 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -540,6 +540,9 @@ NETWORK_VLAN_OUT_OF_RANGE=VLAN ID must be a number between 0 and 4094. ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_DOMAIN=Cannot attach Storage Domain.\n\ -Please attach Data Domain to the Data Center first. +ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN=Cannot ${action} ${type}.\n\ + The Storage Domain is already attached to a different Data Center and cannot be attcahed to an uninitialized Data Center.\n\ + -Please attach a differenet Data Domain to the Data Center first. ERROR_CANNOT_REMOVE_POOL_WITH_ACTIVE_DOMAINS=Cannot remove Data Center which contains active/locked Storage Domains.\n\ -Please deactivate all domains and wait for tasks to finish before removing the Data Center. VDS_GROUP_CANNOT_CHANGE_STORAGE_POOL=Cannot change Data Center association when editing a Cluster. 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 6c2ae99..c5b5ad0 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 @@ -1495,6 +1495,9 @@ @DefaultStringValue("Cannot attach Storage Domain.\n-Please attach Data Domain to the Data Center first.") String ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_DOMAIN(); + @DefaultStringValue("Cannot ${action} ${type}.\n The Storage Domain is already attached to a different Data Center and cannot be attcahed to an uninitialized Data Center.\n -Please attach a differenet Data Domain to the Data Center first.") + String ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN(); + @DefaultStringValue("Cannot remove Data Center which contains active/locked Storage Domains.\n-Please deactivate all domains and wait for tasks to finish before removing the Data Center.") String ERROR_CANNOT_REMOVE_POOL_WITH_ACTIVE_DOMAINS(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 5821301..32e828c 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -503,6 +503,9 @@ NETWORK_VLAN_OUT_OF_RANGE=VLAN ID must be a number between 0 and 4094. ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_DOMAIN=Cannot attach Storage Domain.\n\ -Please attach Data Domain to the Data Center first. +ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN=Cannot ${action} ${type}.\n\ + The Storage Domain is already attached to a different Data Center and cannot be attcahed to an uninitialized Data Center.\n\ + -Please attach a differenet Data Domain to the Data Center first. ERROR_CANNOT_REMOVE_POOL_WITH_ACTIVE_DOMAINS=Cannot remove Data Center which contains active/locked Storage Domains.\n\ -Please deactivate all domains and wait for tasks to finish before removing the Data Center. VDS_GROUP_CANNOT_CHANGE_STORAGE_POOL=Cannot change Data Center association when editing a Cluster. 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 a837ee1..c6268be 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 @@ -544,6 +544,9 @@ NETWORK_VLAN_OUT_OF_RANGE=VLAN ID must be a number between 0 and 4094. ERROR_CANNOT_ADD_STORAGE_POOL_WITHOUT_DATA_DOMAIN=Cannot attach Storage Domain.\n\ -Please attach Data Domain to the Data Center first. +ERROR_CANNOT_ADD_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN=Cannot ${action} ${type}.\n\ + The Storage Domain is already attached to a different Data Center and cannot be attcahed to an uninitialized Data Center.\n\ + -Please attach a differenet Data Domain to the Data Center first. ERROR_CANNOT_REMOVE_POOL_WITH_ACTIVE_DOMAINS=Cannot remove Data Center which contains active/locked Storage Domains.\n\ -Please deactivate all domains and wait for tasks to finish before removing the Data Center. VDS_GROUP_CANNOT_CHANGE_STORAGE_POOL=Cannot change Data Center association when editing a Cluster. -- To view, visit http://gerrit.ovirt.org/36454 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I13ec66cc7ff4773221cc994cb4f0be1886ed9a6b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
