[Kimchi-devel] [PATCH][Kimchi 5/6] Only use source_media as boot media

Ramon Medeiros ramonn at linux.vnet.ibm.com
Tue Mar 22 19:09:28 UTC 2016


Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 API.json      |  2 +-
 i18n.py       |  2 +-
 vmtemplate.py | 12 +++++++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/API.json b/API.json
index 05caa49..ce25fe1 100644
--- a/API.json
+++ b/API.json
@@ -468,7 +468,7 @@
                     "error": "KCHTMPL0011E"
                 },
                 "memory": { "$ref": "#/kimchitype/memory" },
-                "installation_media": {
+                "source_media": {
                     "description": "Path for installation media (ISO, disk, remote ISO)",
                     "type" : "string",
                     "pattern" : "^[^ ]+( +[^ ]+)*$"
diff --git a/i18n.py b/i18n.py
index beefeb5..ada04c2 100644
--- a/i18n.py
+++ b/i18n.py
@@ -168,7 +168,7 @@ messages = {
     "KCHTMPL0013E": _("Amount of memory and maximum memory (MB) must be an integer greater than 512"),
     "KCHTMPL0014E": _("Template CDROM must be a local or remote ISO file"),
     "KCHTMPL0015E": _("Invalid storage pool URI %(value)s specified for template"),
-    "KCHTMPL0016E": _("Specify an ISO image as CDROM or a base image to create a template"),
+    "KCHTMPL0016E": _("Specify an argument to 'source_media' to create a template"),
     "KCHTMPL0017E": _("All networks for the template must be specified in a list."),
     "KCHTMPL0018E": _("Specify a volume to a template when storage pool is iSCSI or SCSI"),
     "KCHTMPL0019E": _("The volume %(volume)s is not in storage pool %(pool)s"),
diff --git a/vmtemplate.py b/vmtemplate.py
index 8572dfe..bc54148 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -47,6 +47,12 @@ from wok.plugins.kimchi.xmlutils.serial import get_serial_xml
 DISK_TYPE = {"QEMU QCOW Image": "qcow2",
              "data": "raw"}
 ISO_TYPE = "ISO 9660 CD-ROM"
+SOURCE_MEDIA = "source_media"
+# In PowerPC, memories must be aligned to 256 MiB
+PPC_MEM_ALIGN = 256
+# Max memory 1TB, in KiB
+MAX_MEM_LIM = 1073741824
+
 
 class VMTemplate(object):
     def __init__(self, args, scan=False):
@@ -98,6 +104,10 @@ class VMTemplate(object):
         """
         Creates a new template
         """
+        # no source_media argument: raise error
+        if args.get(SOURCE_MEDIA) == None:
+            raise OperationFailed('KCHTMPL0016E')
+
         # identify installation media
         self._identify_installation_media(args)
 
@@ -150,7 +160,7 @@ class VMTemplate(object):
             self.info['disks'][index] = disk_info
 
     def _identify_installation_media(self, args):
-        path = args.get("installation_media")
+        path = args.get(SOURCE_MEDIA)
 
         # user did not passed installation media: return
         if path is None:
-- 
2.5.0




More information about the Kimchi-devel mailing list