[Kimchi-devel] [PATCH] Fix host debug report for Fedora 20

Aline Manera alinefm at linux.vnet.ibm.com
Wed Feb 5 19:40:32 UTC 2014


On 02/05/2014 03:21 PM, Rodrigo Trujillo wrote:
> The tool sosreport does not save the report file in /tmp in F20, which
> causes a error in Kimchi, which has /tmp hardcoded. This patch fetches
> the report file location from the output.
> Notice that is possible to pass --tmp-dir as the directory to save the
> report file, but this option is crashing in Fedora 20, so the code is
> not using it.

I don't like the idea to parse the output to know where the file was saved.
Isn't there a config file or other way to get the directory used by 
sosreport?

> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/debugreports.py | 40 +++++++++++++++++-----------------------
>   1 file changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
> index a1cb19c..0db9f85 100644
> --- a/src/kimchi/model/debugreports.py
> +++ b/src/kimchi/model/debugreports.py
> @@ -32,6 +32,7 @@ from kimchi import config
>   from kimchi.exception import NotFoundError, OperationFailed
>   from kimchi.model.tasks import TaskModel
>   from kimchi.utils import add_task, kimchi_log
> +from kimchi.utils import run_command
>
>
>   class DebugReportsModel(object):
> @@ -63,36 +64,29 @@ class DebugReportsModel(object):
>
>       @staticmethod
>       def sosreport_generate(cb, name):
> -        command = 'sosreport --batch --name "%s"' % name
>           try:
> -            retcode = subprocess.call(command, shell=True,
> -                                      stdout=subprocess.PIPE)
> +            command = ['sosreport', '--batch', '--name=%s' % name]
> +            output, error, retcode = run_command(command)
> +
>               if retcode < 0:
>                   raise OperationFailed('Command terminated with signal')
>               elif retcode > 0:
>                   raise OperationFailed('Command failed: rc = %i' % retcode)
> -            pattern = '/tmp/sosreport-%s-*' % name
> -            for reportFile in glob.glob(pattern):
> -                if not fnmatch.fnmatch(reportFile, '*.md5'):
> -                    output = reportFile
> -                    break
> -            else:
> -                # sosreport tends to change the name mangling rule and
> -                # compression file format between different releases.
> -                # It's possible to fail to match a report file even sosreport
> -                # runs successfully. In future we might have a general name
> -                # mangling function in kimchi to format the name before passing
> -                # it to sosreport. Then we can delete this exception.
> -                raise OperationFailed('Can not find generated debug report '
> -                                      'named by %s' % pattern)
> -            ext = output.split('.', 1)[1]
> +
> +            # SOSREPORT outputs the name of the file in the text block
> +            # The right way should be passing the tar.xz file directory though
> +            # the parameter '--tmp-dir', but this is failing in Fedora 20
> +            rep_f = [line for line in output.split()
> +                     if line.endswith('tar.xz')][0]
> +            rep_name = os.path.basename(rep_f)
>               path = config.get_debugreports_path()
> -            target = os.path.join(path, name)
> -            target_file = '%s.%s' % (target, ext)
> -            shutil.move(output, target_file)
> -            os.remove('%s.md5' % output)
> -            cb('OK', True)
> +            target = os.path.join(path, rep_name)
>
> +            msg = 'Moving debug report file "%s" to "%s"' % (rep_f, target)
> +            kimchi_log.info(msg)
> +            shutil.move(rep_f, target)
> +            os.remove('%s.md5' % rep_f)
> +            cb('OK', True)
>               return
>
>           except OSError:




More information about the Kimchi-devel mailing list