Omer Frenkel has uploaded a new change for review. Change subject: core, webadmin: remove name from template version ......................................................................
core, webadmin: remove name from template version >From now, the template.name for template versions will be the name of the base template, and template versions will only use the version name. in this patch: - backend: make sure name of template version is the same as the name of the base template (ie. allow duplicate name for template base and its versions). - UI: disable 'name' field on new template dialog for versions, this field will show the seleceted base name. - UI: template grid - show 'version_name (version_number)' instead of 'name (version_name)' Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1075074 Change-Id: I27f26e7d196d1d2eebfe86e8aac886f3e6a8fc5e Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.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/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmMakeTemplatePopupWidget.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabTemplateView.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties A packaging/dbscripts/upgrade/03_05_0170_update_template_version_naming.sql 14 files changed, 80 insertions(+), 25 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/26270/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 b79f310..5f7210b 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 @@ -316,7 +316,7 @@ return false; } - if (isVmTemlateWithSameNameExist(getVmTemplateName())) { + if (!isTemplateVersion() && isVmTemlateWithSameNameExist(getVmTemplateName())) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); return false; } @@ -368,6 +368,10 @@ return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE); } + // template version name should be the same as the base template name + else { + setVmTemplateName(userSelectedBaseTemplate.getName()); + } } return imagesRelatedChecks() && AddVmCommand.checkCpuSockets(getParameters().getMasterVm().getNumOfSockets(), diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java index abc5c23..66c086a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java @@ -169,7 +169,7 @@ getReturnValue().getCanDoActionMessages().add( String.format("$TemplateName %1$s", duplicateTemplate.getName())); retVal = false; - } else if (isVmTemplateWithSameNameExist()) { + } else if (getVmTemplate().isBaseTemplate() && isVmTemplateWithSameNameExist()) { addCanDoActionMessage(VdcBllMessages.VM_CANNOT_IMPORT_TEMPLATE_NAME_EXISTS); retVal = false; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java index d4f59a8..d6c11c1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java @@ -67,18 +67,21 @@ return failCanDoAction(VdcBllMessages.VM_TEMPLATE_IS_LOCKED); } - if (!StringUtils.equals(mOldTemplate.getName(), getVmTemplate().getName()) - && isVmTemlateWithSameNameExist(getVmTemplateName())) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); - } else { - if (getVdsGroup() == null) { - addCanDoActionMessage(VdcBllMessages.VMT_CLUSTER_IS_NOT_VALID); - } else if (isVmPriorityValueLegal(getParameters().getVmTemplateData().getPriority(), getReturnValue() - .getCanDoActionMessages()) && checkDomain()) { - returnValue = VmTemplateHandler.isUpdateValid(mOldTemplate, getVmTemplate()); - if (!returnValue) { - addCanDoActionMessage(VdcBllMessages.VMT_CANNOT_UPDATE_ILLEGAL_FIELD); - } + if (!StringUtils.equals(mOldTemplate.getName(), getVmTemplate().getName())) { + if (!getVmTemplate().isBaseTemplate()) { + // template version should always have the name of the base template + return failCanDoAction(VdcBllMessages.VMT_CANNOT_UPDATE_VERSION_NAME); + } else if (isVmTemlateWithSameNameExist(getVmTemplateName())) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); + } + } + if (getVdsGroup() == null) { + addCanDoActionMessage(VdcBllMessages.VMT_CLUSTER_IS_NOT_VALID); + } else if (isVmPriorityValueLegal(getParameters().getVmTemplateData().getPriority(), getReturnValue() + .getCanDoActionMessages()) && checkDomain()) { + returnValue = VmTemplateHandler.isUpdateValid(mOldTemplate, getVmTemplate()); + if (!returnValue) { + addCanDoActionMessage(VdcBllMessages.VMT_CANNOT_UPDATE_ILLEGAL_FIELD); } } 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 fb4db9a..951cd6c 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 @@ -386,6 +386,7 @@ VMT_CANNOT_EDIT_BLANK_TEMPLATE(ErrorType.CONFLICT), VMT_CANNOT_EXPORT_BLANK_TEMPLATE(ErrorType.CONFLICT), VMT_CANNOT_UPDATE_ILLEGAL_FIELD(ErrorType.BAD_PARAMETERS), + VMT_CANNOT_UPDATE_VERSION_NAME(ErrorType.BAD_PARAMETERS), VMT_CANNOT_REMOVE_VDS_GROUP_VMTS_DETECTED(ErrorType.CONFLICT), VMT_CANNOT_CREATE_DUPLICATE_NAME(ErrorType.CONFLICT), VMT_CLUSTER_IS_NOT_VALID(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 45e374a..ad4125b 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -140,6 +140,7 @@ VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank Template is not allowed. VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template. VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM template. +VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Template Version, Only the Version name can be updated. DIRECTORY_GROUP_CANNOT_REMOVE_DIRECTORY_GROUP_ATTACHED_TO_VM=Cannot remove Directory Group. Detach Directory Group from VM first. VM_NOT_FOUND=VM not found ACTION_TYPE_FAILED_CLUSTER_UNDEFINED_ARCHITECTURE=Cannot ${action} ${type}. The cluster does not have a defined architecture. 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 8cfd94f..65945af 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 @@ -361,6 +361,9 @@ @DefaultStringValue("Failed updating the properties of the VM template.") String VMT_CANNOT_UPDATE_ILLEGAL_FIELD(); + @DefaultStringValue("Cannot update the name of Template Version, Only the Version name can be updated.") + String VMT_CANNOT_UPDATE_VERSION_NAME(); + @DefaultStringValue("Cannot remove Directory Group. Detach Directory Group from VM first.") String DIRECTORY_GROUP_CANNOT_REMOVE_DIRECTORY_GROUP_ATTACHED_TO_VM(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmMakeTemplatePopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmMakeTemplatePopupWidget.java index 48501a6..dfc9a0d 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmMakeTemplatePopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmMakeTemplatePopupWidget.java @@ -244,6 +244,24 @@ @Override public void eventRaised(Event ev, Object sender, EventArgs args) { subTemplateExpanderContent.setVisible(model.getIsSubTemplate().getEntity()); + nameEditor.setEnabled(!model.getIsSubTemplate().getEntity()); + if (!model.getIsSubTemplate().getEntity()) { + model.getName().setEntity(""); + } else { + // copy any entered name to be the template-version name + model.getTemplateVersionName().setEntity(model.getName().getEntity()); + model.getName().setEntity(model.getBaseTemplate().getSelectedItem().getName()); + } + } + }); + + model.getBaseTemplate().getSelectedItemChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + if (model.getBaseTemplate().getSelectedItem() != null && model.getIsSubTemplate().getEntity()) { + // template.name for version should be the same as the base template name + model.getName().setEntity(model.getBaseTemplate().getSelectedItem().getName()); + } } }); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java index d47fdad..79e474e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java @@ -551,17 +551,22 @@ String name = model.getName().getEntity(); - AsyncDataProvider.isTemplateNameUnique(new AsyncQuery(this, - new INewAsyncCallback() { - @Override - public void onSuccess(Object target, Object returnValue) { + if (((TemplateVmModelBehavior) model.getBehavior()).getVmTemplate().isBaseTemplate()) { - TemplateListModel templateListModel = (TemplateListModel) target; - boolean isNameUnique = (Boolean) returnValue; - templateListModel.postNameUniqueCheck(isNameUnique); + AsyncDataProvider.isTemplateNameUnique(new AsyncQuery(this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object target, Object returnValue) { - } - }), name); + TemplateListModel templateListModel = (TemplateListModel) target; + boolean isNameUnique = (Boolean) returnValue; + templateListModel.postNameUniqueCheck(isNameUnique); + + } + }), name); + } else { + postNameUniqueCheck(true); + } } public void postNameUniqueCheck(boolean isNameUnique) diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java index f1de82a..4a41138 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java @@ -560,6 +560,9 @@ { model.setIsValid(false); } + else if (model.getIsSubTemplate().getEntity()) { + postNameUniqueCheck(this); + } else { model.startProgress(null); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index 02cab3d..f43ff17 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -1326,6 +1326,9 @@ { model.setIsValid(false); } + else if (model.getIsSubTemplate().getEntity()) { + postNameUniqueCheck(); + } else { String name = model.getName().getEntity(); 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 31bde3b..97a2b8e 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 @@ -135,6 +135,7 @@ VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank Template is not allowed. VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template. VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM template. +VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Template Version, Only the Version name can be updated. DIRECTORY_GROUP_CANNOT_REMOVE_DIRECTORY_GROUP_ATTACHED_TO_VM=Cannot remove Directory Group. Detach Directory Group from VM first. VM_NOT_FOUND=VM not found ACTION_TYPE_FAILED_CLUSTER_UNDEFINED_ARCHITECTURE=Cannot ${action} ${type}. The cluster does not have a defined architecture. diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabTemplateView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabTemplateView.java index 74f8371..259bf8d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabTemplateView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabTemplateView.java @@ -54,8 +54,8 @@ } return StringFormat.format("%s (%s)", //$NON-NLS-1$ - getMainModel().resolveBaseTemplateNameForTemplate(object.getId()), - object.getTemplateVersionName() != null ? object.getTemplateVersionName() : " "); //$NON-NLS-1$ + object.getTemplateVersionName() != null ? object.getTemplateVersionName() : "", + object.getTemplateVersionNumber()); } }; getTable().addColumn(versionNameColumn, constants.versionTemplate(), "150px"); //$NON-NLS-1$ 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 8b88ee9..ca83056 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 @@ -139,6 +139,7 @@ VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank Template is not allowed. VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template. VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM template. +VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Template Version, Only the Version name can be updated. DIRECTORY_GROUP_CANNOT_REMOVE_DIRECTORY_GROUP_ATTACHED_TO_VM=Cannot remove Directory Group. Detach Directory Group from VM first. VM_NOT_FOUND=VM not found ACTION_TYPE_FAILED_CLUSTER_UNDEFINED_ARCHITECTURE=Cannot ${action} ${type}. The cluster does not have a defined architecture. diff --git a/packaging/dbscripts/upgrade/03_05_0170_update_template_version_naming.sql b/packaging/dbscripts/upgrade/03_05_0170_update_template_version_naming.sql new file mode 100644 index 0000000..9093921 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_0170_update_template_version_naming.sql @@ -0,0 +1,12 @@ +-- copy name to version_name where version_name is empty +update vm_static +set template_version_name=vm_name +where entity_type='TEMPLATE' and template_version_number>1 and +(template_version_name is null or template_version_name=''); + +-- copy base name to name for versions +update vm_static vm1 +set vm_name= + (select vm2.vm_name from vm_static vm2 + where vm2.vm_guid = vm1.vmt_guid) +where entity_type='TEMPLATE' and template_version_number>1; -- To view, visit http://gerrit.ovirt.org/26270 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I27f26e7d196d1d2eebfe86e8aac886f3e6a8fc5e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches