Add 'cancel_update' action and command

Change-Id: I66590110cc065622a8af03286c272a658bc12646
Implements: blueprint cancel-update-stack
This commit is contained in:
Steve Baker 2014-09-16 13:24:17 +12:00
parent a30d04d79e
commit e549c0ef6c
3 changed files with 48 additions and 0 deletions

View File

@ -1594,6 +1594,34 @@ class ShellTestUserPass(ShellBase):
for r in required:
self.assertRegexpMatches(update_text, r)
@httpretty.activate
def test_stack_cancel_update(self):
self.register_keystone_auth_fixture()
expected_data = {'cancel_update': None}
resp = fakes.FakeHTTPResponse(
202,
'Accepted',
{},
'The request is accepted for processing.')
http.HTTPClient.json_request(
'POST', '/stacks/teststack2/actions',
data=expected_data
).AndReturn((resp, None))
fakes.script_heat_list()
self.m.ReplayAll()
update_text = self.shell('stack-cancel-update teststack2')
required = [
'stack_name',
'id',
'teststack2',
'1'
]
for r in required:
self.assertRegexpMatches(update_text, r)
@httpretty.activate
def test_stack_delete(self):
self.register_keystone_auth_fixture()

View File

@ -46,3 +46,10 @@ class ActionManager(stacks.StackChildManager):
resp, body = self.client.json_request('POST',
'/stacks/%s/actions' % stack_id,
data=body)
def cancel_update(self, stack_id):
"""Cancel running update of a stack."""
body = {'cancel_update': None}
resp, body = self.client.json_request('POST',
'/stacks/%s/actions' % stack_id,
data=body)

View File

@ -464,6 +464,19 @@ def do_stack_update(hc, args):
do_stack_list(hc)
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to cancel update for.')
def do_stack_cancel_update(hc, args):
'''Cancel currently running update of the stack.'''
fields = {'stack_id': args.id}
try:
hc.actions.cancel_update(**fields)
except exc.HTTPNotFound:
raise exc.CommandError('Stack not found: %s' % args.id)
else:
do_stack_list(hc)
def do_list(hc):
'''DEPRECATED! Use stack-list instead.'''
logger.warning('DEPRECATED! Use stack-list instead.')