summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2015-02-16 11:30:14 +1300
committerSteve Baker <sbaker@redhat.com>2015-03-04 09:34:28 +1300
commit5475a2ee347dc81d6d3597a799dd5e5a5f2d822f (patch)
treec170e25d8f0eb41d7563a564c232e3f29760da83
parentebc16767cc967ef2c9f39093c57c96b4dd0dde1a (diff)
downloadpython-heatclient-5475a2ee347dc81d6d3597a799dd5e5a5f2d822f.tar.gz
Make ; parsing optional in format_parameters
Semicolon splitting is legacy behaviour from the old cfn client. New arguments (like deployment input values) can use format_parameters but won't want to support semicolon splitting. This change makes semicolon parsing optional. Change-Id: I1126fd8882d3ba68a03822e5f519656d78d2d535
-rw-r--r--heatclient/common/utils.py11
-rw-r--r--heatclient/tests/test_utils.py6
2 files changed, 12 insertions, 5 deletions
diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py
index 3cc1b4b..3ffb35a 100644
--- a/heatclient/common/utils.py
+++ b/heatclient/common/utils.py
@@ -117,16 +117,17 @@ def exit(msg=''):
sys.exit(1)
-def format_parameters(params):
+def format_parameters(params, parse_semicolon=True):
'''Reformat parameters into dict of format expected by the API.'''
if not params:
return {}
- # expect multiple invocations of --parameters but fall back
- # to ; delimited if only one --parameters is specified
- if len(params) == 1:
- params = params[0].split(';')
+ if parse_semicolon:
+ # expect multiple invocations of --parameters but fall back
+ # to ; delimited if only one --parameters is specified
+ if len(params) == 1:
+ params = params[0].split(';')
parameters = {}
for p in params:
diff --git a/heatclient/tests/test_utils.py b/heatclient/tests/test_utils.py
index 85be4d2..d7a786b 100644
--- a/heatclient/tests/test_utils.py
+++ b/heatclient/tests/test_utils.py
@@ -66,6 +66,12 @@ class shellTest(testtools.TestCase):
'ww7a4oAO;NQ/fD==',
'UpstreamDNS': '8.8.8.8'}, p)
+ def test_format_parameters_parse_semicolon_false(self):
+ p = utils.format_parameters(
+ ['KeyName=heat_key;UpstreamDNS=8.8.8.8;a=b'],
+ parse_semicolon=False)
+ self.assertEqual({'KeyName': 'heat_key;UpstreamDNS=8.8.8.8;a=b'}, p)
+
def test_format_parameters_multiple_values_per_pamaters(self):
p = utils.format_parameters([
'status=COMPLETE',