Omer Frenkel has uploaded a new change for review.

Change subject: core: import/export from template version
......................................................................

core: import/export from template version

Add template version to import and export of vm and template.

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

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1037478
Change-Id: I3dd434f5857a707f12508ebb6ab20e46a4f1be3c
Signed-off-by: Omer Frenkel <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.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 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmWriter.java
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
10 files changed, 53 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/23607/1

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 a284b52..2d30740 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
@@ -200,6 +200,15 @@
         if (retVal) {
             retVal = validateMacAddress(Entities.<VmNic, VmNetworkInterface> 
upcast(getVmTemplate().getInterfaces()));
         }
+
+        // if this is a template version, check base template exist
+        if (retVal && !getVmTemplate().isBaseTemplate()) {
+            VmTemplate baseTemplate = 
getVmTemplateDAO().get(getVmTemplate().getBaseTemplateId());
+            if (baseTemplate == null) {
+                retVal = false;
+                
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST);
+            }
+        }
         if (!retVal) {
             addCanDoActionMessage(VdcBllMessages.VAR__ACTION__IMPORT);
             addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM_TEMPLATE);
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 1e4eb7a..e41b219 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
@@ -750,6 +750,7 @@
     
ACTION_TYPE_FAILED_ACTION_IS_SUPPORTED_ONLY_FOR_ISCSI_DOMAINS(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY(ErrorType.BAD_PARAMETERS),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS),
     // Cluster Policy messages
     
ACTION_TYPE_FAILED_CLUSTER_POLICY_PARAMETERS_INVALID(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_CLUSTER_POLICY_NAME_INUSE(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 7f4315e..66f2a59 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -936,6 +936,7 @@
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
+ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. Base 
Template does not exist for this Template Version.
 
 NON_VM_NETWORK_NOT_SUPPORTED_FOR_POOL_LEVEL=Non-VM networks are not supported 
in this Data-Center.
 # Gluster Error Messages
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
index 1f5e761..48033f3 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java
@@ -196,6 +196,24 @@
         if (node != null) {
             _vmTemplate.setTemplateType(VmEntityType.valueOf(node.innerText));
         }
+
+        node = content.SelectSingleNode("BaseTemplateId");
+        if (node != null) {
+            
_vmTemplate.setBaseTemplateId(Guid.createGuidFromString(node.innerText));
+        } else {
+            // in case base template is missing, we assume it is a base 
template
+            _vmTemplate.setBaseTemplateId(_vmTemplate.getId());
+        }
+
+        node = content.SelectSingleNode("TemplateVersionNumber");
+        if (node != null) {
+            
_vmTemplate.setTemplateVersionNumber(Integer.parseInt(node.innerText));
+        }
+
+        node = content.SelectSingleNode("TemplateVersionName");
+        if (node != null) {
+            _vmTemplate.setTemplateVersionName(node.innerText);
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java
index 0a048d0..b698343 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java
@@ -46,6 +46,15 @@
         _writer.WriteStartElement("TemplateType");
         _writer.WriteRaw(_vmTemplate.getTemplateType().name());
         _writer.WriteEndElement();
+        _writer.WriteStartElement("BaseTemplateId");
+        _writer.WriteRaw(_vmTemplate.getBaseTemplateId().toString());
+        _writer.WriteEndElement();
+        _writer.WriteStartElement("TemplateVersionNumber");
+        
_writer.WriteRaw(String.valueOf(_vmTemplate.getTemplateVersionNumber()));
+        _writer.WriteEndElement();
+        _writer.WriteStartElement("TemplateVersionName");
+        _writer.WriteRaw(_vmTemplate.getTemplateVersionName());
+        _writer.WriteEndElement();
     }
 
     @Override
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
index 6519e7f..7327d90 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmReader.java
@@ -243,6 +243,11 @@
         if (node != null) {
            _vm.setAutoStartup(Boolean.parseBoolean(node.innerText));
         }
+
+        node = content.SelectSingleNode("UseLatestVersion");
+        if (node != null) {
+            _vm.setUseLatestVersion(Boolean.parseBoolean(node.innerText));
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmWriter.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmWriter.java
index 85773a2..b526d99 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmWriter.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfVmWriter.java
@@ -89,6 +89,11 @@
         _writer.WriteStartElement("AutoStartup");
         _writer.WriteRaw(String.valueOf(_vm.isAutoStartup()));
         _writer.WriteEndElement();
+
+        _writer.WriteStartElement("UseLatestVersion");
+        _writer.WriteRaw(String.valueOf(_vm.isUseLatestVersion()));
+        _writer.WriteEndElement();
+
         OvfLogEventHandler<VmStatic> handler = new 
VMStaticOvfLogHandler(_vm.getStaticData());
         // Gets a map that its keys are aliases to fields that should be OVF
         // logged.
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 bd1257d..18b876b 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
@@ -2527,6 +2527,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Template disks cannot be 
moved.")
     String ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Base Template does not 
exist for this Template Version.")
+    String ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST();
+
     @DefaultStringValue("Failed ${action} ${type}. The following networks 
(${networks}) are not defined as VM networks.")
     String ACTION_TYPE_FAILED_NOT_A_VM_NETWORK();
 
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 4cb992c..60cf008 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
@@ -906,6 +906,7 @@
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
+ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. Base 
Template does not exist for this Template Version.
 
 ACTION_TYPE_FAILED_NOT_A_VM_NETWORK=Failed ${action} ${type}. The following 
networks (${networks}) are not defined as VM networks.
 ACTION_TYPE_FAILED_NETWORK_NOT_IN_CLUSTER=Failed ${action} ${type}. The 
following networks (${networks}) are not defined in the cluster.
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 ec44915..44a9aa7 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
@@ -933,6 +933,7 @@
 ACTION_TYPE_FAILED_DISK_IS_NOT_TEMPLATE_DISK=Cannot ${action} ${type}. The 
selected disk is not a template disk. Only template disks can be copied.
 ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME=Cannot ${action} ${type}. The source 
and target storage domains are the same.
 ACTION_TYPE_FAILED_CANNOT_MOVE_TEMPLATE_DISK=Cannot ${action} ${type}. 
Template disks cannot be moved.
+ACTION_TYPE_FAILED_BASE_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. Base 
Template does not exist for this Template Version.
 
 ACTION_TYPE_FAILED_NOT_A_VM_NETWORK=Failed ${action} ${type}. The following 
networks (${networks}) are not defined as VM networks.
 ACTION_TYPE_FAILED_NETWORK_NOT_IN_CLUSTER=Failed ${action} ${type}. The 
following networks (${networks}) are not defined in the cluster.


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

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