]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Re-create guest if it already exists
authorSandon Van Ness <sandon@inktank.com>
Tue, 23 Jul 2013 23:10:24 +0000 (16:10 -0700)
committerSandon Van Ness <sandon@inktank.com>
Tue, 23 Jul 2013 23:10:24 +0000 (16:10 -0700)
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 <sandon@inktank.com>
teuthology/lock.py

index 964f25400dcb8620f6f0c5a1ca2c7cdb09015e0b..1db09b285027f6d800702a2e98c909d3edb5bb19 100644 (file)
@@ -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