Full response for Orchestration client methods

Provide the entire response object for all methods of the
OrchestrationClient

partially implements: blueprint method-return-value-and-move-service-clients-to-lib

Change-Id: I6db8f17335a2dfb9baaa61cfd22353d5e4fc538a
This commit is contained in:
Anusha Ramineni 2015-08-18 08:33:09 +05:30
parent c29370c518
commit ab6c3a3843
9 changed files with 35 additions and 32 deletions

View File

@ -163,7 +163,7 @@ class BaseOrchestrationTest(tempest.test.BaseTestCase):
def list_resources(self, stack_identifier): def list_resources(self, stack_identifier):
"""Get a dict mapping of resource names to types.""" """Get a dict mapping of resource names to types."""
resources = self.client.list_resources(stack_identifier) resources = self.client.list_resources(stack_identifier)['resources']
self.assertIsInstance(resources, list) self.assertIsInstance(resources, list)
for res in resources: for res in resources:
self.assert_fields_in_dict(res, 'logical_resource_id', self.assert_fields_in_dict(res, 'logical_resource_id',
@ -174,5 +174,5 @@ class BaseOrchestrationTest(tempest.test.BaseTestCase):
for r in resources) for r in resources)
def get_stack_output(self, stack_identifier, output_key): def get_stack_output(self, stack_identifier, output_key):
body = self.client.show_stack(stack_identifier) body = self.client.show_stack(stack_identifier)['stack']
return self.stack_output(body, output_key) return self.stack_output(body, output_key)

View File

@ -75,7 +75,8 @@ class NeutronResourcesTestJSON(base.BaseOrchestrationTest):
cls.stack_id = cls.stack_identifier.split('/')[1] cls.stack_id = cls.stack_identifier.split('/')[1]
try: try:
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE') 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)
['resources'])
except exceptions.TimeoutException as e: except exceptions.TimeoutException as e:
if CONF.compute_feature_enabled.console_output: if CONF.compute_feature_enabled.console_output:
# attempt to log the server console to help with debugging # attempt to log the server console to help with debugging

View File

@ -47,7 +47,7 @@ class StacksTestJSON(base.BaseOrchestrationTest):
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE') cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
def _list_stacks(self, expected_num=None, **filter_kwargs): 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)['stacks']
self.assertIsInstance(stacks, list) self.assertIsInstance(stacks, list)
if expected_num is not None: if expected_num is not None:
self.assertEqual(expected_num, len(stacks)) self.assertEqual(expected_num, len(stacks))
@ -63,7 +63,7 @@ class StacksTestJSON(base.BaseOrchestrationTest):
@test.idempotent_id('992f96e3-41ee-4ff6-91c7-bcfb670c0919') @test.idempotent_id('992f96e3-41ee-4ff6-91c7-bcfb670c0919')
def test_stack_show(self): def test_stack_show(self):
"""Getting details about created stack should be possible.""" """Getting details about created stack should be possible."""
stack = self.client.show_stack(self.stack_name) stack = self.client.show_stack(self.stack_name)['stack']
self.assertIsInstance(stack, dict) self.assertIsInstance(stack, dict)
self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links', self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
'parameters', 'outputs', 'disable_rollback', 'parameters', 'outputs', 'disable_rollback',
@ -100,7 +100,7 @@ class StacksTestJSON(base.BaseOrchestrationTest):
def test_show_resource(self): def test_show_resource(self):
"""Getting details about created resource should be possible.""" """Getting details about created resource should be possible."""
resource = self.client.show_resource(self.stack_identifier, resource = self.client.show_resource(self.stack_identifier,
self.resource_name) self.resource_name)['resource']
self.assertIsInstance(resource, dict) self.assertIsInstance(resource, dict)
self.assert_fields_in_dict(resource, 'resource_name', 'description', self.assert_fields_in_dict(resource, 'resource_name', 'description',
'links', 'logical_resource_id', 'links', 'logical_resource_id',
@ -115,14 +115,14 @@ class StacksTestJSON(base.BaseOrchestrationTest):
"""Getting metadata for created resources should be possible.""" """Getting metadata for created resources should be possible."""
metadata = self.client.show_resource_metadata( metadata = self.client.show_resource_metadata(
self.stack_identifier, self.stack_identifier,
self.resource_name) self.resource_name)['metadata']
self.assertIsInstance(metadata, dict) self.assertIsInstance(metadata, dict)
self.assertEqual(['Tom', 'Stinky'], metadata.get('kittens', None)) self.assertEqual(['Tom', 'Stinky'], metadata.get('kittens', None))
@test.idempotent_id('46567533-0a7f-483b-8942-fa19e0f17839') @test.idempotent_id('46567533-0a7f-483b-8942-fa19e0f17839')
def test_list_events(self): def test_list_events(self):
"""Getting list of created events for the stack should be possible.""" """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)['events']
self.assertIsInstance(events, list) self.assertIsInstance(events, list)
for event in events: for event in events:
@ -138,12 +138,12 @@ class StacksTestJSON(base.BaseOrchestrationTest):
def test_show_event(self): def test_show_event(self):
"""Getting details about an event should be possible.""" """Getting details about an event should be possible."""
events = self.client.list_resource_events(self.stack_identifier, events = self.client.list_resource_events(self.stack_identifier,
self.resource_name) self.resource_name)['events']
self.assertNotEqual([], events) self.assertNotEqual([], events)
events.sort(key=lambda event: event['event_time']) events.sort(key=lambda event: event['event_time'])
event_id = events[0]['id'] event_id = events[0]['id']
event = self.client.show_event(self.stack_identifier, event = self.client.show_event(self.stack_identifier,
self.resource_name, event_id) self.resource_name, event_id)['event']
self.assertIsInstance(event, dict) self.assertIsInstance(event, dict)
self.assert_fields_in_dict(event, 'resource_name', 'event_time', self.assert_fields_in_dict(event, 'resource_name', 'event_time',
'links', 'logical_resource_id', 'links', 'logical_resource_id',

View File

@ -43,7 +43,8 @@ class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
cls.stack_id = cls.stack_identifier.split('/')[1] cls.stack_id = cls.stack_identifier.split('/')[1]
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE') 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)
['resources'])
cls.test_resources = {} cls.test_resources = {}
for resource in resources: for resource in resources:
cls.test_resources[resource['logical_resource_id']] = resource cls.test_resources[resource['logical_resource_id']] = resource
@ -70,7 +71,7 @@ class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
@test.idempotent_id('8d77dec7-91fd-45a6-943d-5abd45e338a4') @test.idempotent_id('8d77dec7-91fd-45a6-943d-5abd45e338a4')
def test_stack_keypairs_output(self): def test_stack_keypairs_output(self):
stack = self.client.show_stack(self.stack_name) stack = self.client.show_stack(self.stack_name)['stack']
self.assertIsInstance(stack, dict) self.assertIsInstance(stack, dict)
output_map = {} output_map = {}

View File

@ -20,7 +20,7 @@ class ResourceTypesTest(base.BaseOrchestrationTest):
@test.idempotent_id('7123d082-3577-4a30-8f00-f805327c4ffd') @test.idempotent_id('7123d082-3577-4a30-8f00-f805327c4ffd')
def test_resource_type_list(self): def test_resource_type_list(self):
"""Verify it is possible to list resource types.""" """Verify it is possible to list resource types."""
resource_types = self.client.list_resource_types() resource_types = self.client.list_resource_types()['resource_types']
self.assertIsInstance(resource_types, list) self.assertIsInstance(resource_types, list)
self.assertIn('OS::Nova::Server', resource_types) self.assertIn('OS::Nova::Server', resource_types)
@ -28,7 +28,7 @@ class ResourceTypesTest(base.BaseOrchestrationTest):
@test.idempotent_id('0e85a483-828b-4a28-a0e3-f0a21809192b') @test.idempotent_id('0e85a483-828b-4a28-a0e3-f0a21809192b')
def test_resource_type_show(self): def test_resource_type_show(self):
"""Verify it is possible to get schema about resource types.""" """Verify it is possible to get schema about resource types."""
resource_types = self.client.list_resource_types() resource_types = self.client.list_resource_types()['resource_types']
self.assertNotEmpty(resource_types) self.assertNotEmpty(resource_types)
for resource_type in resource_types: for resource_type in resource_types:

View File

@ -30,7 +30,7 @@ class StacksTestJSON(base.BaseOrchestrationTest):
@test.attr(type='smoke') @test.attr(type='smoke')
@test.idempotent_id('d35d628c-07f6-4674-85a1-74db9919e986') @test.idempotent_id('d35d628c-07f6-4674-85a1-74db9919e986')
def test_stack_list_responds(self): def test_stack_list_responds(self):
stacks = self.client.list_stacks() stacks = self.client.list_stacks()['stacks']
self.assertIsInstance(stacks, list) self.assertIsInstance(stacks, list)
@test.attr(type='smoke') @test.attr(type='smoke')
@ -47,20 +47,20 @@ class StacksTestJSON(base.BaseOrchestrationTest):
self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
# check for stack in list # check for stack in list
stacks = self.client.list_stacks() stacks = self.client.list_stacks()['stacks']
list_ids = list([stack['id'] for stack in stacks]) list_ids = list([stack['id'] for stack in stacks])
self.assertIn(stack_id, list_ids) self.assertIn(stack_id, list_ids)
# fetch the stack # fetch the stack
stack = self.client.show_stack(stack_identifier) stack = self.client.show_stack(stack_identifier)['stack']
self.assertEqual('CREATE_COMPLETE', stack['stack_status']) self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by name # fetch the stack by name
stack = self.client.show_stack(stack_name) stack = self.client.show_stack(stack_name)['stack']
self.assertEqual('CREATE_COMPLETE', stack['stack_status']) self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by id # fetch the stack by id
stack = self.client.show_stack(stack_id) stack = self.client.show_stack(stack_id)['stack']
self.assertEqual('CREATE_COMPLETE', stack['stack_status']) self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# delete the stack # delete the stack

View File

@ -55,7 +55,8 @@ class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
cls.stack_id = cls.stack_identifier.split('/')[1] cls.stack_id = cls.stack_identifier.split('/')[1]
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE') cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
cls.test_resources = {} cls.test_resources = {}
resources = cls.client.list_resources(cls.stack_identifier) resources = (cls.client.list_resources(cls.stack_identifier)
['resources'])
for resource in resources: for resource in resources:
cls.test_resources[resource['logical_resource_id']] = resource cls.test_resources[resource['logical_resource_id']] = resource

View File

@ -220,7 +220,7 @@ class StackService(BaseService):
def list(self): def list(self):
client = self.client client = self.client
stacks = client.list_stacks() stacks = client.list_stacks()['stacks']
LOG.debug("List count, %s Stacks" % len(stacks)) LOG.debug("List count, %s Stacks" % len(stacks))
return stacks return stacks

View File

@ -36,7 +36,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(uri) resp, body = self.get(uri)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBodyList(resp, body['stacks']) return service_client.ResponseBody(resp, body)
def create_stack(self, name, disable_rollback=True, parameters=None, def create_stack(self, name, disable_rollback=True, parameters=None,
timeout_mins=60, template=None, template_url=None, timeout_mins=60, template=None, template_url=None,
@ -111,7 +111,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBody(resp, body['stack']) return service_client.ResponseBody(resp, body)
def suspend_stack(self, stack_identifier): def suspend_stack(self, stack_identifier):
"""Suspend a stack.""" """Suspend a stack."""
@ -135,7 +135,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBodyList(resp, body['resources']) return service_client.ResponseBody(resp, body)
def show_resource(self, stack_identifier, resource_name): def show_resource(self, stack_identifier, resource_name):
"""Returns the details of a single resource.""" """Returns the details of a single resource."""
@ -143,7 +143,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBody(resp, body['resource']) return service_client.ResponseBody(resp, body)
def delete_stack(self, stack_identifier): def delete_stack(self, stack_identifier):
"""Deletes the specified Stack.""" """Deletes the specified Stack."""
@ -160,7 +160,7 @@ class OrchestrationClient(service_client.ServiceClient):
while True: while True:
try: try:
body = self.show_resource( body = self.show_resource(
stack_identifier, resource_name) stack_identifier, resource_name)['resource']
except lib_exc.NotFound: except lib_exc.NotFound:
# ignore this, as the resource may not have # ignore this, as the resource may not have
# been created yet # been created yet
@ -195,7 +195,7 @@ class OrchestrationClient(service_client.ServiceClient):
while True: while True:
try: try:
body = self.show_stack(stack_identifier) body = self.show_stack(stack_identifier)['stack']
except lib_exc.NotFound: except lib_exc.NotFound:
if status == 'DELETE_COMPLETE': if status == 'DELETE_COMPLETE':
return return
@ -224,7 +224,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBody(resp, body['metadata']) return service_client.ResponseBody(resp, body)
def list_events(self, stack_identifier): def list_events(self, stack_identifier):
"""Returns list of all events for a stack.""" """Returns list of all events for a stack."""
@ -232,7 +232,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBodyList(resp, body['events']) return service_client.ResponseBody(resp, body)
def list_resource_events(self, stack_identifier, resource_name): def list_resource_events(self, stack_identifier, resource_name):
"""Returns list of all events for a resource from stack.""" """Returns list of all events for a resource from stack."""
@ -241,7 +241,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBodyList(resp, body['events']) return service_client.ResponseBody(resp, body)
def show_event(self, stack_identifier, resource_name, event_id): def show_event(self, stack_identifier, resource_name, event_id):
"""Returns the details of a single stack's event.""" """Returns the details of a single stack's event."""
@ -250,7 +250,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get(url) resp, body = self.get(url)
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBody(resp, body['event']) return service_client.ResponseBody(resp, body)
def show_template(self, stack_identifier): def show_template(self, stack_identifier):
"""Returns the template for the stack.""" """Returns the template for the stack."""
@ -293,7 +293,7 @@ class OrchestrationClient(service_client.ServiceClient):
resp, body = self.get('resource_types') resp, body = self.get('resource_types')
self.expected_success(200, resp.status) self.expected_success(200, resp.status)
body = json.loads(body) body = json.loads(body)
return service_client.ResponseBodyList(resp, body['resource_types']) return service_client.ResponseBody(resp, body)
def show_resource_type(self, resource_type_name): def show_resource_type(self, resource_type_name):
"""Return the schema of a resource type.""" """Return the schema of a resource type."""