Merge "Client supports check action"

This commit is contained in:
Jenkins 2014-09-25 09:47:06 +00:00 committed by Gerrit Code Review
commit 6089d31e30
4 changed files with 50 additions and 1 deletions

View File

@ -1622,6 +1622,34 @@ class ShellTestUserPass(ShellBase):
for r in required:
self.assertRegexpMatches(update_text, r)
@httpretty.activate
def test_stack_check(self):
self.register_keystone_auth_fixture()
expected_data = {'check': 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()
check_text = self.shell('action-check teststack2')
required = [
'stack_name',
'id',
'teststack2',
'1'
]
for r in required:
self.assertRegexpMatches(check_text, r)
@httpretty.activate
def test_stack_delete(self):
self.register_keystone_auth_fixture()

View File

@ -44,7 +44,8 @@ class StackStatusActionTest(testtools.TestCase):
('UPDATE', dict(action='UPDATE')),
('ROLLBACK', dict(action='ROLLBACK')),
('SUSPEND', dict(action='SUSPEND')),
('RESUME', dict(action='RESUME'))
('RESUME', dict(action='RESUME')),
('CHECK', dict(action='CHECK'))
], [
('IN_PROGRESS', dict(status='IN_PROGRESS')),
('FAILED', dict(status='FAILED')),

View File

@ -53,3 +53,10 @@ class ActionManager(stacks.StackChildManager):
resp, body = self.client.json_request('POST',
'/stacks/%s/actions' % stack_id,
data=body)
def check(self, stack_id):
"""Check a stack."""
body = {'check': None}
resp, body = self.client.json_request('POST',
'/stacks/%s/actions' % stack_id,
data=body)

View File

@ -306,6 +306,19 @@ def do_action_resume(hc, args):
do_stack_list(hc)
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to check.')
def do_action_check(hc, args):
'''Check that stack resources are in expected states.'''
fields = {'stack_id': args.id}
try:
hc.actions.check(**fields)
except exc.HTTPNotFound:
raise exc.CommandError('Stack not found: %s' % args.id)
else:
do_stack_list(hc)
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to describe.')
def do_describe(hc, args):