Fixes bug 902374-Negative tests for Volumes
Change-Id: Ic8f9f92f2f927f00c2eac0b6ba027ba4a45098bc
diff --git a/tempest/services/nova/json/volumes_client.py b/tempest/services/nova/json/volumes_client.py
new file mode 100644
index 0000000..95131f2
--- /dev/null
+++ b/tempest/services/nova/json/volumes_client.py
@@ -0,0 +1,36 @@
+from tempest.common import rest_client
+import json
+
+
+class VolumesClient(object):
+
+ def __init__(self, config, username, key, auth_url, tenant_name=None):
+ self.config = config
+ catalog_type = self.config.compute.catalog_type
+ self.client = rest_client.RestClient(config, username, key, auth_url,
+ catalog_type, tenant_name)
+
+ def list_volumes(self, params=None):
+ """List all the volumes created"""
+ url = 'os-volumes'
+ if params != None:
+ param_list = []
+ for param, value in params.iteritems():
+ param_list.append("%s=%s&" % (param, value))
+
+ url += '?' + ' '.join(param_list)
+
+ resp, body = self.client.get(url)
+ body = json.loads(body)
+ return resp, body['volumes']
+
+ def get_volume(self, volume_id):
+ """Returns the details of a single volume"""
+ url = "os-volumes/%s" % str(volume_id)
+ resp, body = self.client.get(url)
+ body = json.loads(body)
+ return resp, body['volume']
+
+ def delete_volume(self, volume_id):
+ """Deletes the Specified Volume"""
+ return self.client.delete("os-volumes/%s" % str(volume_id))