]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Be smarter about logging in create_if_vm()
authorZack Cerza <zack@redhat.com>
Thu, 12 Feb 2015 21:57:57 +0000 (14:57 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 3 Apr 2015 03:42:30 +0000 (21:42 -0600)
Also return False on failure.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/provision.py

index 38f38969ef79522a8f01aa81c5f1fea2e29e3a4e..d82891baff1b2743573a01dfd4b189079ba00a0c 100644 (file)
@@ -84,17 +84,20 @@ def create_if_vm(ctx, machine_name):
                               'create', metadata, createMe],
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE,)
         owt, err = p.communicate()
-        if err:
-            log.info("Downburst completed on %s: %s" %
-                     (machine_name, err))
-        else:
-            log.info("%s created: %s" % (machine_name, owt))
-        # If the guest already exists first destroy then re-create:
-        if 'exists' in err:
-            log.info("Guest files exist. Re-creating guest: %s" %
-                     (machine_name))
-            destroy_if_vm(ctx, machine_name)
-            create_if_vm(ctx, machine_name)
+        if p.returncode == 0:
+            log.info("Downburst created %s: %s" % (machine_name, owt.strip()))
+        elif err:
+            # If the guest already exists first destroy then re-create:
+            # FIXME there is a recursion-depth issue here.
+            if 'exists' in err:
+                log.info("Guest files exist. Re-creating guest: %s" %
+                         (machine_name))
+                destroy_if_vm(ctx, machine_name)
+                create_if_vm(ctx, machine_name)
+            else:
+                log.info("Downburst failed on %s: %s" % (machine_name,
+                                                         err.strip()))
+                return False
     return True