Omer Frenkel has uploaded a new change for review.

Change subject: core: support adding template version
......................................................................

core: support adding template version

This patch add the ability to specify on add template,
that this will be version of a template.

http://www.ovirt.org/index.php?title=Features/Template_Versions

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1037478
Change-Id: Id256ade6e3973d5ad00daa267f80e5ce42b87872
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/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.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, 34 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/22738/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 dce8e8d..7c14336 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
@@ -193,6 +193,11 @@
         getParameters().setVmTemplateId(getVmTemplateId());
         getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, 
getVmTemplateId()));
 
+        // set blank template as base for new templates
+        if (getParameters().getBaseTemplateId() == null) {
+            
getParameters().setbaseTemplateId(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
+        }
+
         final Map<Guid, Guid> srcDeviceIdToTargetDeviceIdMapping = new 
HashMap<>();
 
         TransactionSupport.executeInNewTransaction(new 
TransactionMethod<Void>() {
@@ -308,6 +313,17 @@
                     getParameters().getWatchdog(),
                     
getVdsGroup().getcompatibility_version())).isModelCompatibleWithOs())) {
                 return false;
+            }
+        }
+
+        if (getParameters().getBaseTemplateId() != null) {
+            VmTemplate baseTemplate = 
getVmTemplateDAO().get(getParameters().getBaseTemplateId());
+            if (baseTemplate == null) {
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST);
+            } else if 
(!baseTemplate.getBaseTemplateId().equals(VmTemplateHandler.BLANK_VM_TEMPLATE_ID))
 {
+                // currently template version cannot be base template
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE);
+
             }
         }
 
@@ -441,7 +457,7 @@
                         getParameters().getMasterVm().isRunAndPause(),
                         getUserId(),
                         getParameters().getTemplateType(),
-                        VmTemplateHandler.BLANK_VM_TEMPLATE_ID));
+                        getParameters().getBaseTemplateId()));
         
getVmTemplate().setAutoStartup(getParameters().getMasterVm().isAutoStartup());
         
getVmTemplate().setPriority(getParameters().getMasterVm().getPriority());
         
getVmTemplate().setDefaultDisplayType(getParameters().getMasterVm().getDefaultDisplayType());
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
index 1042ad8..4181f08 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddVmTemplateParameters.java
@@ -51,6 +51,8 @@
 
     private Boolean virtioScsiEnabled;
 
+    private Guid baseTemplateId;
+
     public AddVmTemplateParameters(VmStatic masterVm, String name, String 
description) {
         this();
         _masterVm = masterVm;
@@ -160,4 +162,12 @@
     public void setTemplateType(VmEntityType templateType) {
         this.templateType = templateType;
     }
+
+    public Guid getBaseTemplateId() {
+        return baseTemplateId;
+    }
+
+    public void setbaseTemplateId(Guid baseTemplateId) {
+        this.baseTemplateId = baseTemplateId;
+    }
 }
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 1dc5a57..26a1b4d 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
@@ -201,6 +201,7 @@
     ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_IMAGE(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_CPU_NOT_FOUND(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS),
+    
ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE(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 6ea7c89..c86595d 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -216,6 +216,7 @@
 ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. 
Failed to get data for Import operation.\n\
 - Check your Import Domain.
 ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The 
relevant Template doesn't exist.
+ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE=Cannot ${action} 
${type}. Template version cannot be used as base for other template version, 
please use base templates only.
 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/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 09be69f..795ec9f 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
@@ -578,6 +578,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. The relevant Template 
doesn't exist.")
     String ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Template version cannot be 
used as base for other template version, please use base templates only.")
+    String ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE();
+
     @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 eeb3cd3..aed5b6f 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
@@ -212,6 +212,7 @@
 ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. 
Failed to get data for Import operation.\n\
 - Check your Import Domain.
 ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The 
relevant Template doesn't exist.
+ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE=Cannot ${action} 
${type}. Template version cannot be used as base for other template version, 
please use base templates only.
 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 181525c..9f422c8 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
@@ -214,6 +214,7 @@
 ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. 
Failed to get data for Import operation.\n\
 - Check your Import Domain.
 ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The 
relevant Template doesn't exist.
+ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE=Cannot ${action} 
${type}. Template version cannot be used as base for other template version, 
please use base templates only.
 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/22738
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id256ade6e3973d5ad00daa267f80e5ce42b87872
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

Reply via email to