Tal Nisan has uploaded a new change for review. Change subject: core: Block import of storage domain if the storage contains hosted engine ......................................................................
core: Block import of storage domain if the storage contains hosted engine Block an import of a storage domain that contains the hosted engine by the it's storage name defined in the configuration value named HOSTED_ENGINE_STORAGE_DOMAIN_NAME Change-Id: I36db8c4a7a1d13be8874407c56596ecd9ab74333 Bug-Url: https://bugzilla.redhat.com/1177247 Signed-off-by: Tal Nisan <tni...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/StorageDomainValidator.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommandTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/ConfigurationValues.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 13 files changed, 68 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/49/36549/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommand.java index c34ce27..f770680 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommand.java @@ -7,6 +7,7 @@ import org.apache.commons.collections.CollectionUtils; import org.ovirt.engine.core.bll.LockMessagesMatchUtil; +import org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator; import org.ovirt.engine.core.common.action.LockProperties; import org.ovirt.engine.core.common.action.StorageDomainManagementParameter; import org.ovirt.engine.core.common.businessentities.Entities; @@ -53,6 +54,11 @@ @Override protected boolean canAddDomain() { + StorageDomainValidator validator = new StorageDomainValidator(getStorageDomain()); + if (!validate(validator.isHostedEngineStorage())) { + return false; + } + if (getStorageDomainStaticDAO().get(getStorageDomain().getId()) != null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_EXIST); } @@ -64,6 +70,7 @@ getStorageDomain().getStorage()); return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_IMPORT_STORAGE_DOMAIN_EXTERNAL_LUN_DISK_EXIST); } + return true; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommand.java index edf0559..61ee702 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommand.java @@ -2,6 +2,7 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.Backend; +import org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator; import org.ovirt.engine.core.common.action.StorageDomainManagementParameter; import org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; @@ -62,6 +63,11 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST); } + StorageDomainValidator validator = new StorageDomainValidator(getStorageDomain()); + if (!validate(validator.isHostedEngineStorage())) { + return false; + } + return concreteCheckExistingStorageDomain(domainFromIrs); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/StorageDomainValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/StorageDomainValidator.java index 6c777a4..ae5a529 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/StorageDomainValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/storage/StorageDomainValidator.java @@ -250,4 +250,11 @@ return ValidationResult.VALID; } + + public ValidationResult isHostedEngineStorage() { + if (Config.getValue(ConfigValues.HostedEngineStorageDomainName).equals(storageDomain.getName())) { + return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE); + } + return ValidationResult.VALID; + } } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommandTest.java index 148f52c..66e39da 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingBlockStorageDomainCommandTest.java @@ -8,28 +8,39 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; +import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig; import java.util.ArrayList; import java.util.List; import org.junit.Before; +import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.ovirt.engine.core.bll.CanDoActionTestUtils; import org.ovirt.engine.core.common.action.StorageDomainManagementParameter; import org.ovirt.engine.core.common.businessentities.LUNs; import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; +import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.constants.StorageConstants; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dao.StorageDomainStaticDAO; +import org.ovirt.engine.core.utils.MockConfigRule; @RunWith(MockitoJUnitRunner.class) public class AddExistingBlockStorageDomainCommandTest { private AddExistingBlockStorageDomainCommand<StorageDomainManagementParameter> command; private StorageDomainManagementParameter parameters; + + @ClassRule + public static MockConfigRule mcr = new MockConfigRule( + mockConfig(ConfigValues.HostedEngineStorageDomainName, StorageConstants.HOSTED_ENGINE_STORAGE_DOMAIN_NAME) + ); @Mock private DbFacade dbFacade; @@ -68,6 +79,13 @@ .contains(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_EXIST.toString())); } + @Test + public void testAddHostedEngineStorageFails() { + parameters.getStorageDomain().setStorageName(StorageConstants.HOSTED_ENGINE_STORAGE_DOMAIN_NAME); + assertFalse(command.canAddDomain()); + CanDoActionTestUtils.assertCanDoActionMessages("", command, VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE); + } + private static StorageDomainStatic getStorageDomain() { StorageDomainStatic storageDomain = new StorageDomainStatic(); storageDomain.setStorage(Guid.newGuid().toString()); diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommandTest.java index 205a106..1167a0c 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/AddExistingFileStorageDomainCommandTest.java @@ -27,6 +27,7 @@ import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.constants.StorageConstants; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters; @@ -36,6 +37,7 @@ import org.ovirt.engine.core.dao.StorageDomainStaticDAO; import org.ovirt.engine.core.dao.StoragePoolDAO; import org.ovirt.engine.core.dao.VdsDAO; +import org.ovirt.engine.core.utils.ConfigUtilsBase; import org.ovirt.engine.core.utils.MockConfigRule; @RunWith(MockitoJUnitRunner.class) @@ -50,7 +52,8 @@ public static MockConfigRule mcr = new MockConfigRule( mockConfig(ConfigValues.StorageDomainNameSizeLimit, SD_MAX_NAME_LENGTH), mockConfig(ConfigValues.SupportedStorageFormats, Version.v3_4.toString(), "3"), - mockConfig(ConfigValues.SupportedStorageFormats, Version.v3_5.toString(), "3") + mockConfig(ConfigValues.SupportedStorageFormats, Version.v3_5.toString(), "3"), + mockConfig(ConfigValues.HostedEngineStorageDomainName, StorageConstants.HOSTED_ENGINE_STORAGE_DOMAIN_NAME) ); @Mock @@ -129,6 +132,18 @@ CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command); } + @Test + public void testAddHostedEngineStorageFails() { + parameters.getStorageDomain().setStorageName(StorageConstants.HOSTED_ENGINE_STORAGE_DOMAIN_NAME); + + when(command.getStorageDomainStaticDAO().get(any(Guid.class))).thenReturn(null); + + StorageDomainStatic sdStatic = command.getStorageDomain().getStorageStaticData(); + doReturn(new Pair<>(sdStatic, sdStatic.getId())).when(command).executeHSMGetStorageDomainInfo( + any(HSMGetStorageDomainInfoVDSCommandParameters.class)); + + CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, VdcBllMessages.ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE); + } private static StorageDomainStatic getStorageDomain() { StorageDomainStatic storageDomain = new StorageDomainStatic(); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java index f0adc8e..19e04f4 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java @@ -7,6 +7,7 @@ import org.ovirt.engine.core.common.EngineWorkingMode; import org.ovirt.engine.core.common.businessentities.SerialNumberPolicy; +import org.ovirt.engine.core.common.constants.StorageConstants; public enum ConfigValues { @Reloadable @@ -1657,6 +1658,10 @@ @DefaultValueAttribute("true") ImportDataStorageDomain, + @TypeConverterAttribute(String.class) + @DefaultValueAttribute(StorageConstants.HOSTED_ENGINE_STORAGE_DOMAIN_NAME) + HostedEngineStorageDomainName, + @TypeConverterAttribute(Boolean.class) @DefaultValueAttribute("true") VirtIoRngDeviceSupported, diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java index 31be55e..187023b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/StorageConstants.java @@ -5,4 +5,5 @@ public static final int OVF_MAX_ITEMS_PER_SQL_STATEMENT = 100; public static final String HOSTED_ENGINE_LUN_DISK_ALIAS = "hosted_engine"; + public static final String HOSTED_ENGINE_STORAGE_DOMAIN_NAME= "hosted_storage"; } 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 297e153..d9e7507 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 @@ -208,6 +208,7 @@ ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS(ErrorType.CONFLICT), ACTION_TYPE_FAILED_DISK_LUN_INVALID(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK(ErrorType.CONFLICT), + ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_UNSUPPORTED_DISK_STORAGE_TYPE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_DOMAIN_UNAVAILABLE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED(ErrorType.BAD_PARAMETERS), 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 186dfb3..53480ec 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 @@ -53,6 +53,7 @@ VmPriorityMaxValue(ConfigAuthType.User), StorageDomainNameSizeLimit(ConfigAuthType.User), ImportDataStorageDomain, + HostEngineStorageDomainName, StoragePoolNameSizeLimit(ConfigAuthType.User), SANWipeAfterDelete(ConfigAuthType.User), AuthenticationMethod(ConfigAuthType.User), 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 43c2193..6da90c0 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -225,6 +225,7 @@ ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk contains the hosted engine. +ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE=Cannot ${action} ${type}. The storage selected contains the hosted engine. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. ACTION_TYPE_FAILED_DESTINATION_HOST_NOT_IN_DESTINATION_CLUSTER=Cannot ${action} ${type}. Destination host is not present in destination 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 1ca5952..a3f9860 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 @@ -613,6 +613,9 @@ @DefaultStringValue("Cannot ${action} ${type}. The disk contains the hosted engine.") String ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK(); + @DefaultStringValue("Cannot ${action} ${type}. The storage selected contains the hosted engine.") + String ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE(); + @DefaultStringValue("Cannot ${action} ${type}. source and destination is the same.") String ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST(); 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 23c3cde..9ac7fa9 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 @@ -210,6 +210,7 @@ ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk contains the hosted engine. +ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE=Cannot ${action} ${type}. The storage selected contains the hosted engine. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. ACTION_TYPE_FAILED_DESTINATION_HOST_NOT_IN_DESTINATION_CLUSTER=Cannot ${action} ${type}. Destination host is not present in destination 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 a102ceb..4fc4f63 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 @@ -221,6 +221,7 @@ ACTION_TYPE_FAILED_DISK_LUN_ISCSI_MISSING_CONNECTION_PARAMS=Cannot ${action} ${type}. The provided lun is missing at least one connection parameter (address/port/iqn). ACTION_TYPE_FAILED_DISK_LUN_INVALID=Cannot ${action} ${type}. The provided LUN is not visible by the specified host, please check storage server connectivity. ACTION_TYPE_FAILED_HOSTED_ENGINE_DISK=Cannot ${action} ${type}. The disk contains the hosted engine. +ACTION_TYPE_FAILED_HOSTED_ENGINE_STORAGE=Cannot ${action} ${type}. The storage selected contains the hosted engine. ACTION_TYPE_FAILED_DISK_LUN_IS_ALREADY_IN_USE=Cannot ${action} ${type}. The provided lun is used by another disk. ACTION_TYPE_FAILED_MIGRATION_IN_PROGRESS=Cannot ${action} ${type}. VM migration is in progress ACTION_TYPE_FAILED_MIGRATION_TO_SAME_HOST=Cannot ${action} ${type}. source and destination is the same. -- To view, visit http://gerrit.ovirt.org/36549 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I36db8c4a7a1d13be8874407c56596ecd9ab74333 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <tni...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches