Tal Nisan has uploaded a new change for review. Change subject: webadmin: Block add of mixed domain to a pool if not supported by version ......................................................................
webadmin: Block add of mixed domain to a pool if not supported by version When adding a new storage domain via webadmin where the compatibility version does not support mixed storage types we might encounter a situation where the domain is created and the attach to the data center is failing and the setup is left with an unattached domain, to prevent that we now disallow addition from a storage type (block/file) to a data center that does not support mixed types and already have a ttached domains of another storage type (e.g. adding an iSCSI storage domain to a v3.3 data center V3.3 with an NFS domain attached will be prohibited) Change-Id: Ib31884e6fd5a7868e9bb21c9566bcd2e445de52a https://bugzilla.redhat.com/show_bug.cgi?id=1085395 Signed-off-by: Tal Nisan <[email protected]> --- R backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/GetStorageTypesInPoolByPoolIdQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/NewEditStorageModelBehavior.java 4 files changed, 68 insertions(+), 24 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/26983/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/GetStorageTypesInPoolByPoolIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/GetStorageTypesInPoolByPoolIdQuery.java similarity index 92% rename from backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/GetStorageTypesInPoolByPoolIdQuery.java rename to backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/GetStorageTypesInPoolByPoolIdQuery.java index cbe3a87..79be60d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/GetStorageTypesInPoolByPoolIdQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/GetStorageTypesInPoolByPoolIdQuery.java @@ -1,4 +1,4 @@ -package org.ovirt.engine.core; +package org.ovirt.engine.core.bll.storage; import org.ovirt.engine.core.bll.QueriesCommandBase; import org.ovirt.engine.core.common.queries.IdQueryParameters; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java index eda62ec..f6a1ecc 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.java @@ -120,7 +120,8 @@ IsSuspendSupported(ConfigAuthType.User), SerialNumberPolicySupported(ConfigAuthType.User), IscsiMultipathingSupported, - BootMenuSupported(ConfigAuthType.User); + BootMenuSupported(ConfigAuthType.User), + MixedDomainTypesInDataCenter; public static enum ConfigAuthType { Admin, diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index 6d0260e..37ee5c3 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -3603,6 +3603,10 @@ aQuery); } + public static boolean isMixedStorageDomainsSupported(Version version) { + return (Boolean) getConfigValuePreConverted(ConfigurationValues.MixedDomainTypesInDataCenter, version.toString()); + } + private static ArrayList<VDSGroup> getClusterByServiceList(ArrayList<VDSGroup> list, boolean supportsVirtService, boolean supportsGlusterService) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/NewEditStorageModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/NewEditStorageModelBehavior.java index 5930e92..a14019a 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/NewEditStorageModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/NewEditStorageModelBehavior.java @@ -1,9 +1,16 @@ package org.ovirt.engine.ui.uicommonweb.models.storage; +import java.util.List; + import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; +import org.ovirt.engine.core.common.businessentities.StorageType; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; +import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.Linq; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; @@ -66,24 +73,22 @@ public void postUpdateItemsAvailability(IStorageModel item, boolean isNoExportOrIsoStorageAttached) { StoragePool dataCenter = getModel().getDataCenter().getSelectedItem(); - Model model = (Model) item; - boolean isItemSelectable = isItemSelectable(item, dataCenter, isNoExportOrIsoStorageAttached); - model.setIsSelectable(isItemSelectable); - - onStorageModelUpdated(item); + checkCanItemBeSelected(item, dataCenter, isNoExportOrIsoStorageAttached); } - private boolean isItemSelectable(IStorageModel item, StoragePool dataCenter, boolean isNoExportOrIsoStorageAttached) { + private void checkCanItemBeSelected(final IStorageModel item, StoragePool dataCenter, boolean isNoExportOrIsoStorageAttached) { boolean isExistingStorage = getModel().getStorage() != null && item.getType() == getModel().getStorage().getStorageType(); if (isExistingStorage) { - return true; + updateItemSelectability(item, true); + return; } if (isLocalStorage(item) != dataCenter.isLocal()) { - return false; + updateItemSelectability(item, false); + return; } boolean isNoneDataCenter = dataCenter.getId().equals(StorageModel.UnassignedDataCenterId); @@ -91,20 +96,54 @@ if (isNoneDataCenter) { // 'None' Data Center can create only Data Storage Domain - return isDataDomain; - } else { - boolean isExportDomain = item.getRole() == StorageDomainType.ImportExport; - boolean canAttachExportDomain = isNoExportOrIsoStorageAttached && - dataCenter.getStatus() != StoragePoolStatus.Uninitialized; - - boolean isIsoDomain = item.getRole() == StorageDomainType.ISO; - boolean canAttachIsoDomain = isNoExportOrIsoStorageAttached && - dataCenter.getStatus() != StoragePoolStatus.Uninitialized; - - return isExportDomain && canAttachExportDomain || - isIsoDomain && canAttachIsoDomain || - isDataDomain; - + updateItemSelectability(item, isDataDomain); + return; } + + boolean isExportDomain = item.getRole() == StorageDomainType.ImportExport; + boolean canAttachExportDomain = isNoExportOrIsoStorageAttached && + dataCenter.getStatus() != StoragePoolStatus.Uninitialized; + + boolean isIsoDomain = item.getRole() == StorageDomainType.ISO; + boolean canAttachIsoDomain = isNoExportOrIsoStorageAttached && + dataCenter.getStatus() != StoragePoolStatus.Uninitialized; + + if (isExportDomain && canAttachExportDomain || isIsoDomain && canAttachIsoDomain) { + updateItemSelectability(item, true); + return; + } + + if (isDataDomain) { + if (AsyncDataProvider.isMixedStorageDomainsSupported(dataCenter.getcompatibility_version())) { + updateItemSelectability(item, true); + return; + } else { + IdQueryParameters params = new IdQueryParameters(dataCenter.getId()); + Frontend.getInstance().runQuery(VdcQueryType.GetStorageTypesInPoolByPoolId, params, + new AsyncQuery(this, new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object ReturnValue) { + List<StorageType> storageTypes = ((VdcQueryReturnValue) ReturnValue).getReturnValue(); + for (StorageType storageType : storageTypes) { + if (storageType.isBlockDomain() != item.getType().isBlockDomain()) { + updateItemSelectability(item, false); + return; + } + updateItemSelectability(item, true); + return; + } + + } + })); + } + } + + updateItemSelectability(item, false); + } + + private void updateItemSelectability(IStorageModel item, boolean isSelectable) { + Model model = (Model) item; + model.setIsSelectable(isSelectable); + onStorageModelUpdated(item); } } -- To view, visit http://gerrit.ovirt.org/26983 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib31884e6fd5a7868e9bb21c9566bcd2e445de52a 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
