Merge "Return complete resp from security_groups_client"
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 8dcd0b2..b4fc749 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -156,9 +156,8 @@
 
         s_name = data_utils.rand_name('securitygroup')
         s_description = data_utils.rand_name('description')
-        securitygroup =\
-            self.sg_client.create_security_group(name=s_name,
-                                                 description=s_description)
+        securitygroup = self.sg_client.create_security_group(
+            name=s_name, description=s_description)['security_group']
         self.addCleanup(self.sg_client.delete_security_group,
                         securitygroup['id'])
 
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index b2a1b98..b0a3086 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -50,9 +50,8 @@
         for i in range(2):
             name = data_utils.rand_name('securitygroup')
             description = data_utils.rand_name('description')
-            securitygroup = (self.client
-                             .create_security_group(name=name,
-                                                    description=description))
+            securitygroup = self.client.create_security_group(
+                name=name, description=description)['security_group']
             self.addCleanup(self._delete_security_group,
                             securitygroup['id'], admin=False)
             security_group_list.append(securitygroup)
@@ -63,13 +62,14 @@
             name = data_utils.rand_name('securitygroup')
             description = data_utils.rand_name('description')
             adm_securitygroup = self.adm_client.create_security_group(
-                name=name, description=description)
+                name=name, description=description)['security_group']
             self.addCleanup(self._delete_security_group,
                             adm_securitygroup['id'])
             security_group_list.append(adm_securitygroup)
 
         # Fetch all security groups based on 'all_tenants' search filter
-        fetched_list = self.adm_client.list_security_groups(all_tenants='true')
+        fetched_list = self.adm_client.list_security_groups(
+            all_tenants='true')['security_groups']
         sec_group_id_list = map(lambda sg: sg['id'], fetched_list)
         # Now check if all created Security Groups are present in fetched list
         for sec_group in security_group_list:
@@ -77,7 +77,8 @@
 
         # Fetch all security groups for non-admin user with 'all_tenants'
         # search filter
-        fetched_list = self.client.list_security_groups(all_tenants='true')
+        fetched_list = (self.client.list_security_groups(all_tenants='true')
+                        ['security_groups'])
         # Now check if all created Security Groups are present in fetched list
         for sec_group in fetched_list:
             self.assertEqual(sec_group['tenant_id'], client_tenant_id,
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 1ec2b56..894bfde 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -223,9 +223,8 @@
             name = data_utils.rand_name(cls.__name__ + "-securitygroup")
         if description is None:
             description = data_utils.rand_name('description')
-        body = \
-            cls.security_groups_client.create_security_group(
-                name=name, description=description)
+        body = cls.security_groups_client.create_security_group(
+            name=name, description=description)['security_group']
         cls.security_groups.append(body)
 
         return body
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 9c58f6f..dbbeb70 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -40,7 +40,7 @@
             security_group_list.append(body)
         # Fetch all Security Groups and verify the list
         # has all created Security Groups
-        fetched_list = self.client.list_security_groups()
+        fetched_list = self.client.list_security_groups()['security_groups']
         # Now check if all the created Security Groups are in fetched list
         missing_sgs = \
             [sg for sg in security_group_list if sg not in fetched_list]
@@ -53,7 +53,7 @@
             self.client.delete_security_group(sg['id'])
             self.client.wait_for_resource_deletion(sg['id'])
         # Now check if all the created Security Groups are deleted
-        fetched_list = self.client.list_security_groups()
+        fetched_list = self.client.list_security_groups()['security_groups']
         deleted_sgs = \
             [sg for sg in security_group_list if sg in fetched_list]
         self.assertFalse(deleted_sgs,
@@ -75,8 +75,8 @@
                          "The created Security Group name is "
                          "not equal to the requested name")
         # Now fetch the created Security Group by its 'id'
-        fetched_group = \
-            self.client.show_security_group(securitygroup['id'])
+        fetched_group = (self.client.show_security_group(securitygroup['id'])
+                         ['security_group'])
         self.assertEqual(securitygroup, fetched_group,
                          "The fetched Security Group is different "
                          "from the created Group")
@@ -143,7 +143,7 @@
                                           name=s_new_name,
                                           description=s_new_des)
         # get the security group
-        fetched_group = \
-            self.client.show_security_group(securitygroup_id)
+        fetched_group = (self.client.show_security_group(securitygroup_id)
+                         ['security_group'])
         self.assertEqual(s_new_name, fetched_group['name'])
         self.assertEqual(s_new_des, fetched_group['description'])
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index 642aca1..120d327 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -39,7 +39,7 @@
 
     def _generate_a_non_existent_security_group_id(self):
         security_group_id = []
-        body = self.client.list_security_groups()
+        body = self.client.list_security_groups()['security_groups']
         for i in range(len(body)):
             security_group_id.append(body[i]['id'])
         # Generate a non-existent security group id
@@ -122,7 +122,7 @@
     def test_delete_the_default_security_group(self):
         # Negative test:Deletion of the "default" Security Group should Fail
         default_security_group_id = None
-        body = self.client.list_security_groups()
+        body = self.client.list_security_groups()['security_groups']
         for i in range(len(body)):
             if body[i]['name'] == 'default':
                 default_security_group_id = body[i]['id']
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 1ebf117..96ce45e 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -49,7 +49,7 @@
         cls.sg_name = data_utils.rand_name('sg')
         cls.sg_desc = data_utils.rand_name('sg-desc')
         cls.sg = cls.security_groups_client.create_security_group(
-            name=cls.sg_name, description=cls.sg_desc)
+            name=cls.sg_name, description=cls.sg_desc)['security_group']
         cls.sg_id = cls.sg['id']
 
         # Server for positive tests
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 1e92e90..9517e32 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -84,7 +84,7 @@
         name = data_utils.rand_name('security')
         description = data_utils.rand_name('description')
         cls.security_group = cls.security_client.create_security_group(
-            name=name, description=description)
+            name=name, description=description)['security_group']
 
         parent_group_id = cls.security_group['id']
         ip_protocol = 'tcp'
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index a47c442..9d32b00 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -271,7 +271,7 @@
 
     def list(self):
         client = self.client
-        secgrps = client.list_security_groups()
+        secgrps = client.list_security_groups()['security_groups']
         secgrp_del = [grp for grp in secgrps if grp['name'] != 'default']
         LOG.debug("List count, %s Security Groups" % len(secgrp_del))
         return secgrp_del
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 28b71d5..0e9849f 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -909,14 +909,15 @@
         # only create a security group if the name isn't here
         # i.e. a security group may be used by another server
         # only create a router if the name isn't here
-        body = client.secgroups.list_security_groups()
+        body = client.secgroups.list_security_groups()['security_groups']
         if any(item['name'] == secgroup['name'] for item in body):
             LOG.warning("Security group '%s' already exists" %
                         secgroup['name'])
             continue
 
         body = client.secgroups.create_security_group(
-            name=secgroup['name'], description=secgroup['description'])
+            name=secgroup['name'],
+            description=secgroup['description'])['security_group']
         secgroup_id = body['id']
         # for each security group, create the rules
         for rule in secgroup['rules']:
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index c7a45e9..debc200 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -28,7 +28,7 @@
     sg_name = data_utils.rand_name('securitygroup-')
     sg_description = data_utils.rand_name('description-')
     security_group = security_groups_client.create_security_group(
-        name=sg_name, description=sg_description)
+        name=sg_name, description=sg_description)['security_group']
     if add_rule:
         security_group_rules_client.create_security_group_rule(
             parent_group_id=security_group['id'], ip_protocol='tcp',
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 67e2f86..fb573d0 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -226,7 +226,7 @@
         _client = self.security_groups_client
         _client_rules = self.security_group_rules_client
         if secgroup_id is None:
-            sgs = _client.list_security_groups()
+            sgs = _client.list_security_groups()['security_groups']
             for sg in sgs:
                 if sg['name'] == 'default':
                     secgroup_id = sg['id']
@@ -266,7 +266,7 @@
         sg_name = data_utils.rand_name(self.__class__.__name__)
         sg_desc = sg_name + " description"
         secgroup = self.security_groups_client.create_security_group(
-            name=sg_name, description=sg_desc)
+            name=sg_name, description=sg_desc)['security_group']
         self.assertEqual(secgroup['name'], sg_name)
         self.assertEqual(secgroup['description'], sg_desc)
         self.addCleanup(self.delete_wrapper,
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 4e6358e..2ad5d2d 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -87,7 +87,8 @@
         # Since no traffic is tested, we don't need to actually add rules to
         # secgroup
         secgroup = self.security_groups_client.create_security_group(
-            name='secgroup-%s' % name, description='secgroup-desc-%s' % name)
+            name='secgroup-%s' % name,
+            description='secgroup-desc-%s' % name)['security_group']
         self.addCleanupClass(self.security_groups_client.delete_security_group,
                              secgroup['id'])
         create_kwargs = {
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index c0b667b..083d03a 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -33,7 +33,7 @@
         resp, body = self.get(url)
         body = json.loads(body)
         self.validate_response(schema.list_security_groups, resp, body)
-        return service_client.ResponseBodyList(resp, body['security_groups'])
+        return service_client.ResponseBody(resp, body)
 
     def show_security_group(self, security_group_id):
         """Get the details of a Security Group."""
@@ -41,7 +41,7 @@
         resp, body = self.get(url)
         body = json.loads(body)
         self.validate_response(schema.get_security_group, resp, body)
-        return service_client.ResponseBody(resp, body['security_group'])
+        return service_client.ResponseBody(resp, body)
 
     def create_security_group(self, **kwargs):
         """
@@ -53,7 +53,7 @@
         resp, body = self.post('os-security-groups', post_body)
         body = json.loads(body)
         self.validate_response(schema.get_security_group, resp, body)
-        return service_client.ResponseBody(resp, body['security_group'])
+        return service_client.ResponseBody(resp, body)
 
     def update_security_group(self, security_group_id, **kwargs):
         """
@@ -67,7 +67,7 @@
                               post_body)
         body = json.loads(body)
         self.validate_response(schema.update_security_group, resp, body)
-        return service_client.ResponseBody(resp, body['security_group'])
+        return service_client.ResponseBody(resp, body)
 
     def delete_security_group(self, security_group_id):
         """Deletes the provided Security Group."""
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 4bbcfa9..2505a77 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -95,7 +95,7 @@
         s_name = data_utils.rand_name('sec_grp')
         s_description = data_utils.rand_name('desc')
         self.sec_grp = sec_grp_cli.create_security_group(
-            name=s_name, description=s_description)
+            name=s_name, description=s_description)['security_group']
         create_rule = sec_grp_cli.create_security_group_rule
         create_rule(parent_group_id=self.sec_grp['id'], ip_protocol='tcp',
                     from_port=22, to_port=22)
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index 490ee5b..dc7d217 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -58,7 +58,7 @@
         s_name = data_utils.rand_name('sec_grp')
         s_description = data_utils.rand_name('desc')
         self.sec_grp = sec_grp_cli.create_security_group(
-            name=s_name, description=s_description)
+            name=s_name, description=s_description)['security_group']
         create_rule = sec_grp_cli.create_security_group_rule
         create_rule(parent_group_id=self.sec_grp['id'], ip_protocol='tcp',
                     from_port=22, to_port=22)
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index f5d5a32..9456590 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -49,7 +49,8 @@
             pass
 
     secgrp_client = admin_manager.security_groups_client
-    secgrp = secgrp_client.list_security_groups(all_tenants=True)
+    secgrp = (secgrp_client.list_security_groups(all_tenants=True)
+              ['security_groups'])
     secgrp_del = [grp for grp in secgrp if grp['name'] != 'default']
     LOG.info("Cleanup::remove %s Security Group" % len(secgrp_del))
     for g in secgrp_del:
diff --git a/tempest/tests/cmd/test_javelin.py b/tempest/tests/cmd/test_javelin.py
index d1dee54..a95d400 100644
--- a/tempest/tests/cmd/test_javelin.py
+++ b/tempest/tests/cmd/test_javelin.py
@@ -270,9 +270,10 @@
     def test_create_secgroup(self):
         self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
                                               return_value=self.fake_client))
-        self.fake_client.secgroups.list_security_groups.return_value = []
+        self.fake_client.secgroups.list_security_groups.return_value = (
+            {'security_groups': []})
         self.fake_client.secgroups.create_security_group.return_value = \
-            {'id': self.fake_object['secgroup_id']}
+            {'security_group': {'id': self.fake_object['secgroup_id']}}
 
         javelin.create_secgroups([self.fake_object])