[Kimchi-devel] [PATCH V2] [Kimchi] Modified code, to return distro and version as unknown, if guestfs import failed.

archus at linux.vnet.ibm.com archus at linux.vnet.ibm.com
Wed Aug 10 05:35:49 UTC 2016


From: Archana Singh <archus at linux.vnet.ibm.com>

On s390x machine, guestfs is not supported, hence made the change
in imageinfo.py to return unknown as distro and version on import error
of guestfs.

Signed-off-by: Archana Singh <archus at linux.vnet.ibm.com>
---
 imageinfo.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/imageinfo.py b/imageinfo.py
index 8874917..30c08ae 100644
--- a/imageinfo.py
+++ b/imageinfo.py
@@ -17,7 +17,6 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
-import guestfs
 import json
 import os
 import sys
@@ -48,11 +47,14 @@ def probe_image(image_path):
     if not os.access(image_path, os.R_OK):
         raise ImageFormatError("KCHIMG0003E", {'filename': image_path})
 
-    g = guestfs.GuestFS(python_return_dict=True)
-    g.add_drive_opts(image_path, readonly=1)
-    g.launch()
     try:
+        import guestfs
+        g = guestfs.GuestFS(python_return_dict=True)
+        g.add_drive_opts(image_path, readonly=1)
+        g.launch()
         roots = g.inspect_os()
+    except ImportError:
+        return ("unknown", "unknown")
     except:
         raise ImageFormatError("KCHIMG0001E")
 
-- 
2.7.4




More information about the Kimchi-devel mailing list