Merge "Add stack-update argument for reset parameters"

This commit is contained in:
Jenkins 2014-09-18 03:17:26 +00:00 committed by Gerrit Code Review
commit 346e9e2609
2 changed files with 109 additions and 0 deletions

View File

@ -1497,6 +1497,103 @@ class ShellTestUserPass(ShellBase):
for r in required:
self.assertRegexpMatches(update_text, r)
@httpretty.activate
def test_stack_update_with_existing_and_default_parameters(self):
self.register_keystone_auth_fixture()
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
template_data = open(template_file).read()
resp = fakes.FakeHTTPResponse(
202,
'Accepted',
{},
'The request is accepted for processing.')
expected_data = {
'files': {},
'environment': {},
'template': jsonutils.loads(template_data),
'parameters': {},
'clear_parameters': ['InstanceType', 'DBUsername',
'DBPassword', 'KeyPairName',
'LinuxDistribution'],
'disable_rollback': False}
http.HTTPClient.json_request(
'PATCH', '/stacks/teststack2/2',
data=expected_data,
headers={'X-Auth-Key': 'password', 'X-Auth-User': 'username'}
).AndReturn((resp, None))
fakes.script_heat_list()
self.m.ReplayAll()
update_text = self.shell(
'stack-update teststack2/2 '
'--template-file=%s '
'--enable-rollback '
'--existing '
'--clear-parameter=InstanceType '
'--clear-parameter=DBUsername '
'--clear-parameter=DBPassword '
'--clear-parameter=KeyPairName '
'--clear-parameter=LinuxDistribution' % template_file)
required = [
'stack_name',
'id',
'teststack2',
'1'
]
for r in required:
self.assertRegexpMatches(update_text, r)
@httpretty.activate
def test_stack_update_with_patched_and_default_parameters(self):
self.register_keystone_auth_fixture()
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
template_data = open(template_file).read()
resp = fakes.FakeHTTPResponse(
202,
'Accepted',
{},
'The request is accepted for processing.')
expected_data = {
'files': {},
'environment': {},
'template': jsonutils.loads(template_data),
'parameters': {'"KeyPairName': 'updated_key"'},
'clear_parameters': ['InstanceType', 'DBUsername',
'DBPassword', 'KeyPairName',
'LinuxDistribution'],
'disable_rollback': False}
http.HTTPClient.json_request(
'PATCH', '/stacks/teststack2/2',
data=expected_data,
headers={'X-Auth-Key': 'password', 'X-Auth-User': 'username'}
).AndReturn((resp, None))
fakes.script_heat_list()
self.m.ReplayAll()
update_text = self.shell(
'stack-update teststack2/2 '
'--template-file=%s '
'--enable-rollback '
'--existing '
'--parameters="KeyPairName=updated_key" '
'--clear-parameter=InstanceType '
'--clear-parameter=DBUsername '
'--clear-parameter=DBPassword '
'--clear-parameter=KeyPairName '
'--clear-parameter=LinuxDistribution' % template_file)
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

@ -368,6 +368,11 @@ def do_stack_show(hc, args):
'Parameters specified in --parameters will patch over the existing '
'values in the current stack. Parameters omitted will keep '
'the existing values.')
@utils.arg('-c', '--clear-parameter', metavar='<PARAMETER>',
help='Remove the parameters from the set of parameters of current '
'stack for the stack-update. The default value in the template '
'will be used. This can be specified multiple times.',
action='append')
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to update.')
def do_update(hc, args):
@ -409,6 +414,11 @@ def do_update(hc, args):
'Parameters specified in --parameters will patch over the existing '
'values in the current stack. Parameters omitted will keep '
'the existing values.')
@utils.arg('-c', '--clear-parameter', metavar='<PARAMETER>',
help='Remove the parameters from the set of parameters of current '
'stack for the stack-update. The default value in the template '
'will be used. This can be specified multiple times.',
action='append')
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to update.')
def do_stack_update(hc, args):
@ -434,6 +444,8 @@ def do_stack_update(hc, args):
if args.timeout:
fields['timeout_mins'] = args.timeout
if args.clear_parameter:
fields['clear_parameters'] = list(args.clear_parameter)
if args.rollback is not None:
try: