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
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 <[email protected]>
---
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/StorageDomainValidator.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
11 files changed, 43 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/36554/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 27c4100..6198adc3 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;
@@ -56,16 +57,25 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_EXIST);
         }
 
+        StorageDomainValidator validator = new 
StorageDomainValidator(getStorageDomain());
+        if (!validate(validator.isHostedEngineStorage())) {
+            return false;
+        }
+
         List<LUNs> lunsOnStorage = 
getLUNsFromVgInfo(getStorageDomain().getStorage());
-        if (CollectionUtils.containsAny(Entities.getIds(lunsOnStorage),
-                Entities.getIds(getDbFacade().getLunDao().getAll()))) {
+        if (CollectionUtils.containsAny(Entities.getIds(lunsOnStorage), 
Entities.getIds(getAllLuns()))) {
             log.infoFormat("There are existing luns in the system which are 
part of VG id '{0}'",
                     getStorageDomain().getStorage());
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_IMPORT_STORAGE_DOMAIN_EXTERNAL_LUN_DISK_EXIST);
         }
+
         return true;
     }
 
+    protected List<LUNs> getAllLuns() {
+        return getDbFacade().getLunDao().getAll();
+    }
+
     @Override
     protected LockProperties applyLockProperties(LockProperties 
lockProperties) {
         return lockProperties.withScope(LockProperties.Scope.Execution);
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 5429e10..e52422f 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,9 +2,11 @@
 
 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;
+import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatic;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.utils.Pair;
@@ -61,6 +63,14 @@
         if (domainFromIrs == null) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST);
         }
+
+        StorageDomain storageDomainFromIrs = new StorageDomain();
+        storageDomainFromIrs.setStorageStaticData(domainFromIrs.getFirst());
+        StorageDomainValidator validator = new 
StorageDomainValidator(storageDomainFromIrs);
+        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/StorageDomainValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java
index d5dd2c0..1ee8230 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java
@@ -306,4 +306,11 @@
     private static interface SizeAssessment {
         public double getSizeForDisk(DiskImage diskImage);
     }
+
+    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/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 45b15e9..0b19ce0 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
@@ -1691,6 +1692,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 8b4e79f..2fb273b 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
@@ -206,6 +206,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 eb4b98e..faee03e 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,
+    HostedEngineStorageDomainName,
     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 48f0525..053dd22 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -218,6 +218,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 self 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 11330d2..9246e79 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
@@ -592,6 +592,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 self 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 6f779e0..1e4858a 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 self 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 600a16e..f7bb49f 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
@@ -215,6 +215,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 self 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/36554
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36db8c4a7a1d13be8874407c56596ecd9ab74333
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Tal Nisan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to