From e6a30d73a75b383db2c99ee2b471e1488397445c Mon Sep 17 00:00:00 2001 From: Sandon Van Ness Date: Tue, 23 Jul 2013 16:10:24 -0700 Subject: [PATCH] Re-create guest if it already exists In some cases tests fail or nuke fails and the guest is not properly destroyed. This will look to see if it gets an error due to the guest already existing or its disks existing and will re-create the guest. Signed-off-by: Sandon Van Ness --- teuthology/lock.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/teuthology/lock.py b/teuthology/lock.py index 964f25400d..1db09b2850 100644 --- a/teuthology/lock.py +++ b/teuthology/lock.py @@ -590,6 +590,12 @@ def create_if_vm(ctx, machine_name): (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) return True # # Use downburst to destroy a virtual machine -- 2.39.5