Expose the --run-sync Action Execution parameter on the CLI
This allows for actions to be saved and ran synchronously. See the dependant review for more details. Depends-On: I4417750fd5ff47016357655370410e9e7348cc25 Change-Id: I00c6301394512e123436ca6c5650827c2475308e
This commit is contained in:
@@ -121,6 +121,12 @@ class Create(command.ShowOne):
|
||||
action='store_true',
|
||||
help='Save the result into DB.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--run-sync',
|
||||
dest='run_sync',
|
||||
action='store_true',
|
||||
help='Run the action synchronously.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-t',
|
||||
'--target',
|
||||
@@ -136,6 +142,9 @@ class Create(command.ShowOne):
|
||||
if parsed_args.save_result:
|
||||
params['save_result'] = parsed_args.save_result
|
||||
|
||||
if parsed_args.run_sync:
|
||||
params['run_sync'] = parsed_args.run_sync
|
||||
|
||||
if parsed_args.target:
|
||||
params['target'] = parsed_args.target
|
||||
|
||||
@@ -154,7 +163,7 @@ class Create(command.ShowOne):
|
||||
**params
|
||||
)
|
||||
|
||||
if parsed_args.save_result:
|
||||
if not parsed_args.run_sync and parsed_args.save_result:
|
||||
return format(action_ex)
|
||||
else:
|
||||
self.app.stdout.write("%s\n" % action_ex.output)
|
||||
|
@@ -87,6 +87,38 @@ class TestCLIActionExecutions(base.BaseCommandTest):
|
||||
result[1]
|
||||
)
|
||||
|
||||
def test_create_run_sync(self):
|
||||
(self.client.action_executions.create.
|
||||
return_value) = ACTION_EX_WITH_OUTPUT
|
||||
|
||||
self.call(
|
||||
action_ex_cmd.Create,
|
||||
app_args=[
|
||||
'some', '{"output": "Hello!"}', '--run-sync'
|
||||
]
|
||||
)
|
||||
|
||||
self.assertDictEqual(
|
||||
ACTION_EX_RESULT,
|
||||
json.loads(self.app.stdout.write.call_args[0][0])
|
||||
)
|
||||
|
||||
def test_create_run_sync_and_save_result(self):
|
||||
(self.client.action_executions.create.
|
||||
return_value) = ACTION_EX_WITH_OUTPUT
|
||||
|
||||
self.call(
|
||||
action_ex_cmd.Create,
|
||||
app_args=[
|
||||
'some', '{"output": "Hello!"}', '--save-result', '--run-sync'
|
||||
]
|
||||
)
|
||||
|
||||
self.assertDictEqual(
|
||||
ACTION_EX_RESULT,
|
||||
json.loads(self.app.stdout.write.call_args[0][0])
|
||||
)
|
||||
|
||||
def test_update(self):
|
||||
self.client.action_executions.update.return_value = ACTION_EX
|
||||
|
||||
|
Reference in New Issue
Block a user