Add APIs to create and manipulate snapshots
This adds a new action on stacks to snapshots them, and specific actions to show and delete them. blueprint stack-snapshot Co-Authored-By: ala.rezmerita@cloudwatt.com Change-Id: I225b199f3a25a0b40653d654d7fab8cf9de3f242
This commit is contained in:
parent
6dd121c44d
commit
c839e90d84
|
@ -51,6 +51,9 @@
|
|||
"stacks:template": "rule:deny_stack_user",
|
||||
"stacks:update": "rule:deny_stack_user",
|
||||
"stacks:validate_template": "rule:deny_stack_user",
|
||||
"stacks:snapshot": "rule:deny_stack_user",
|
||||
"stacks:show_snapshot": "rule:deny_stack_user",
|
||||
"stacks:delete_snapshot": "rule:deny_stack_user",
|
||||
|
||||
"software_configs:create": "rule:deny_stack_user",
|
||||
"software_configs:show": "rule:deny_stack_user",
|
||||
|
|
|
@ -117,6 +117,23 @@ class API(wsgi.Router):
|
|||
action="abandon",
|
||||
conditions={'method': 'DELETE'})
|
||||
|
||||
stack_mapper.connect("stack_snapshot",
|
||||
"/stacks/{stack_name}/{stack_id}/snapshots",
|
||||
action="snapshot",
|
||||
conditions={'method': 'POST'})
|
||||
|
||||
stack_mapper.connect("stack_snapshot_show",
|
||||
"/stacks/{stack_name}/{stack_id}/snapshots/"
|
||||
"{snapshot_id}",
|
||||
action="show_snapshot",
|
||||
conditions={'method': 'GET'})
|
||||
|
||||
stack_mapper.connect("stack_snapshot_delete",
|
||||
"/stacks/{stack_name}/{stack_id}/snapshots/"
|
||||
"{snapshot_id}",
|
||||
action="delete_snapshot",
|
||||
conditions={'method': 'DELETE'})
|
||||
|
||||
# Resources
|
||||
resources_resource = resources.create_resource(conf)
|
||||
stack_path = "/{tenant_id}/stacks/{stack_name}/{stack_id}"
|
||||
|
|
|
@ -398,6 +398,22 @@ class StackController(object):
|
|||
"""
|
||||
return self.rpc_client.generate_template(req.context, type_name)
|
||||
|
||||
@util.identified_stack
|
||||
def snapshot(self, req, identity, body):
|
||||
name = body.get('name')
|
||||
return self.rpc_client.stack_snapshot(req.context, identity, name)
|
||||
|
||||
@util.identified_stack
|
||||
def show_snapshot(self, req, identity, snapshot_id):
|
||||
snapshot = self.rpc_client.show_snapshot(
|
||||
req.context, identity, snapshot_id)
|
||||
return {'snapshot': snapshot}
|
||||
|
||||
@util.identified_stack
|
||||
def delete_snapshot(self, req, identity, snapshot_id):
|
||||
self.rpc_client.delete_snapshot(req.context, identity, snapshot_id)
|
||||
raise exc.HTTPNoContent()
|
||||
|
||||
|
||||
class StackSerializer(serializers.JSONResponseSerializer):
|
||||
"""Handles serialization of specific controller method responses."""
|
||||
|
|
|
@ -481,3 +481,18 @@ class EngineClient(object):
|
|||
def delete_software_deployment(self, cnxt, deployment_id):
|
||||
return self.call(cnxt, self.make_msg('delete_software_deployment',
|
||||
deployment_id=deployment_id))
|
||||
|
||||
def stack_snapshot(self, ctxt, stack_identity, name):
|
||||
return self.call(ctxt, self.make_msg('stack_snapshot',
|
||||
stack_identity=stack_identity,
|
||||
name=name))
|
||||
|
||||
def show_snapshot(self, cnxt, stack_identity, snapshot_id):
|
||||
return self.call(cnxt, self.make_msg('show_snapshot',
|
||||
stack_identity=stack_identity,
|
||||
snapshot_id=snapshot_id))
|
||||
|
||||
def delete_snapshot(self, cnxt, stack_identity, snapshot_id):
|
||||
return self.call(cnxt, self.make_msg('delete_snapshot',
|
||||
stack_identity=stack_identity,
|
||||
snapshot_id=snapshot_id))
|
||||
|
|
|
@ -2925,6 +2925,43 @@ class RoutesTest(HeatTestCase):
|
|||
'stack_id': 'bbbb',
|
||||
})
|
||||
|
||||
def test_stack_snapshot(self):
|
||||
self.assertRoute(
|
||||
self.m,
|
||||
'/aaaa/stacks/teststack/bbbb/snapshots',
|
||||
'POST',
|
||||
'snapshot',
|
||||
'StackController',
|
||||
{
|
||||
'tenant_id': 'aaaa',
|
||||
'stack_name': 'teststack',
|
||||
'stack_id': 'bbbb',
|
||||
})
|
||||
self.assertRoute(
|
||||
self.m,
|
||||
'/aaaa/stacks/teststack/bbbb/snapshots/cccc',
|
||||
'GET',
|
||||
'show_snapshot',
|
||||
'StackController',
|
||||
{
|
||||
'tenant_id': 'aaaa',
|
||||
'stack_name': 'teststack',
|
||||
'stack_id': 'bbbb',
|
||||
'snapshot_id': 'cccc'
|
||||
})
|
||||
self.assertRoute(
|
||||
self.m,
|
||||
'/aaaa/stacks/teststack/bbbb/snapshots/cccc',
|
||||
'DELETE',
|
||||
'delete_snapshot',
|
||||
'StackController',
|
||||
{
|
||||
'tenant_id': 'aaaa',
|
||||
'stack_name': 'teststack',
|
||||
'stack_id': 'bbbb',
|
||||
'snapshot_id': 'cccc'
|
||||
})
|
||||
|
||||
def test_stack_data_template(self):
|
||||
self.assertRoute(
|
||||
self.m,
|
||||
|
|
|
@ -268,3 +268,20 @@ class EngineRpcAPITestCase(testtools.TestCase):
|
|||
deployment_id = '86729f02-4648-44d8-af44-d0ec65b6abc9'
|
||||
self._test_engine_api('delete_software_deployment', 'call',
|
||||
deployment_id=deployment_id)
|
||||
|
||||
def test_show_snapshot(self):
|
||||
snapshot_id = '86729f02-4648-44d8-af44-d0ec65b6abc9'
|
||||
self._test_engine_api('show_snapshot', 'call',
|
||||
stack_identity=self.identity,
|
||||
snapshot_id=snapshot_id)
|
||||
|
||||
def test_stack_snapshot(self):
|
||||
self._test_engine_api(
|
||||
'stack_snapshot', 'call', stack_identity=self.identity,
|
||||
name='snap1')
|
||||
|
||||
def test_delete_snapshot(self):
|
||||
snapshot_id = '86729f02-4648-44d8-af44-d0ec65b6abc9'
|
||||
self._test_engine_api('delete_snapshot', 'call',
|
||||
stack_identity=self.identity,
|
||||
snapshot_id=snapshot_id)
|
||||
|
|
Loading…
Reference in New Issue