Eldan Shachar has uploaded a new change for review. Change subject: core: Fix CDA for AddVmCommand ......................................................................
core: Fix CDA for AddVmCommand The command allowed a user to add a VM using REST before the DC was initialized, this VM caused problems in some flows. Added a check for the storage pool status that will cause the command to fail when the DC is down. Change-Id: I2586b0026c85f053b6cd0aebeb555d760afc0937 Bug-Url: https://bugzilla.redhat.com/1157229 Signed-off-by: Eldan Shachar <eshac...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmCommandTest.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 7 files changed, 14 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/35454/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index b25a036..b63efa9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -51,6 +51,7 @@ import org.ovirt.engine.core.common.businessentities.OriginType; import org.ovirt.engine.core.common.businessentities.Permissions; import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; @@ -470,6 +471,10 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST); } + if (getStoragePool().getStatus() != StoragePoolStatus.Up) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE); + } + if (!isTemplateInValidDc()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_NOT_EXISTS_IN_CURRENT_DC); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmCommandTest.java index 049cf6b..980076d 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmCommandTest.java @@ -49,6 +49,7 @@ import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; 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.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmDynamic; @@ -515,6 +516,7 @@ if (storagePool == null) { storagePool = new StoragePool(); storagePool.setId(STORAGE_POOL_ID); + storagePool.setStatus(StoragePoolStatus.Up); } return storagePool; } 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 159bf40..e773017 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 @@ -585,6 +585,7 @@ ACTION_TYPE_FAILED_LUNS_ALREADY_PART_OF_STORAGE_DOMAINS(ErrorType.CONFLICT), ACTION_TYPE_FAILED_LUNS_ALREADY_USED_BY_DISKS(ErrorType.CONFLICT), ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_STORAGE_CONNECTION_FOR_DOMAIN_NOT_EXIST(ErrorType.BAD_PARAMETERS), 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 5280d81..1f9d82f 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -490,6 +490,7 @@ STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN = Cannot ${action} ${type}.\n\ The ${action} action can be performed on a Data Center that has only one Storage Domain in Active/Unknown state. ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST= Data Center doesn't exist. +ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE=The Storage Pool for the required Data Center is not active. 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}. 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 67ffa82..d326c6e 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 @@ -1354,6 +1354,9 @@ @DefaultStringValue(" Data Center doesn't exist.") String ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST(); + @DefaultStringValue("The Storage Pool for the required Data Center is not active.") + String ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE(); + @DefaultStringValue("Cannot ${action} ${type}. The selected Storage Domain is not part of the Data Center.") String ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL(); 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 1b16029..24861b1 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 @@ -448,6 +448,7 @@ STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN = Cannot ${action} ${type}.\n\ The ${action} action can be performed on a Data Center that has only one Storage Domain in Active/Unknown state. ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST= Data Center doesn't exist. +ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE=The Storage Pool for the required Data Center is not active. 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}. 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 eb2d3f5..6f773a4 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 @@ -493,6 +493,7 @@ STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN = Cannot ${action} ${type}.\n\ The ${action} action can be performed on a Data Center that has only one Storage Domain in Active/Unknown state. ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST= Data Center doesn't exist. +ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE=The Storage Pool for the required Data Center is not active. 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}. -- To view, visit http://gerrit.ovirt.org/35454 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2586b0026c85f053b6cd0aebeb555d760afc0937 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eldan Shachar <eshac...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches