Merge "Make environment-action-call command accept JSON arguments"
This commit is contained in:
commit
5ecacc7f88
|
@ -501,10 +501,24 @@ class ShellCommandTest(ShellTest):
|
|||
self.make_env()
|
||||
self.register_keystone_discovery_fixture(m_requests)
|
||||
self.register_keystone_token_fixture(m_requests)
|
||||
self.shell('environment-action-call 12345 --action-id 54321 '
|
||||
'--arguments foo=bar')
|
||||
self.shell("""environment-action-call 12345 --action-id 54321
|
||||
--arguments foo=bar
|
||||
dictArg={"key1":"value1","key2":"value2"}
|
||||
listArg=["item1","item2","item3"]
|
||||
nullArg=null
|
||||
stringArg="null"
|
||||
intArg=5
|
||||
compoundArg=["foo",14,{"key1":null,"key2":8}]""")
|
||||
self.client.actions.call.assert_called_once_with(
|
||||
'12345', '54321', arguments={'foo': 'bar'})
|
||||
'12345', '54321', arguments={
|
||||
'foo': 'bar',
|
||||
'dictArg': {u'key1': u'value1', u'key2': u'value2'},
|
||||
'listArg': [u'item1', u'item2', u'item3'],
|
||||
'nullArg': None,
|
||||
'stringArg': u'null',
|
||||
'intArg': 5,
|
||||
'compoundArg': [u'foo', 14, {u'key1': None, u'key2': 8}]
|
||||
})
|
||||
|
||||
@mock.patch('muranoclient.v1.actions.ActionManager')
|
||||
@requests_mock.mock()
|
||||
|
|
|
@ -193,6 +193,11 @@ def do_environment_action_call(mc, args):
|
|||
"Argument should be in form of KEY=VALUE. Found: {0}".format(
|
||||
argument))
|
||||
k, v = argument.split('=', 1)
|
||||
try:
|
||||
v = json.loads(v)
|
||||
except ValueError:
|
||||
# treat value as a string if it doesn't load as json
|
||||
pass
|
||||
arguments[k] = v
|
||||
task_id = mc.actions.call(
|
||||
args.id, args.action_id, arguments=arguments)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
upgrade:
|
||||
- environment-action-call command now accepts action argument values of any
|
||||
type in JSON format, for example
|
||||
environment-action-call $ENV_ID --action-id $ACT_ID --arguments
|
||||
foo=bar listArg='["item1", "item2", "item3"]' nullArg=null
|
||||
stringArg='"null"' intArg=5
|
Loading…
Reference in New Issue