Merge "Change keypair client to return one value and update tests"
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index ce10fbe..d7884ab 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -28,12 +28,12 @@
         cls.client = cls.keypairs_client
 
     def _delete_keypair(self, keypair_name):
-        resp, _ = self.client.delete_keypair(keypair_name)
+        self.client.delete_keypair(keypair_name)
 
     def _create_keypair(self, keypair_name, pub_key=None):
-        resp, body = self.client.create_keypair(keypair_name, pub_key)
+        body = self.client.create_keypair(keypair_name, pub_key)
         self.addCleanup(self._delete_keypair, keypair_name)
-        return resp, body
+        return body
 
     @test.attr(type='gate')
     def test_keypairs_create_list_delete(self):
@@ -42,7 +42,7 @@
         key_list = list()
         for i in range(3):
             k_name = data_utils.rand_name('keypair-')
-            resp, keypair = self._create_keypair(k_name)
+            keypair = self._create_keypair(k_name)
             # Need to pop these keys so that our compare doesn't fail later,
             # as the keypair dicts from list API doesn't have them.
             keypair.pop('private_key')
@@ -50,8 +50,7 @@
             key_list.append(keypair)
         # Fetch all keypairs and verify the list
         # has all created keypairs
-        resp, fetched_list = self.client.list_keypairs()
-        self.assertEqual(200, resp.status)
+        fetched_list = self.client.list_keypairs()
         # We need to remove the extra 'keypair' element in the
         # returned dict. See comment in keypairs_client.list_keypairs()
         new_list = list()
@@ -68,7 +67,7 @@
     def test_keypair_create_delete(self):
         # Keypair should be created, verified and deleted
         k_name = data_utils.rand_name('keypair-')
-        resp, keypair = self._create_keypair(k_name)
+        keypair = self._create_keypair(k_name)
         private_key = keypair['private_key']
         key_name = keypair['name']
         self.assertEqual(key_name, k_name,
@@ -81,9 +80,8 @@
     def test_get_keypair_detail(self):
         # Keypair should be created, Got details by name and deleted
         k_name = data_utils.rand_name('keypair-')
-        resp, keypair = self._create_keypair(k_name)
-        resp, keypair_detail = self.client.get_keypair(k_name)
-        self.assertEqual(200, resp.status)
+        self._create_keypair(k_name)
+        keypair_detail = self.client.get_keypair(k_name)
         self.assertIn('name', keypair_detail)
         self.assertIn('public_key', keypair_detail)
         self.assertEqual(keypair_detail['name'], k_name,
@@ -106,7 +104,7 @@
                    "LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
                    "XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
                    "snSA8wzBx3A/8y9Pp1B nova@ubuntu")
-        resp, keypair = self._create_keypair(k_name, pub_key)
+        keypair = self._create_keypair(k_name, pub_key)
         self.assertFalse('private_key' in keypair,
                          "Field private_key is not empty!")
         key_name = keypair['name']
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 2cc6f00..4e06d6c 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -66,13 +66,11 @@
     def test_create_keypair_with_duplicate_name(self):
         # Keypairs with duplicate names should not be created
         k_name = data_utils.rand_name('keypair-')
-        resp, _ = self.client.create_keypair(k_name)
-        self.assertEqual(200, resp.status)
+        self.client.create_keypair(k_name)
         # Now try the same keyname to create another key
         self.assertRaises(exceptions.Conflict, self._create_keypair,
                           k_name)
-        resp, _ = self.client.delete_keypair(k_name)
-        self.assertEqual(202, resp.status)
+        self.client.delete_keypair(k_name)
 
     @test.attr(type=['negative', 'gate'])
     def test_create_keypair_with_empty_name_string(self):
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index aba6dff..d31b320 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -62,8 +62,8 @@
         # Specify a keypair while creating a server
 
         key_name = data_utils.rand_name('key')
-        resp, keypair = self.keypairs_client.create_keypair(key_name)
-        resp, body = self.keypairs_client.list_keypairs()
+        self.keypairs_client.create_keypair(key_name)
+        self.keypairs_client.list_keypairs()
         resp, server = self.create_test_server(key_name=key_name)
         self.assertEqual('202', resp['status'])
         self.client.wait_for_server_status(server['id'], 'ACTIVE')
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index fda4107..cdbaee8 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -68,8 +68,7 @@
         cls.image = cls.images_client.get_image(image_id)
 
         cls.keypairname = data_utils.rand_name('keypair')
-        resp, keypair = \
-            cls.keypairs_client.create_keypair(cls.keypairname)
+        cls.keypairs_client.create_keypair(cls.keypairname)
 
         name = data_utils.rand_name('security')
         description = data_utils.rand_name('description')
@@ -202,7 +201,7 @@
         finally:
             # Next request the base_url is back to normal
             if (resp['status'] is not None):
-                resp, _ = self.alt_keypairs_client.delete_keypair(k_name)
+                self.alt_keypairs_client.delete_keypair(k_name)
                 LOG.error("Create keypair request should not happen "
                           "if the tenant id does not match the current user")
 
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index d3dffbf..97777db 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -97,7 +97,7 @@
     @classmethod
     def _create_keypair(cls, name_start='keypair-heat-'):
         kp_name = data_utils.rand_name(name_start)
-        _, body = cls.keypairs_client.create_keypair(kp_name)
+        body = cls.keypairs_client.create_keypair(kp_name)
         cls.keypairs.append(kp_name)
         return body
 
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 6f3b50f..9c4a5dc 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -244,7 +244,7 @@
 
     def list(self):
         client = self.client
-        _, keypairs = client.list_keypairs()
+        keypairs = client.list_keypairs()
         LOG.debug("List count, %s Keypairs" % len(keypairs))
         return keypairs
 
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 0fcc75b..b1f5cce 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -160,7 +160,7 @@
             client = self.keypairs_client
         name = data_utils.rand_name(self.__class__.__name__)
         # We don't need to create a keypair by pubkey in scenario
-        resp, body = client.create_keypair(name)
+        body = client.create_keypair(name)
         self.addCleanup(client.delete_keypair, name)
         return body
 
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 69dd9ae..18729c3 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -31,13 +31,13 @@
         # For now we shall adhere to the spec, but the spec for keypairs
         # is yet to be found
         self.validate_response(common_schema.list_keypairs, resp, body)
-        return resp, body['keypairs']
+        return service_client.ResponseBodyList(resp, body['keypairs'])
 
     def get_keypair(self, key_name):
         resp, body = self.get("os-keypairs/%s" % str(key_name))
         body = json.loads(body)
         self.validate_response(schema.get_keypair, resp, body)
-        return resp, body['keypair']
+        return service_client.ResponseBody(resp, body['keypair'])
 
     def create_keypair(self, name, pub_key=None):
         post_body = {'keypair': {'name': name}}
@@ -47,9 +47,9 @@
         resp, body = self.post("os-keypairs", body=post_body)
         body = json.loads(body)
         self.validate_response(schema.create_keypair, resp, body)
-        return resp, body['keypair']
+        return service_client.ResponseBody(resp, body['keypair'])
 
     def delete_keypair(self, key_name):
         resp, body = self.delete("os-keypairs/%s" % str(key_name))
         self.validate_response(schema.delete_keypair, resp, body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index aa3cad0..3c052ac 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -24,7 +24,7 @@
 
     def _create_keypair(self):
         keyname = data_utils.rand_name("key")
-        _, self.key = self.manager.keypairs_client.create_keypair(keyname)
+        self.key = self.manager.keypairs_client.create_keypair(keyname)
 
     def _delete_keypair(self):
         self.manager.keypairs_client.delete_keypair(self.key['name'])
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 94d4b30..b52eca9 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -37,7 +37,7 @@
         except Exception:
             pass
 
-    _, keypairs = admin_manager.keypairs_client.list_keypairs()
+    keypairs = admin_manager.keypairs_client.list_keypairs()
     LOG.info("Cleanup::remove %s keypairs" % len(keypairs))
     for k in keypairs:
         try: