python-heatclient stack-abandon support
Adding stack-abandon support for python-heatclient. Partial-Bug: #1262267 Change-Id: Ifaec08558103137fe8288d00ba8d7188f01afe03
This commit is contained in:
parent
a2ff9eaeed
commit
a94108ab26
|
@ -69,6 +69,9 @@ Delete a stack::
|
|||
|
||||
heat stack-delete mystack
|
||||
|
||||
Abandon a stack::
|
||||
|
||||
heat stack-abandon mystack
|
||||
|
||||
BUGS
|
||||
====
|
||||
|
|
|
@ -535,6 +535,48 @@ class ShellTestUserPass(ShellBase):
|
|||
for r in required:
|
||||
self.assertRegexpMatches(list_text, r)
|
||||
|
||||
def test_stack_abandon(self):
|
||||
self._script_keystone_client()
|
||||
|
||||
resp_dict = {"stack": {
|
||||
"id": "1",
|
||||
"stack_name": "teststack",
|
||||
"stack_status": 'CREATE_COMPLETE',
|
||||
"creation_time": "2012-10-25T01:58:47Z"
|
||||
}}
|
||||
|
||||
abandoned_stack = {
|
||||
"action": "CREATE",
|
||||
"status": "COMPLETE",
|
||||
"name": "teststack",
|
||||
"id": "1",
|
||||
"resources": {
|
||||
"foo": {
|
||||
"name": "foo",
|
||||
"resource_id": "test-res-id",
|
||||
"action": "CREATE",
|
||||
"status": "COMPLETE",
|
||||
"resource_data": {},
|
||||
"metadata": {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
200,
|
||||
'OK',
|
||||
{'content-type': 'application/json'},
|
||||
jsonutils.dumps(resp_dict))
|
||||
http.HTTPClient.json_request(
|
||||
'GET', '/stacks/teststack/1').AndReturn((resp, resp_dict))
|
||||
http.HTTPClient.json_request(
|
||||
'DELETE',
|
||||
'/stacks/teststack/1/abandon').AndReturn((resp, abandoned_stack))
|
||||
|
||||
self.m.ReplayAll()
|
||||
abandon_resp = self.shell('stack-abandon teststack/1')
|
||||
self.assertEqual(abandoned_stack, jsonutils.loads(abandon_resp))
|
||||
|
||||
def test_template_show_cfn(self):
|
||||
self._script_keystone_client()
|
||||
template_data = open(os.path.join(TEST_VAR_DIR,
|
||||
|
|
|
@ -74,6 +74,12 @@ class StackOperationsTest(testtools.TestCase):
|
|||
stack.delete()
|
||||
manager.delete.assert_called_once_with('the_stack/abcd1234')
|
||||
|
||||
def test_abandon_stack(self):
|
||||
manager = MagicMock()
|
||||
stack = mock_stack(manager, 'the_stack', 'abcd1234')
|
||||
stack.abandon()
|
||||
manager.abandon.assert_called_once_with('the_stack/abcd1234')
|
||||
|
||||
def test_get_stack(self):
|
||||
manager = MagicMock()
|
||||
stack = mock_stack(manager, 'the_stack', 'abcd1234')
|
||||
|
|
|
@ -117,6 +117,19 @@ def do_stack_delete(hc, args):
|
|||
do_stack_list(hc)
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NAME or ID>',
|
||||
help='Name or ID of stack to abandon.')
|
||||
def do_stack_abandon(hc, args):
|
||||
'''Abandon the stack.'''
|
||||
fields = {'stack_id': args.id}
|
||||
try:
|
||||
stack = hc.stacks.abandon(**fields)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Stack not found: %s' % args.id)
|
||||
else:
|
||||
print(jsonutils.dumps(stack, indent=2))
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NAME or ID>',
|
||||
help='Name or ID of stack to suspend.')
|
||||
def do_action_suspend(hc, args):
|
||||
|
|
|
@ -31,6 +31,9 @@ class Stack(base.Resource):
|
|||
def delete(self):
|
||||
return self.manager.delete(self.identifier)
|
||||
|
||||
def abandon(self):
|
||||
return self.manager.abandon(self.identifier)
|
||||
|
||||
def get(self):
|
||||
# set_loaded() first ... so if we have to bail, we know we tried.
|
||||
self.set_loaded(True)
|
||||
|
@ -118,6 +121,14 @@ class StackManager(base.BaseManager):
|
|||
"""Delete a stack."""
|
||||
self._delete("/stacks/%s" % stack_id)
|
||||
|
||||
def abandon(self, stack_id):
|
||||
"""Abandon a stack."""
|
||||
stack = self.get(stack_id)
|
||||
resp, body = self.client.json_request(
|
||||
'DELETE',
|
||||
'/stacks/%s/abandon' % stack.identifier)
|
||||
return body
|
||||
|
||||
def get(self, stack_id):
|
||||
"""Get the metadata for a specific stack.
|
||||
|
||||
|
|
Loading…
Reference in New Issue