Merge "Change orchestration client to return one value and update tests"
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 21f2578..d3dffbf 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -68,13 +68,13 @@
                      environment=None, files=None):
         if parameters is None:
             parameters = {}
-        resp, body = cls.client.create_stack(
+        body = cls.client.create_stack(
             stack_name,
             template=template_data,
             parameters=parameters,
             environment=environment,
             files=files)
-        stack_id = resp['location'].split('/')[-1]
+        stack_id = body.response['location'].split('/')[-1]
         stack_identifier = '%s/%s' % (stack_name, stack_id)
         cls.stacks.append(stack_identifier)
         return stack_identifier
@@ -164,7 +164,7 @@
 
     def list_resources(self, stack_identifier):
         """Get a dict mapping of resource names to types."""
-        _, resources = self.client.list_resources(stack_identifier)
+        resources = self.client.list_resources(stack_identifier)
         self.assertIsInstance(resources, list)
         for res in resources:
             self.assert_fields_in_dict(res, 'logical_resource_id',
@@ -175,5 +175,5 @@
                     for r in resources)
 
     def get_stack_output(self, stack_identifier, output_key):
-        _, body = self.client.get_stack(stack_identifier)
+        body = self.client.get_stack(stack_identifier)
         return self.stack_output(body, output_key)
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 8352719..ea6d4be 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -65,14 +65,14 @@
         cls.stack_id = cls.stack_identifier.split('/')[1]
         try:
             cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
-            _, resources = cls.client.list_resources(cls.stack_identifier)
+            resources = cls.client.list_resources(cls.stack_identifier)
         except exceptions.TimeoutException as e:
             if CONF.compute_feature_enabled.console_output:
                 # attempt to log the server console to help with debugging
                 # the cause of the server not signalling the waitcondition
                 # to heat.
-                _, body = cls.client.get_resource(cls.stack_identifier,
-                                                  'Server')
+                body = cls.client.get_resource(cls.stack_identifier,
+                                               'Server')
                 server_id = body['physical_resource_id']
                 LOG.debug('Console output for %s', server_id)
                 _, output = cls.servers_client.get_console_output(
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index bf6c79c..db1ac9a 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -47,7 +47,7 @@
         cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
 
     def _list_stacks(self, expected_num=None, **filter_kwargs):
-        _, stacks = self.client.list_stacks(params=filter_kwargs)
+        stacks = self.client.list_stacks(params=filter_kwargs)
         self.assertIsInstance(stacks, list)
         if expected_num is not None:
             self.assertEqual(expected_num, len(stacks))
@@ -63,7 +63,7 @@
     @test.attr(type='gate')
     def test_stack_show(self):
         """Getting details about created stack should be possible."""
-        _, stack = self.client.get_stack(self.stack_name)
+        stack = self.client.get_stack(self.stack_name)
         self.assertIsInstance(stack, dict)
         self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
                                    'parameters', 'outputs', 'disable_rollback',
@@ -82,10 +82,10 @@
     @test.attr(type='gate')
     def test_suspend_resume_stack(self):
         """Suspend and resume a stack."""
-        _, suspend_stack = self.client.suspend_stack(self.stack_identifier)
+        self.client.suspend_stack(self.stack_identifier)
         self.client.wait_for_stack_status(self.stack_identifier,
                                           'SUSPEND_COMPLETE')
-        _, resume_stack = self.client.resume_stack(self.stack_identifier)
+        self.client.resume_stack(self.stack_identifier)
         self.client.wait_for_stack_status(self.stack_identifier,
                                           'RESUME_COMPLETE')
 
@@ -99,8 +99,8 @@
     @test.attr(type='gate')
     def test_show_resource(self):
         """Getting details about created resource should be possible."""
-        _, resource = self.client.get_resource(self.stack_identifier,
-                                               self.resource_name)
+        resource = self.client.get_resource(self.stack_identifier,
+                                            self.resource_name)
         self.assertIsInstance(resource, dict)
         self.assert_fields_in_dict(resource, 'resource_name', 'description',
                                    'links', 'logical_resource_id',
@@ -113,7 +113,7 @@
     @test.attr(type='gate')
     def test_resource_metadata(self):
         """Getting metadata for created resources should be possible."""
-        _, metadata = self.client.show_resource_metadata(
+        metadata = self.client.show_resource_metadata(
             self.stack_identifier,
             self.resource_name)
         self.assertIsInstance(metadata, dict)
@@ -122,7 +122,7 @@
     @test.attr(type='gate')
     def test_list_events(self):
         """Getting list of created events for the stack should be possible."""
-        _, events = self.client.list_events(self.stack_identifier)
+        events = self.client.list_events(self.stack_identifier)
         self.assertIsInstance(events, list)
 
         for event in events:
@@ -137,13 +137,13 @@
     @test.attr(type='gate')
     def test_show_event(self):
         """Getting details about an event should be possible."""
-        _, events = self.client.list_resource_events(self.stack_identifier,
-                                                     self.resource_name)
+        events = self.client.list_resource_events(self.stack_identifier,
+                                                  self.resource_name)
         self.assertNotEqual([], events)
         events.sort(key=lambda event: event['event_time'])
         event_id = events[0]['id']
-        _, event = self.client.show_event(self.stack_identifier,
-                                          self.resource_name, event_id)
+        event = self.client.show_event(self.stack_identifier,
+                                       self.resource_name, event_id)
         self.assertIsInstance(event, dict)
         self.assert_fields_in_dict(event, 'resource_name', 'event_time',
                                    'links', 'logical_resource_id',
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index 1da340c..772bab3 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -43,7 +43,7 @@
 
         cls.stack_id = cls.stack_identifier.split('/')[1]
         cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
-        _, resources = cls.client.list_resources(cls.stack_identifier)
+        resources = cls.client.list_resources(cls.stack_identifier)
         cls.test_resources = {}
         for resource in resources:
             cls.test_resources[resource['logical_resource_id']] = resource
@@ -70,7 +70,7 @@
 
     @test.attr(type='gate')
     def test_stack_keypairs_output(self):
-        _, stack = self.client.get_stack(self.stack_name)
+        stack = self.client.get_stack(self.stack_name)
         self.assertIsInstance(stack, dict)
 
         output_map = {}
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index d7fbd65..5cdd8b4 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -28,7 +28,7 @@
 
     @test.attr(type='smoke')
     def test_stack_list_responds(self):
-        _, stacks = self.client.list_stacks()
+        stacks = self.client.list_stacks()
         self.assertIsInstance(stacks, list)
 
     @test.attr(type='smoke')
@@ -44,20 +44,20 @@
         self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
 
         # check for stack in list
-        _, stacks = self.client.list_stacks()
+        stacks = self.client.list_stacks()
         list_ids = list([stack['id'] for stack in stacks])
         self.assertIn(stack_id, list_ids)
 
         # fetch the stack
-        _, stack = self.client.get_stack(stack_identifier)
+        stack = self.client.get_stack(stack_identifier)
         self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
 
         # fetch the stack by name
-        _, stack = self.client.get_stack(stack_name)
+        stack = self.client.get_stack(stack_name)
         self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
 
         # fetch the stack by id
-        _, stack = self.client.get_stack(stack_id)
+        stack = self.client.get_stack(stack_id)
         self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
 
         # delete the stack
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index 307468e..0288fd4 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -42,7 +42,7 @@
         cls.stack_id = cls.stack_identifier.split('/')[1]
         cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
         cls.test_resources = {}
-        _, resources = cls.client.list_resources(cls.stack_identifier)
+        resources = cls.client.list_resources(cls.stack_identifier)
         for resource in resources:
             cls.test_resources[resource['logical_resource_id']] = resource
 
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 262c576..6113cab 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -38,13 +38,13 @@
     @test.attr(type='gate')
     def test_show_template(self):
         """Getting template used to create the stack."""
-        _, template = self.client.show_template(self.stack_identifier)
+        self.client.show_template(self.stack_identifier)
 
     @test.attr(type='gate')
     def test_validate_template(self):
         """Validating template passing it content."""
-        _, parameters = self.client.validate_template(self.template,
-                                                      self.parameters)
+        self.client.validate_template(self.template,
+                                      self.parameters)
 
 
 class TemplateAWSTestJSON(TemplateYAMLTestJSON):
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 2928777..a0bbb70 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -218,7 +218,7 @@
 
     def list(self):
         client = self.client
-        _, stacks = client.list_stacks()
+        stacks = client.list_stacks()
         LOG.debug("List count, %s Stacks" % len(stacks))
         return stacks
 
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index f09f00c..18b759e 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -52,13 +52,13 @@
 
         # create the stack
         self.template = self._load_template(__file__, self.template_name)
-        _, stack = self.client.create_stack(
+        stack = self.client.create_stack(
             name=self.stack_name,
             template=self.template,
             parameters=self.parameters)
         stack = stack['stack']
 
-        _, self.stack = self.client.get_stack(stack['id'])
+        self.stack = self.client.get_stack(stack['id'])
         self.stack_identifier = '%s/%s' % (self.stack_name, self.stack['id'])
         self.addCleanup(self.delete_wrapper,
                         self.orchestration_client.delete_stack,
@@ -77,7 +77,7 @@
         self.client.wait_for_resource_status(
             sid, 'SmokeServer', 'CREATE_COMPLETE')
 
-        _, server_resource = self.client.get_resource(sid, 'SmokeServer')
+        server_resource = self.client.get_resource(sid, 'SmokeServer')
         server_id = server_resource['physical_resource_id']
         _, server = self.servers_client.get_server(server_id)
         server_ip =\
@@ -104,7 +104,7 @@
 
         self.client.wait_for_stack_status(sid, 'CREATE_COMPLETE')
 
-        _, stack = self.client.get_stack(sid)
+        stack = self.client.get_stack(sid)
 
         # This is an assert of great significance, as it means the following
         # has happened:
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index e2dd558..c813977 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -34,7 +34,7 @@
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['stacks']
+        return service_client.ResponseBodyList(resp, body['stacks'])
 
     def create_stack(self, name, disable_rollback=True, parameters=None,
                      timeout_mins=60, template=None, template_url=None,
@@ -54,7 +54,7 @@
         resp, body = self.post(uri, headers=headers, body=body)
         self.expected_success(201, resp.status)
         body = json.loads(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def update_stack(self, stack_identifier, name, disable_rollback=True,
                      parameters=None, timeout_mins=60, template=None,
@@ -73,7 +73,7 @@
         uri = "stacks/%s" % stack_identifier
         resp, body = self.put(uri, headers=headers, body=body)
         self.expected_success(202, resp.status)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def _prepare_update_create(self, name, disable_rollback=True,
                                parameters=None, timeout_mins=60,
@@ -109,7 +109,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['stack']
+        return service_client.ResponseBody(resp, body['stack'])
 
     def suspend_stack(self, stack_identifier):
         """Suspend a stack."""
@@ -117,7 +117,7 @@
         body = {'suspend': None}
         resp, body = self.post(url, json.dumps(body))
         self.expected_success(200, resp.status)
-        return resp, body
+        return service_client.ResponseBody(resp)
 
     def resume_stack(self, stack_identifier):
         """Resume a stack."""
@@ -125,7 +125,7 @@
         body = {'resume': None}
         resp, body = self.post(url, json.dumps(body))
         self.expected_success(200, resp.status)
-        return resp, body
+        return service_client.ResponseBody(resp)
 
     def list_resources(self, stack_identifier):
         """Returns the details of a single resource."""
@@ -133,7 +133,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['resources']
+        return service_client.ResponseBodyList(resp, body['resources'])
 
     def get_resource(self, stack_identifier, resource_name):
         """Returns the details of a single resource."""
@@ -141,13 +141,13 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['resource']
+        return service_client.ResponseBody(resp, body['resource'])
 
     def delete_stack(self, stack_identifier):
         """Deletes the specified Stack."""
         resp, _ = self.delete("stacks/%s" % str(stack_identifier))
         self.expected_success(204, resp.status)
-        return resp
+        return service_client.ResponseBody(resp)
 
     def wait_for_resource_status(self, stack_identifier, resource_name,
                                  status, failure_pattern='^.*_FAILED$'):
@@ -157,7 +157,7 @@
 
         while True:
             try:
-                resp, body = self.get_resource(
+                body = self.get_resource(
                     stack_identifier, resource_name)
             except exceptions.NotFound:
                 # ignore this, as the resource may not have
@@ -193,7 +193,7 @@
 
         while True:
             try:
-                resp, body = self.get_stack(stack_identifier)
+                body = self.get_stack(stack_identifier)
             except exceptions.NotFound:
                 if status == 'DELETE_COMPLETE':
                     return
@@ -222,7 +222,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['metadata']
+        return service_client.ResponseBody(resp, body['metadata'])
 
     def list_events(self, stack_identifier):
         """Returns list of all events for a stack."""
@@ -230,7 +230,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['events']
+        return service_client.ResponseBodyList(resp, body['events'])
 
     def list_resource_events(self, stack_identifier, resource_name):
         """Returns list of all events for a resource from stack."""
@@ -239,7 +239,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['events']
+        return service_client.ResponseBodyList(resp, body['events'])
 
     def show_event(self, stack_identifier, resource_name, event_id):
         """Returns the details of a single stack's event."""
@@ -248,7 +248,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body['event']
+        return service_client.ResponseBody(resp, body['event'])
 
     def show_template(self, stack_identifier):
         """Returns the template for the stack."""
@@ -256,7 +256,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def _validate_template(self, post_body):
         """Returns the validation request result."""
@@ -264,7 +264,7 @@
         resp, body = self.post('validate', post_body)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def validate_template(self, template, parameters=None):
         """Returns the validation result for a template with parameters."""
@@ -291,21 +291,21 @@
         resp, body = self.get('resource_types')
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body['resource_types']
+        return service_client.ResponseBodyList(resp, body['resource_types'])
 
     def get_resource_type(self, resource_type_name):
         """Return the schema of a resource type."""
         url = 'resource_types/%s' % resource_type_name
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
-        return json.loads(body)
+        return service_client.ResponseBody(resp, json.loads(body))
 
     def get_resource_type_template(self, resource_type_name):
         """Return the template of a resource type."""
         url = 'resource_types/%s/template' % resource_type_name
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
-        return json.loads(body)
+        return service_client.ResponseBody(resp, json.loads(body))
 
     def create_software_config(self, name=None, config=None, group=None,
                                inputs=None, outputs=None, options=None):
@@ -316,7 +316,7 @@
         resp, body = self.post(url, headers=headers, body=body)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def get_software_config(self, conf_id):
         """Returns a software configuration resource."""
@@ -324,13 +324,14 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def delete_software_config(self, conf_id):
         """Deletes a specific software configuration."""
         url = 'software_configs/%s' % str(conf_id)
         resp, _ = self.delete(url)
         self.expected_success(204, resp.status)
+        return service_client.ResponseBody(resp)
 
     def create_software_deploy(self, server_id=None, config_id=None,
                                action=None, status=None,
@@ -345,7 +346,7 @@
         resp, body = self.post(url, headers=headers, body=body)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def update_software_deploy(self, deploy_id=None, server_id=None,
                                config_id=None, action=None, status=None,
@@ -360,7 +361,7 @@
         resp, body = self.put(url, headers=headers, body=body)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def get_software_deploy_list(self):
         """Returns a list of all deployments."""
@@ -368,7 +369,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def get_software_deploy(self, deploy_id):
         """Returns a specific software deployment."""
@@ -376,7 +377,7 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def get_software_deploy_meta(self, server_id):
         """Return a config metadata for a specific server."""
@@ -384,13 +385,14 @@
         resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
-        return body
+        return service_client.ResponseBody(resp, body)
 
     def delete_software_deploy(self, deploy_id):
         """Deletes a specific software deployment."""
         url = 'software_deployments/%s' % str(deploy_id)
         resp, _ = self.delete(url)
         self.expected_success(204, resp.status)
+        return service_client.ResponseBody(resp)
 
     def _prep_software_config_create(self, name=None, conf=None, group=None,
                                      inputs=None, outputs=None, options=None):