Skip to content
Snippets Groups Projects
Commit 7c6a4186 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add check_guestfs_version function

This function is used to check if a specified libguestfs version is
smaller, greater or equal to the installed one
parent 97d863ff
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from image_creator.util import FatalError
from image_creator.util import FatalError, check_guestfs_version
from image_creator.gpt import GPTPartitionTable
from image_creator.os_type import os_cls
......@@ -64,14 +64,11 @@ class Image(object):
# file descriptors. This can cause problems especially if the parent
# process has opened pipes. Since the recovery process is an optional
# feature of libguestfs, it's better to disable it.
self.g.set_recovery_proc(0)
version = self.g.version()
if version['major'] > 1 or \
(version['major'] == 1 and (version['minor'] >= 18 or
(version['minor'] == 17 and
version['release'] >= 14))):
self.g.set_recovery_proc(1)
if check_guestfs_version(self.g, 1, 17, 14) >= 0:
self.out.output("Enabling recovery proc")
self.g.set_recovery_proc(1)
else:
self.g.set_recovery_proc(0)
#self.g.set_trace(1)
#self.g.set_verbose(1)
......
......@@ -115,4 +115,23 @@ class MD5:
return checksum
def check_guestfs_version(ghandler, major, minor, release):
"""Checks if the version of the used libguestfs is smaller, equal or
greater than the one specified by the major, minor and release triplet
Returns:
< 0 if the installed version is smaller than the specified one
= 0 if they are equal
> 0 if the installed one is greater than the specified one
"""
ver = ghandler.version()
for (a, b) in (ver['major'], major), (ver['minor'], minor), \
(ver['release'], release):
if a != b:
return a - b
return 0
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment