Amit Aviram has uploaded a new change for review. Change subject: core: Template's empty string as a disk alias fix. ......................................................................
core: Template's empty string as a disk alias fix. While making a new template based on a VM, providing the template's allocated disks' alias as an empty string is now disabled. The user should not be able to create a template with disks that have an empty alias. Change-Id: If20fcbe3ae6507ba1f39c6e336928fb647efeb1e Bug-Url: https://bugzilla.redhat.com/1110304 Signed-off-by: Amit Aviram <aavi...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.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, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/97/34597/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index 56969b7..ccd214c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -408,6 +408,10 @@ return false; } + if(!isDisksAliasNotEmpty()) { + return false; + } + if (isInstanceType) { return true; } else { @@ -415,6 +419,16 @@ } } + protected boolean isDisksAliasNotEmpty() { + // Check that all the template's allocated disk's aliases are not an empty string. + for (DiskImage diskImage : diskInfoDestinationMap.values()) { + if (StringUtils.isEmpty(diskImage.getDiskAlias())) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS); + } + } + return true; + } + protected boolean setAndValidateDiskProfiles() { if (diskInfoDestinationMap != null && !diskInfoDestinationMap.isEmpty()) { Map<DiskImage, Guid> map = new HashMap<>(); 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 5180a42..b889d61 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 @@ -226,6 +226,7 @@ ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_CLUSTER_CAN_NOT_BE_EMPTY(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_INSTANCE_TYPE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_IMAGE_TYPE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED(ErrorType.CONFLICT), 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 c23dc88..f5b0f5b 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -247,6 +247,7 @@ ACTION_TYPE_FAILED_IMAGE_TYPE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Image Type doesn't exist. ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. ACTION_TYPE_FAILED_TEMPLATE_NOT_EXISTS_IN_CURRENT_DC=The specified Template doesn't exist in the current Data Center. +ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS=Cannot ${action} ${type} with an empty disk alias. ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS=Cannot ${action} ${type}. One of the Template Images already exists. ACTION_TYPE_FAILED_TEMPLATE_GUID_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same identifier already exists. ACTION_TYPE_FAILED_CANDIDATE_ALREADY_EXISTS=Cannot ${action} ${type}. The export candidate already exists in the specified path.\n\ 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 a76e961..4f03281 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 @@ -658,6 +658,9 @@ @DefaultStringValue("Cannot ${action} ${type}. Only the first template version can be selected as the base template.") String ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE(); + @DefaultStringValue("Cannot ${action} ${type} with an empty disk alias.") + String ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS(); + @DefaultStringValue("Cannot ${action} ${type}. The relevant Instance Type doesn't exist.") String ACTION_TYPE_FAILED_INSTANCE_TYPE_DOES_NOT_EXIST(); 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 50e979b..fdaae4b 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 @@ -233,6 +233,7 @@ ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Template doesn't exist. ACTION_TYPE_FAILED_CLUSTER_CAN_NOT_BE_EMPTY=Cannot ${action} ${type}. The relevant Cluster doesn't exist. ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE=Cannot ${action} ${type}. Only the first template version can be selected as the base template. +ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS=Cannot ${action} ${type} with an empty disk alias. ACTION_TYPE_FAILED_INSTANCE_TYPE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Instance Type doesn't exist. ACTION_TYPE_FAILED_IMAGE_TYPE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Image Type doesn't exist. ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. 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 b292fb3..db32cd4 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 @@ -240,6 +240,7 @@ ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Template doesn't exist. ACTION_TYPE_FAILED_CLUSTER_CAN_NOT_BE_EMPTY=Cannot ${action} ${type}. The relevant Cluster doesn't exist. ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE=Cannot ${action} ${type}. Only the first template version can be selected as the base template. +ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS=Cannot ${action} ${type} with an empty disk alias. ACTION_TYPE_FAILED_INSTANCE_TYPE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Instance Type doesn't exist. ACTION_TYPE_FAILED_IMAGE_TYPE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Image Type doesn't exist. ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. -- To view, visit http://gerrit.ovirt.org/34597 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If20fcbe3ae6507ba1f39c6e336928fb647efeb1e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Amit Aviram <aavi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches