From 50a45c90a4046f5852c55970b7f6a10551b66c41 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Thu, 13 Aug 2015 09:32:45 -0500 Subject: [PATCH] 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 --- teuthology/task/ansible.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index c0712d5890..03fe4ab758 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): -- 2.39.5