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).
- backend + UI: dont check name already exist for template versions.
- UI: disable 'name' field on new template dialog for versions,
  this field will show the selected base name.
- UI: template grid - show 'version_name (version_number)' instead of
  'name (version_name)'.
- UI: show template version name for importing templates, on template
  sub tab of export domain, and on import template dialog.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1075074
Change-Id: I27f26e7d196d1d2eebfe86e8aac886f3e6a8fc5e
Signed-off-by: Omer Frenkel <[email protected]>
---
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/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/NewTemplateVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.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/popup/storage/backup/ImportTemplatePopupView.java
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/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
A packaging/dbscripts/upgrade/03_05_0270_update_template_version_naming.sql
M packaging/dbscripts/vm_templates_sp.sql
20 files changed, 136 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/26699/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 c6fcdca..6e5cee0 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
@@ -86,6 +86,8 @@
     private static final String BASE_TEMPLATE_VERSION_NAME = "base version";
     private static Map<Guid, String> updateVmsJobIdMap = new 
ConcurrentHashMap<Guid, String>();
 
+    private VmTemplate cachedBaseTemplate;
+
     /**
      * Constructor for command creation when compensation is applied on startup
      *
@@ -221,6 +223,8 @@
                 
getParameters().setTemplateVersionName(BASE_TEMPLATE_VERSION_NAME);
             }
         } else {
+            // template version name should be the same as the base template 
name
+            setVmTemplateName(getBaseTemplate().getName());
             String jobId = 
updateVmsJobIdMap.remove(getParameters().getBaseTemplateId());
             if (jobId != null) {
                 log.infoFormat("Cancelling current running update for vms for 
base template id {0}", getParameters().getBaseTemplateId());
@@ -317,7 +321,7 @@
             return false;
         }
 
-        if (isVmTemlateWithSameNameExist(getVmTemplateName())) {
+        if (!isTemplateVersion() && 
isVmTemlateWithSameNameExist(getVmTemplateName())) {
             
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED);
             return false;
         }
@@ -361,7 +365,7 @@
         }
 
         if (isTemplateVersion()) {
-            VmTemplate userSelectedBaseTemplate = 
getVmTemplateDAO().get(getParameters().getBaseTemplateId());
+            VmTemplate userSelectedBaseTemplate = getBaseTemplate();
             if (userSelectedBaseTemplate == null) {
                 return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST);
             } else if (!userSelectedBaseTemplate.isBaseTemplate()) {
@@ -376,6 +380,13 @@
                 .getcompatibility_version().toString(), 
getReturnValue().getCanDoActionMessages());
     }
 
+    private VmTemplate getBaseTemplate() {
+        if (cachedBaseTemplate == null) {
+            cachedBaseTemplate = 
getVmTemplateDAO().get(getParameters().getBaseTemplateId());
+        }
+        return cachedBaseTemplate;
+    }
+
     private boolean isTemplateVersion() {
         return getParameters().getBaseTemplateId() != null;
     }
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 8887d56..fd8eb74 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
@@ -384,6 +384,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 410158a..4614749 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -138,6 +138,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 Sub-Templates, 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 a22b9cc..4865b85 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
@@ -355,6 +355,9 @@
     @DefaultStringValue("Failed updating the properties of the VM template.")
     String VMT_CANNOT_UPDATE_ILLEGAL_FIELD();
 
+    @DefaultStringValue("Cannot update the name of Sub-Templates, 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/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 646f372..e8aefea0 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
@@ -550,17 +550,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 7fb1cf9..f5cd4b9 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
@@ -554,6 +554,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/NewTemplateVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
index ed83de4..3cb4a04 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java
@@ -452,5 +452,24 @@
 
     @Override
     protected void baseTemplateSelectedItemChanged() {
+        if (getModel().getBaseTemplate().getSelectedItem() != null && 
getModel().getIsSubTemplate().getEntity()) {
+            // template.name for version should be the same as the base 
template name
+            
getModel().getName().setEntity(getModel().getBaseTemplate().getSelectedItem().getName());
+        }
+    }
+
+    @Override
+    protected void isSubTemplateEntityChanged() {
+        
getModel().getName().setIsChangable(!getModel().getIsSubTemplate().getEntity());
+        if (!getModel().getIsSubTemplate().getEntity()) {
+            getModel().getName().setEntity(""); //$NON-NLS-1$
+        } else {
+            // by default select the template of the vm
+            
getModel().getBaseTemplate().setEntity(getModel().getTemplate().getEntity());
+
+            // copy any entered name to be the template-version name
+            
getModel().getTemplateVersionName().setEntity(getModel().getName().getEntity());
+            
getModel().getName().setEntity(getModel().getBaseTemplate().getSelectedItem().getName());
+        }
     }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
index 238dbe5..49e3f1d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java
@@ -37,7 +37,8 @@
         getModel().getStorageDomain().setIsChangable(false);
         getModel().getIsSoundcardEnabled().setIsChangable(true);
         getModel().getVmType().setIsChangable(true);
-        
getModel().getTemplateVersionName().setIsChangable(!template.getId().equals(template.getBaseTemplateId()));
+        
getModel().getTemplateVersionName().setIsChangable(!template.isBaseTemplate());
+        getModel().getName().setIsChangable(template.isBaseTemplate());
 
         if (template.getStoragePoolId() != null && 
!template.getStoragePoolId().equals(Guid.Empty))
         {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index 0da83c3..4136007 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -1289,6 +1289,7 @@
         setSpiceProxy(new EntityModel<String>());
 
         setIsSubTemplate(new 
NotChangableForVmInPoolEntityModel<Boolean>(false));
+        getIsSubTemplate().getEntityChangedEvent().addListener(this);
         setTemplateVersionName(new 
NotChangableForVmInPoolEntityModel<String>());
         setBaseTemplate(new NotChangableForVmInPoolListModel<VmTemplate>());
         getBaseTemplate().getSelectedItemChangedEvent().addListener(this);
@@ -1604,6 +1605,9 @@
             } else if (sender == getOverrideMigrationDowntime()) {
                 overrideMigrationDowntimeChanged();
             }
+            else if (sender == getIsSubTemplate()) {
+                behavior.isSubTemplateEntityChanged();
+            }
 
         }
     }
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 548facb..d198664 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
@@ -1318,6 +1318,9 @@
         {
             model.setIsValid(false);
         }
+        else  if (model.getIsSubTemplate().getEntity()) {
+            postNameUniqueCheck();
+        }
         else
         {
             String name = model.getName().getEntity();
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
index 8a6083f..28fa477 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
@@ -187,6 +187,9 @@
         }
     }
 
+    protected void isSubTemplateEntityChanged() {
+    }
+
     public boolean validate()
     {
         return true;
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 c29a71b..e6ddb1b 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
@@ -133,6 +133,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 Sub-Templates, 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/popup/storage/backup/ImportTemplatePopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportTemplatePopupView.java
index 9c9bf1f..6114c5a 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportTemplatePopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/storage/backup/ImportTemplatePopupView.java
@@ -2,6 +2,7 @@
 
 import org.ovirt.engine.core.common.businessentities.OriginType;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.compat.StringFormat;
 import org.ovirt.engine.ui.common.uicommon.model.DetailModelProvider;
 import org.ovirt.engine.ui.common.widget.editor.ListModelObjectCellTable;
 import org.ovirt.engine.ui.common.widget.table.column.CheckboxColumn;
@@ -65,6 +66,21 @@
         };
         table.addColumn(nameColumn, constants.nameTemplate(), "150px"); 
//$NON-NLS-1$
 
+        TextColumnWithTooltip<Object> versionNameColumn = new 
TextColumnWithTooltip<Object>() {
+            @Override
+            public String getValue(Object object) {
+                VmTemplate template = ((ImportTemplateData) 
object).getTemplate();
+                if (template.isBaseTemplate()) {
+                    return ""; //$NON-NLS-1$
+                }
+
+                return StringFormat.format("%s (%s)", //$NON-NLS-1$
+                        template.getTemplateVersionName() != null ? 
template.getTemplateVersionName() : "", //$NON-NLS-1$
+                        template.getTemplateVersionNumber());
+            }
+        };
+        table.addColumn(versionNameColumn, constants.versionTemplate(), 
"150px"); //$NON-NLS-1$
+
         TextColumnWithTooltip<Object> originColumn = new EnumColumn<Object, 
OriginType>() {
             @Override
             protected OriginType getRawValue(Object object) {
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..77fd36f 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
@@ -53,9 +53,9 @@
                     return ""; //$NON-NLS-1$
                 }
 
-                return StringFormat.format("%s (%s)",  //$NON-NLS-1$
-                        
getMainModel().resolveBaseTemplateNameForTemplate(object.getId()),
-                        object.getTemplateVersionName() != null ? 
object.getTemplateVersionName() : " "); //$NON-NLS-1$
+                return StringFormat.format("%s (%s)", //$NON-NLS-1$
+                        object.getTemplateVersionName() != null ? 
object.getTemplateVersionName() : "", //$NON-NLS-1$
+                        object.getTemplateVersionNumber());
             }
         };
         getTable().addColumn(versionNameColumn, constants.versionTemplate(), 
"150px"); //$NON-NLS-1$
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java
index 0455522..7100cfd 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageTemplateBackupView.java
@@ -4,6 +4,7 @@
 
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.compat.StringFormat;
 import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider;
 import org.ovirt.engine.ui.common.widget.table.column.TextColumnWithTooltip;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
@@ -43,6 +44,20 @@
                 };
         getTable().addColumn(nameColumn, constants.nameTemplate(), "160px"); 
//$NON-NLS-1$
 
+        TextColumnWithTooltip<VmTemplate> versionNameColumn = new 
TextColumnWithTooltip<VmTemplate>() {
+            @Override
+            public String getValue(VmTemplate object) {
+                if (object.isBaseTemplate()) {
+                    return ""; //$NON-NLS-1$
+                }
+
+                return StringFormat.format("%s (%s)", //$NON-NLS-1$
+                        object.getTemplateVersionName() != null ? 
object.getTemplateVersionName() : "", //$NON-NLS-1$
+                        object.getTemplateVersionNumber());
+            }
+        };
+        table.addColumn(versionNameColumn, constants.versionTemplate(), 
"150px"); //$NON-NLS-1$
+
         TextColumnWithTooltip<VmTemplate> originColumn =
                 new TextColumnWithTooltip<VmTemplate>() {
                     @Override
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 4927d9b..8cdb6f3 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
@@ -137,6 +137,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 Sub-Templates, 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_0270_update_template_version_naming.sql 
b/packaging/dbscripts/upgrade/03_05_0270_update_template_version_naming.sql
new file mode 100644
index 0000000..9093921
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_05_0270_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;
diff --git a/packaging/dbscripts/vm_templates_sp.sql 
b/packaging/dbscripts/vm_templates_sp.sql
index f8c6d1b..c3c43b2 100644
--- a/packaging/dbscripts/vm_templates_sp.sql
+++ b/packaging/dbscripts/vm_templates_sp.sql
@@ -222,7 +222,7 @@
  v_migration_support integer,
  v_dedicated_vm_for_vds uuid,
  v_tunnel_migration BOOLEAN,
- v_vnc_keyboard_layout VARCHAR(16),
+ v_vnc_keyboard_layout VARCHAR(16),
  v_min_allocated_mem INTEGER,
  v_is_run_and_pause BOOLEAN,
  v_created_by_user_id UUID,
@@ -256,6 +256,11 @@
       template_version_name = v_template_version_name
       WHERE vm_guid = v_vmt_guid
       AND   entity_type = v_template_type;
+
+      -- update template versions to new name
+      update vm_static
+        set vm_name = v_name
+      where vm_guid <> v_vmt_guid and vmt_guid = v_vmt_guid and entity_type = 
v_template_type;
 END; $procedure$
 LANGUAGE plpgsql;
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27f26e7d196d1d2eebfe86e8aac886f3e6a8fc5e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Omer Frenkel <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to