From: Andrew Schoen Date: Thu, 13 Aug 2015 14:32:45 +0000 (-0500) Subject: task.ansible: use shutil.move instead of os.rename to move a failure log X-Git-Tag: 1.1.0~850^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F595%2Fhead;p=teuthology.git task.ansible: use shutil.move instead of os.rename to move a failure log When moving a file between file systems of different types os.rename will throw an exception, while shutil.move correctly handles that case. Signed-off-by: Andrew Schoen --- diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index c0712d58..03fe4ab7 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -4,6 +4,7 @@ import requests import os import pexpect import yaml +import shutil from cStringIO import StringIO from tempfile import NamedTemporaryFile @@ -266,7 +267,11 @@ class Ansible(Task): try: failures = yaml.safe_load(log) except yaml.parser.ParserError: - log.exception("Failed to load failure log...") + log.exception( + "Failed to parse ansible failure log: {0}".format( + self.failure_log.name, + ) + ) if failures: if self.ctx.archive: @@ -275,9 +280,13 @@ class Ansible(Task): raise CommandFailedError(command, status) def _archive_failures(self): - os.rename( + archive_path = "{0}/ansible_failures.yaml".format(self.ctx.archive) + log.info("Archiving ansible failure log at: {0}".format( + archive_path, + )) + shutil.move( self.failure_log.name, - "{0}/ansible_failures.yaml".format(self.ctx.archive) + archive_path ) def _build_args(self):