[Kimchi-devel] [PATCH] [Kimchi] Bug fix: Create VM based on Remote ISO Template

Aline Manera alinefm at linux.vnet.ibm.com
Thu May 5 21:36:27 UTC 2016


When trying to create a VM from a recent created remote ISO Template, an error
was raised:

Error in async_task 1
Traceback (most recent call last):
  File "/home/alinefm/wok/src/wok/asynctask.py", line 72, in _run_helper
    self.fn(cb, opaque)
  File "/home/alinefm/wok/src/wok/plugins/kimchi/model/vms.py", line 168, in _create_task
    vol_list = t.fork_vm_storage(vm_uuid)
  File "/home/alinefm/wok/src/wok/plugins/kimchi/model/templates.py", line 397, in fork_vm_storage
    vol_list = self.to_volume_list(vm_uuid)
  File "/home/alinefm/wok/src/wok/plugins/kimchi/vmtemplate.py", line 262, in to_volume_list
    base_fmt = imageinfo.probe_img_info(d['base'])['format']
  File "/home/alinefm/wok/src/wok/plugins/kimchi/imageinfo.py", line 40, in probe_img_info
    info['actual-size'] = info['actual-size'] >> 30
KeyError: 'actual-size'

It was because the remote ISO path was being set as CDROM and also as
base image, causing the issue when creating the VM.

Fix it.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 model/templates.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/model/templates.py b/model/templates.py
index 131f86b..5cdac00 100644
--- a/model/templates.py
+++ b/model/templates.py
@@ -68,10 +68,9 @@ class TemplatesModel(object):
         if source_media['type'] == 'netboot':
             params['netboot'] = True
             return self.save_template(params)
-        else:
-            # Get path of source media if it's based on disk type.
-            path = source_media.get('path', None)
 
+        # Get path of source media if it's based on disk type.
+        path = source_media.get('path', None)
         if path is None:
             raise InvalidParameter("KCHTMPL0016E")
 
@@ -80,9 +79,10 @@ class TemplatesModel(object):
         if urlparse.urlparse(path).scheme in ["http", "https", "tftp", "ftp",
                                               "ftps"]:
             params["cdrom"] = path
+            return self.save_template(params)
 
-        # image does not exists: raise error
-        elif not os.path.exists(path):
+        # Local file (ISO/Img) does not exist: raise error
+        if not os.path.exists(path):
             raise InvalidParameter("KCHTMPL0002E", {'path': path})
 
         # create magic object to discover file type
-- 
2.5.5




More information about the Kimchi-devel mailing list