incorporated Jay's suggestion
bug915695 security groups client - to list
Change-Id: I7f9ab59557c8cb20e7e67468925e4666dd981541
diff --git a/tempest/openstack.py b/tempest/openstack.py
index 920ff14..1d73e21 100644
--- a/tempest/openstack.py
+++ b/tempest/openstack.py
@@ -3,6 +3,8 @@
from tempest.services.nova.json.servers_client import ServersClient
from tempest.services.nova.json.limits_client import LimitsClient
from tempest.services.nova.json.extensions_client import ExtensionsClient
+from tempest.services.nova.json.extensions_client import SecurityGroupsClient
+
import tempest.config
@@ -40,7 +42,11 @@
self.config.nova.api_key,
self.config.nova.auth_url,
self.config.nova.tenant_name)
-
+ self.security_groups_client = SecurityGroupsClient(self.config,
+ self.config.nova.username,
+ self.config.nova.api_key,
+ self.config.nova.auth_url,
+ self.config.nova.tenant_name)
else:
#Assuming basic/native authentication
self.servers_client = ServersClient(self.config,
@@ -63,3 +69,7 @@
self.config.nova.username,
self.config.nova.api_key,
self.config.nova.auth_url)
+ self.security_groups_client = SecurityGroupsClient(self.config,
+ self.config.nova.username,
+ self.config.nova.api_key,
+ self.config.nova.auth_url)
diff --git a/tempest/services/nova/json/security_groups_client.py b/tempest/services/nova/json/security_groups_client.py
new file mode 100644
index 0000000..b365ce5
--- /dev/null
+++ b/tempest/services/nova/json/security_groups_client.py
@@ -0,0 +1,40 @@
+from tempest.common import rest_client
+import json
+
+
+class SecurityGroupsClient(object):
+
+ def __init__(self, config, username, key, auth_url, tenant_name=None):
+ self.config = config
+ self.client = rest_client.RestClient(config, username, key,
+ auth_url, 'nova', tenant_name)
+
+ def list_security_groups(self, params=None):
+ """List all security groups for a user"""
+
+ url = 'os-security-groups'
+ 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
+
+ def list_security_groups_with_detail(self, params=None):
+ """List security groups with detail"""
+
+ url = 'os-security-groups/detail'
+ 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