From 6ceb7e8ca0778b726ac72ffbb6fd84c1d1ae5055 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 12 Feb 2015 14:57:57 -0700 Subject: [PATCH] Be smarter about logging in create_if_vm() Also return False on failure. Signed-off-by: Zack Cerza --- teuthology/provision.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) 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 -- 2.39.5