From 0037e756452b042cdba50a28285cc9f9797b0586 Mon Sep 17 00:00:00 2001 From: grakiss Date: Tue, 8 Aug 2017 17:04:23 +0800 Subject: create a tar file for logs JIRA: DOVETAIL-479 User may want to upload all logs along with the results, so others may check the running logs to make sure what' s going on during the test. Change-Id: Ia5862f99c129b8207aa91a391567ffdd5ee0829a Signed-off-by: grakiss --- dovetail/report.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dovetail/report.py b/dovetail/report.py index 4743c256..fc707a37 100644 --- a/dovetail/report.py +++ b/dovetail/report.py @@ -13,6 +13,7 @@ import urllib2 import re import os import datetime +import tarfile from pbr import version @@ -159,9 +160,21 @@ class Report(object): report_txt += sub_report[key] cls.logger.info(report_txt) + cls.save_logs() # cls.save(report_txt) return report_txt + @classmethod + def save_logs(cls): + logs_gz = "logs.tar.gz" + result_dir = dt_cfg.dovetail_config['result_dir'] + + with tarfile.open(os.path.join(result_dir, logs_gz), "w:gz") as f_out: + files = os.listdir(result_dir) + for f in files: + if f not in ['workspace']: + f_out.add(os.path.join(result_dir, f)) + # save to disk as default @classmethod def save(cls, report): -- cgit 1.2.3-korg