]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add optional description arg to destroy_if_vm()
authorZack Cerza <zack@redhat.com>
Thu, 12 Feb 2015 17:00:38 +0000 (10:00 -0700)
committerZack Cerza <zack@redhat.com>
Thu, 12 Feb 2015 18:15:12 +0000 (11:15 -0700)
If it is passed and doesn't match the one received from the lock server,
don't destroy the VM.

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

index e2bcb7cd6480449a911206086f5074d1ef967fe9..38f38969ef79522a8f01aa81c5f1fea2e29e3a4e 100644 (file)
@@ -98,7 +98,7 @@ def create_if_vm(ctx, machine_name):
     return True
 
 
-def destroy_if_vm(ctx, machine_name, user=None):
+def destroy_if_vm(ctx, machine_name, user=None, description=None):
     """
     Use downburst to destroy a virtual machine
 
@@ -111,6 +111,10 @@ def destroy_if_vm(ctx, machine_name, user=None):
         log.error("Tried to destroy {node} as {as_user} but it is locked by {locked_by}".format(
             node=machine_name, as_user=user, locked_by=status_info['locked_by']))
         return False
+    if description is not None and description != status_info['description']:
+        log.error("Tried to destroy {node} with description {desc_arg} but it is locked with description {desc_lock}".format(
+            node=machine_name, desc_arg=description, desc_lock=status_info['description']))
+        return False
     phys_host = decanonicalize_hostname(status_info['vm_host']['name'])
     destroyMe = decanonicalize_hostname(machine_name)
     dbrst = _get_downburst_exec()