[Kimchi-devel] [PATCH] Issue#536: raise proper error message when disk os info absent

lvroyce0210 at gmail.com lvroyce0210 at gmail.com
Wed Dec 10 13:23:05 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

When disk os cannot be decided by libguestfs,
it will leave it to 'unknown' distro and version.
But if no boot information available,
ImageFormatError is left unhandled and this will introduce
500 error when disk os info is absent.
Handle this error to fix this.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/vmtemplate.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 8582d48..3266e7b 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -29,6 +29,7 @@ from lxml.builder import E
 from kimchi import imageinfo
 from kimchi import osinfo
 from kimchi.exception import InvalidParameter, IsoFormatError, MissingParameter
+from kimchi.exception import ImageFormatError, OperationFailed
 from kimchi.isoinfo import IsoImage
 from kimchi.utils import check_url_path, pool_name_from_uri
 from kimchi.xmlutils.disk import get_disk_xml
@@ -51,7 +52,10 @@ class VMTemplate(object):
         self.fc_host_support = args.get('fc_host_support')
 
         # Fetch defaults based on the os distro and version
-        distro, version = self._get_os_info(args, scan)
+        try:
+            distro, version = self._get_os_info(args, scan)
+        except ImageFormatError as e:
+            raise OperationFailed('KCHTMPL0020E', {'err': e.message})
         os_distro = args.get('os_distro', distro)
         os_version = args.get('os_version', version)
         entry = osinfo.lookup(os_distro, os_version)
-- 
1.8.3.2




More information about the Kimchi-devel mailing list