Merge "Add Heat REST API action for cancel update stack"

This commit is contained in:
Jenkins 2014-09-15 01:51:59 +00:00 committed by Gerrit Code Review
commit 084058ae9e
2 changed files with 29 additions and 1 deletions

View File

@ -27,7 +27,11 @@ class ActionController(object):
# Define request scope (must match what is in policy.json)
REQUEST_SCOPE = 'actions'
ACTIONS = (SUSPEND, RESUME, CHECK) = ('suspend', 'resume', 'check')
ACTIONS = (
SUSPEND, RESUME, CHECK, CANCEL_UPDATE
) = (
'suspend', 'resume', 'check', 'cancel_update'
)
def __init__(self, options):
self.options = options
@ -56,6 +60,8 @@ class ActionController(object):
self.rpc_client.stack_resume(req.context, identity)
elif ac == self.CHECK:
self.rpc_client.stack_check(req.context, identity)
elif ac == self.CANCEL_UPDATE:
self.rpc_client.stack_cancel_update(req.context, identity)
else:
raise exc.HTTPInternalServerError(_("Unexpected action %s") % ac)

View File

@ -3328,6 +3328,28 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
self.assertIsNone(result)
self.m.VerifyAll()
def test_action_cancel_update(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'cancel_update': None}
req = self._post(stack_identity._tenant_path() + '/actions',
data=json.dumps(body))
self.m.StubOutWithMock(rpc_client.EngineClient, 'call')
rpc_client.EngineClient.call(
req.context,
('stack_cancel_update', {'stack_identity': stack_identity})
).AndReturn(None)
self.m.ReplayAll()
result = self.controller.action(req, tenant_id=self.tenant,
stack_name=stack_identity.stack_name,
stack_id=stack_identity.stack_id,
body=body)
self.assertIsNone(result)
self.m.VerifyAll()
def test_action_badaction(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
stack_identity = identifier.HeatIdentifier(self.tenant,