Merge "javelin: implement resource destruction"
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index f37bfdb..436162e 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -110,6 +110,13 @@
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
+
+def destroy_tenants(tenants):
+ admin = keystone_admin()
+ for tenant in tenants:
+ tenant_id = admin.identity.get_tenant_by_name(tenant)['id']
+ r, body = admin.identity.delete_tenant(tenant_id)
+
##############
#
# USERS
@@ -174,6 +181,13 @@
enabled=True)
+def destroy_users(users):
+ admin = keystone_admin()
+ for user in users:
+ user_id = admin.identity.get_user_by_name(user['name'])['id']
+ r, body = admin.identity.delete_user(user_id)
+
+
def collect_users(users):
global USERS
LOG.info("Collecting users")
@@ -343,6 +357,15 @@
obj['container'], obj['name'],
_file_contents(obj['file']))
+
+def destroy_objects(objects):
+ for obj in objects:
+ client = client_for_user(obj['owner'])
+ r, body = client.objects.delete_object(obj['container'], obj['name'])
+ if not (200 >= int(r['status']) < 299):
+ raise ValueError("unable to destroy object: [%s] %s" % (r, body))
+
+
#######################
#
# IMAGES
@@ -496,6 +519,13 @@
client.volumes.create_volume(volume['name'], volume['size'])
+def destroy_volumes(volumes):
+ for volume in volumes:
+ client = client_for_user(volume['owner'])
+ volume_id = _get_volume_by_name(client, volume['name'])['id']
+ r, body = client.volumes.delete_volume(volume_id)
+
+
def attach_volumes(volumes):
for volume in volumes:
client = client_for_user(volume['owner'])
@@ -531,18 +561,13 @@
def destroy_resources():
LOG.info("Destroying Resources")
# Destroy in inverse order of create
-
- # Future
- # detach_volumes
- # destroy_volumes
-
destroy_servers(RES['servers'])
destroy_images(RES['images'])
- # destroy_objects
-
- # destroy_users
- # destroy_tenants
-
+ destroy_objects(RES['objects'])
+ destroy_servers(RES['servers'])
+ destroy_volumes(RES['volumes'])
+ destroy_users(RES['users'])
+ destroy_tenants(RES['tenants'])
LOG.warn("Destroy mode incomplete")