From: Zack Cerza Date: Thu, 12 Feb 2015 21:57:57 +0000 (-0700) Subject: Be smarter about logging in create_if_vm() X-Git-Tag: 1.1.0~974^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6ceb7e8ca0778b726ac72ffbb6fd84c1d1ae5055;p=teuthology.git Be smarter about logging in create_if_vm() Also return False on failure. Signed-off-by: Zack Cerza --- diff --git a/teuthology/provision.py b/teuthology/provision.py index 38f38969ef..d82891baff 100644 --- a/teuthology/provision.py +++ b/teuthology/provision.py @@ -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