]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
task.ansible: use shutil.move instead of os.rename to move a failure log 595/head
authorAndrew Schoen <aschoen@redhat.com>
Thu, 13 Aug 2015 14:32:45 +0000 (09:32 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 13 Aug 2015 17:43:24 +0000 (12:43 -0500)
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 <aschoen@redhat.com>
teuthology/task/ansible.py

index c0712d589083e4555b57e97be00e9e82c10d7d08..03fe4ab7586f7272190f0c11c92768d7d0087852 100644 (file)
@@ -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):