Maor Lipchuk has uploaded a new change for review.

Change subject: core: Detach storage domain when remove Storage Pool.
......................................................................

core: Detach storage domain when remove Storage Pool.

Allow to remove storage pool even if there is a Storage Domain which
contains VMs and disks.

Change-Id: I120c6b001a197e65528edb73375b379f76d24cd5
Signed-off-by: Maor Lipchuk <mlipc...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.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, 3 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/27307/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.java
index fe353d9..97bec98 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.java
@@ -13,7 +13,6 @@
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.network.ExternalNetworkManager;
 import org.ovirt.engine.core.bll.network.MacPoolManager;
-import org.ovirt.engine.core.bll.validator.StorageDomainValidator;
 import org.ovirt.engine.core.common.AuditLogType;
 import 
org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters;
 import org.ovirt.engine.core.common.action.RemoveStorageDomainParameters;
@@ -27,7 +26,6 @@
 import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
-import org.ovirt.engine.core.common.businessentities.VmStatic;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.businessentities.network.VmNic;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
@@ -146,7 +144,6 @@
             }
         });
         final StorageDomain masterDomain = LinqUtils.first(temp);
-
         TransactionSupport.executeInNewTransaction(new 
TransactionMethod<Void>() {
 
             @Override
@@ -167,6 +164,7 @@
 
         List<VDS> vdss = getAllRunningVdssInPool();
         for (StorageDomain storageDomain : storageDomains) {
+            detachStorageDomainWithEntities(storageDomain);
             if (storageDomain.getStorageDomainType() != 
StorageDomainType.Master) {
                 if (!removeDomainFromPool(storageDomain, vdss.get(0))) {
                     log.errorFormat("Unable to detach storage domain {0} {1}",
@@ -325,18 +323,8 @@
             if(poolDomains.size() > 1) {
                 return 
failCanDoAction(VdcBllMessages.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS);
             }
-            for (StorageDomain domain : poolDomains) {
-                // check that there are no images on data domains
-                if (domain.getStorageDomainType().isDataDomain()) {
-                    StorageDomainValidator storageDomainValidator = new 
StorageDomainValidator(domain);
-                    if 
(!validate(storageDomainValidator.isDomainHasNoImages(VdcBllMessages.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES,
 true))) {
-                        return false;
-                    }
-                }
-            }
-            final List<VmStatic> vms = 
getVmStaticDAO().getAllByStoragePoolId(getStoragePool().getId());
-            if (!vms.isEmpty()) {
-                return 
failCanDoAction(VdcBllMessages.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS);
+            if (!canDetachStorageDomainWithVmsAndDisks(poolDomains.get(0))) {
+                return false;
             }
         } else {
             List<VDS> poolHosts = 
getVdsDAO().getAllForStoragePool(getParameters().getStoragePoolId());
@@ -355,7 +343,6 @@
                 }
             }
         }
-
         return true;
     }
 
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 c20d870..2f234d3 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
@@ -595,8 +595,6 @@
     ERROR_CANNOT_CHANGE_STORAGE_POOL_TYPE_WITH_DOMAINS(ErrorType.CONFLICT),
     ERROR_CANNOT_EXTEND_CONNECTION_FAILED(ErrorType.CONFLICT),
     ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS(ErrorType.BAD_PARAMETERS),
-    ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES(ErrorType.CONFLICT),
-    ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS(ErrorType.CONFLICT),
     
ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS(ErrorType.CONFLICT),
     
ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE(ErrorType.CONFLICT),
     
ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS(ErrorType.INCOMPATIBLE_VERSION),
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 b963148..f54f76a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -474,10 +474,6 @@
 ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL=Cannot ${action} 
${type}. The selected Storage Domain is not part of the Data Center.
 ACTION_TYPE_FAILED_LUNS_ALREADY_PART_OF_STORAGE_DOMAINS=Cannot ${action} 
${type}. The following LUNs are already part of existing storage domains: 
${lunIds}.
 ACTION_TYPE_FAILED_LUNS_ALREADY_USED_BY_DISKS=Cannot ${action} ${type}. The 
following LUNs are already used by DirectLUN disks: ${lunIds}.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES=Cannot remove Data Center while 
it contains disks.\n\
-       -Please remove them first.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS=Cannot remove Data Center while 
there are VMs on it.\n\
-       -Please remove all VMs and Templates first.
 ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS=Cannot remove Data 
Center while there are more than one Storage Domain attached.
 ERROR_CANNOT_REMOVE_STORAGE_DOMAIN_DO_FORMAT=Cannot remove Storage Domain. 
Data storage must be formatted after remove.\n\
        -Please verify that Format option is enabled on the Data Domain.
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 6c3317e..7d4ddb1 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
@@ -1315,12 +1315,6 @@
     @DefaultStringValue("Cannot detach a non empty Storage Domain.\n-Please 
remove all VMs / Templates / Disks and try again.")
     String ERROR_CANNOT_DETACH_STORAGE_DOMAIN_WITH_IMAGES();
 
-    @DefaultStringValue("Cannot remove Data Center while it contains 
disks.\n-Please remove them first.")
-    String ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES();
-
-    @DefaultStringValue("Cannot remove Data Center while there are VMs on 
it.\n-Please remove all VMs and Templates first.")
-    String ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS();
-
     @DefaultStringValue("Cannot remove Data Center while there are more than 
one Storage Domains attached.")
     String ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_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 5e3ef68..60df2ad 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
@@ -445,10 +445,6 @@
 ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL=Cannot ${action} 
${type}. The selected Storage Domain is not part of the Data Center.
 ACTION_TYPE_FAILED_LUNS_ALREADY_PART_OF_STORAGE_DOMAINS=Cannot ${action} 
${type}. The following LUNs are already part of existing storage domains: 
${lunIds}.
 ACTION_TYPE_FAILED_LUNS_ALREADY_USED_BY_DISKS=Cannot ${action} ${type}. The 
following LUNs are already used by DirectLUN disks: ${lunIds}.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES=Cannot remove Data Center while 
it contains disks.\n\
-       -Please remove them first.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS=Cannot remove Data Center while 
there are VMs on it.\n\
-       -Please remove all VMs and Templates first.
 ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS=Cannot remove Data 
Center when there are more than one Storage Domain attached.
 ERROR_CANNOT_REMOVE_STORAGE_DOMAIN_DO_FORMAT=Cannot remove Storage Domain. 
Data storage must be formatted after remove.\n\
        -Please verify that Format option is enabled on the Data Domain.
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 e1a0bf7..c45954c 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
@@ -479,10 +479,6 @@
 ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL=Cannot ${action} 
${type}. The selected Storage Domain is not part of the Data Center.
 ACTION_TYPE_FAILED_LUNS_ALREADY_PART_OF_STORAGE_DOMAINS=Cannot ${action} 
${type}. The following LUNs are already part of existing storage domains: 
${lunIds}.
 ACTION_TYPE_FAILED_LUNS_ALREADY_USED_BY_DISKS=Cannot ${action} ${type}. The 
following LUNs are already used by DirectLUN disks: ${lunIds}.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES=Cannot remove Data Center while 
it contains disks.\n\
-       -Please remove them first.
-ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS=Cannot remove Data Center while 
there are VMs on it.\n\
-       -Please remove all VMs and Templates first.
 ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS=Cannot remove Data 
Center when there are more than one Storage Domain attached.
 ERROR_CANNOT_REMOVE_STORAGE_DOMAIN_DO_FORMAT=Cannot remove Storage Domain. 
Data storage must be formatted after remove.\n\
        -Please verify that Format option is enabled on the Data Domain.


-- 
To view, visit http://gerrit.ovirt.org/27307
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I120c6b001a197e65528edb73375b379f76d24cd5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to