[PATCH V2] [Kimchi] Guestfs if not supported will return unknown distro and version

From: Archana Singh <archus@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. Archana Singh (1): Modified code, to return distro and version as unknown, if guestfs import failed. imageinfo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.7.4

From: Archana Singh <archus@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@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

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 08/10/2016 02:35 AM, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@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@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")

Applied to master. Thanks! On 08/10/2016 02:35 AM, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@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.
Archana Singh (1): Modified code, to return distro and version as unknown, if guestfs import failed.
imageinfo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
participants (2)
-
archus@linux.vnet.ibm.com
-
Daniel Henrique Barboza