Add Heat REST API action for cancel update stack

Implements blueprint cancel-update-stack (partial)

Change-Id: I5bc5ceebc6c0962540b7fc5f3f7fd3703431a8e7
This commit is contained in:
Pavlo Shchelokovskyy 2014-08-26 12:42:46 +03:00
parent a75f055caf
commit f94c175df0
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

@ -3322,6 +3322,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,