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 <grakiss.wanglei@huawei.com>
import re
import os
import datetime
+import tarfile
from pbr import version
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):