Add APIs implementation for output functions

APIImpact

Add new APIs for showing and listing stack outputs.
It can be used by heat client and separately for
getting stack outputs.

implements bp api-call-output

Change-Id: Ia24b24f59e2c592801e4e670ba5510f642ecf45c
This commit is contained in:
Peter Razumovsky 2015-10-21 16:44:16 +03:00
parent 1c22402b2f
commit 2e76bb0716
8 changed files with 83 additions and 2 deletions

View File

@ -62,6 +62,8 @@
"stacks:delete_snapshot": "rule:deny_stack_user",
"stacks:list_snapshots": "rule:deny_stack_user",
"stacks:restore_snapshot": "rule:deny_stack_user",
"stacks:list_outputs": "rule:deny_stack_user",
"stacks:show_output": "rule:deny_stack_user",
"software_configs:global_index": "rule:deny_everybody",
"software_configs:index": "rule:deny_stack_user",

View File

@ -265,6 +265,21 @@ class API(wsgi.Router):
'{snapshot_id}/restore',
'action': 'restore_snapshot',
'method': 'POST'
},
# Stack outputs
{
'name': 'stack_output_list',
'url': '/stacks/{stack_name}/{stack_id}/outputs',
'action': 'list_outputs',
'method': 'GET'
},
{
'name': 'stack_output_show',
'url': '/stacks/{stack_name}/{stack_id}/outputs/'
'{output_key}',
'action': 'show_output',
'method': 'GET'
}
])

View File

@ -628,6 +628,19 @@ class StackController(object):
self.rpc_client.stack_restore(req.context, identity, snapshot_id)
raise exc.HTTPAccepted()
@util.identified_stack
def list_outputs(self, req, identity):
return {
'outputs': self.rpc_client.list_outputs(
req.context, identity)
}
@util.identified_stack
def show_output(self, req, identity, output_key):
return {'output': self.rpc_client.show_output(req.context,
identity,
output_key)}
class StackSerializer(serializers.JSONResponseSerializer):
"""Handles serialization of specific controller method responses."""

View File

@ -279,7 +279,7 @@ class EngineService(service.Service):
by the RPC caller.
"""
RPC_API_VERSION = '1.18'
RPC_API_VERSION = '1.19'
def __init__(self, host, topic):
super(EngineService, self).__init__()

View File

@ -37,6 +37,7 @@ class EngineClient(object):
1.16 - Adds version, type_name to list_resource_types()
1.17 - Add files to validate_template
1.18 - Add show_nested to validate_template
1.19 - Add show_output and list_outputs for returning stack outputs
"""
BASE_RPC_API_VERSION = '1.0'
@ -686,3 +687,14 @@ class EngineClient(object):
def list_services(self, cnxt):
return self.call(cnxt, self.make_msg('list_services'), version='1.4')
def list_outputs(self, cntx, stack_identity):
return self.call(cntx, self.make_msg('list_outputs',
stack_identity=stack_identity),
version='1.19')
def show_output(self, cntx, stack_identity, output_key):
return self.call(cntx, self.make_msg('show_output',
stack_identity=stack_identity,
output_key=output_key),
version='1.19')

View File

@ -235,6 +235,34 @@ class RoutesTest(common.HeatTestCase):
'snapshot_id': 'cccc'
})
def test_stack_outputs(self):
self.assertRoute(
self.m,
'/aaaa/stacks/teststack/bbbb/outputs',
'GET',
'list_outputs',
'StackController',
{
'tenant_id': 'aaaa',
'stack_name': 'teststack',
'stack_id': 'bbbb'
}
)
self.assertRoute(
self.m,
'/aaaa/stacks/teststack/bbbb/outputs/cccc',
'GET',
'show_output',
'StackController',
{
'tenant_id': 'aaaa',
'stack_name': 'teststack',
'stack_id': 'bbbb',
'output_key': 'cccc'
}
)
def test_stack_data_template(self):
self.assertRoute(
self.m,

View File

@ -39,7 +39,7 @@ class ServiceEngineTest(common.HeatTestCase):
def test_make_sure_rpc_version(self):
self.assertEqual(
'1.18',
'1.19',
service.EngineService.RPC_API_VERSION,
('RPC version is changed, please update this test to new version '
'and make sure additional test cases are added for RPC APIs '

View File

@ -364,3 +364,14 @@ class EngineRpcAPITestCase(common.HeatTestCase):
def test_list_services(self):
self._test_engine_api('list_services', 'call', version='1.4')
def test_stack_list_outputs(self):
self._test_engine_api(
'list_outputs', 'call', stack_identity=self.identity,
version='1.19'
)
def test_stack_show_output(self):
self._test_engine_api(
'show_output', 'call', stack_identity=self.identity,
output_key='test', version='1.19')