Tal Nisan has uploaded a new change for review. Change subject: core: Disallow from remove of a DC when not all hosts are in maintenance (#850286) ......................................................................
core: Disallow from remove of a DC when not all hosts are in maintenance (#850286) When trying to force remove a Data Center when not all it's hosts are in maintenance mode, fail the CanDoAction Change-Id: I88e2938d4c1b02065b330929e15c579f714e4385 Bug-Url: https://bugzilla.redhat.com/850286 Signed-off-by: Tal Nisan <tni...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStoragePoolCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/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, 20 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/9110/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 b82ed25..cc1fef1 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,13 +13,14 @@ import org.ovirt.engine.core.common.action.RemoveStorageDomainParameters; import org.ovirt.engine.core.common.action.StoragePoolParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.businessentities.Network; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; 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; import org.ovirt.engine.core.common.businessentities.storage_domains; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.errors.VdcBLLException; @@ -325,6 +326,17 @@ return failCanDoAction(VdcBllMessages.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS); } } + else { + List<VDS> poolHosts = + DbFacade.getInstance().getVdsDao().getAllForStoragePool(getParameters().getStoragePoolId()); + if (poolHosts != null && !poolHosts.isEmpty()) { + for (VDS host : poolHosts) { + if (host.getstatus() != VDSStatus.Maintenance) { + return failCanDoAction(VdcBllMessages.ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE); + } + } + } + } return true; } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 7095af6..19a5572 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -458,6 +458,7 @@ ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_IMAGES, ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_VMS, ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS, + ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE, ERROR_CANNOT_UPDATE_STORAGE_POOL_COMPATIBILITY_VERSION_BIGGER_THAN_CLUSTERS, ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL, ERROR_CANNOT_ADD_DEPRECATED_EXISTING_SAN_EXPORT_STORAGE_DOMAIN, 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 e39b835..c1373bc 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -352,6 +352,7 @@ 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. +ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE=Cannot ${action} ${type} while there are Hosts which are not in Maintenance mode. ACTION_TYPE_FAILED_STORAGE_POOL_STATUS_ILLEGAL=Cannot ${action} ${type}. Unknown Data Center status. NETWORK_BOND_NAME_EXISTS=Bond name already exists. NETWORK_BOND_NOT_EXISTS=Bond name doesn't exist. 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 da53061..24bfa0c 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 @@ -949,6 +949,9 @@ @DefaultStringValue("Cannot remove Storage Domain. Data storage must be formatted after remove.\n-Please verify that Format option is enabled on the Data Domain.") String ERROR_CANNOT_REMOVE_STORAGE_DOMAIN_DO_FORMAT(); + @DefaultStringValue("Cannot ${action} ${type} while there are Hosts which are not in Maintenance mode.") + String ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE(); + @DefaultStringValue("Cannot ${action} ${type}. Unknown Data Center status.") String ACTION_TYPE_FAILED_STORAGE_POOL_STATUS_ILLEGAL(); 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 86194a7..c245201 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 @@ -348,6 +348,7 @@ 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. +ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE=Cannot ${action} ${type} while there are Hosts which are not in Maintenance mode. ACTION_TYPE_FAILED_STORAGE_POOL_STATUS_ILLEGAL=Cannot ${action} ${type}. Unknown Data Center status. NETWORK_BOND_NAME_EXISTS=Bond name already exists. NETWORK_BOND_NOT_EXISTS=Bond name doesn't exist. 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 2c729ff..11e4492 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 @@ -346,6 +346,7 @@ 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. +ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE=Cannot ${action} ${type} while there are Hosts which are not in Maintenance mode. ACTION_TYPE_FAILED_STORAGE_POOL_STATUS_ILLEGAL=Cannot ${action} ${type}. Unknown Data Center status. NETWORK_BOND_NAME_EXISTS=Bond name already exists. NETWORK_BOND_NOT_EXISTS=Bond name doesn't exist. -- To view, visit http://gerrit.ovirt.org/9110 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I88e2938d4c1b02065b330929e15c579f714e4385 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