feat: better handling of cli command options

This commit is contained in:
Mauro Torrez 2020-10-06 09:10:46 -03:00
parent a4d6ffefc6
commit fcc2fa0be9

View File

@ -44,7 +44,7 @@ class ActionModule(ActionBase):
# read current config # read current config
cur_result = self.execute_command( cur_result = self.execute_command(
'{} --output-json --command="/:read-resource(recursive)"'.format( '{} --command="/:read-resource(recursive)"'.format(
cli_command), cli_command),
check_mode_unsafe=False check_mode_unsafe=False
) )
@ -91,7 +91,7 @@ class ActionModule(ActionBase):
if not dry_run: if not dry_run:
result = merge_hash(result, self.execute_command( result = merge_hash(result, self.execute_command(
'{} --output-json'.format(cli_command), cli_command,
stdin=batch_script, stdin=batch_script,
check_mode_unsafe=True check_mode_unsafe=True
)) ))
@ -121,14 +121,40 @@ def read_args(task_args, check_mode):
''' '''
# CLI command for connecting to Wildfly admin interface # CLI command for connecting to Wildfly admin interface
cli_command = task_args.get('cli_cmd', 'jboss-cli.sh --connect') cli_path = task_args.get('cli_path', 'jboss-cli.sh')
cli_options = task_args.get('cli_options', False)
controller = task_args.get('controller', False)
user = task_args.get('user', False)
password = task_args.get('password', '')
local_auth = task_args.get('local_auth', True)
cli_command = (
'{} {} {} {} {} --connect --error-on-interact --output-json'
'--no-color-output --no-output-paging'
).format(
cli_path,
(cli_options if cli_options else ''),
('--controller={}'.format(controller) if controller else ''),
('--user={} --password={}'.format(user, password) if user else ''),
('' if local_auth else '--no-local-auth')
)
# deprecated cli_cmd option
if task_args.get('cli_cmd', False):
display.deprecated(
'"cli_cmd" argument should not be used. Please use '
'"cli_path", "cli_options", "conroller", "user", "password", '
'and "local_auth" arguments instead')
cli_command = (
'{} --connect --error-on-interact --output-json'
'--no-color-output --no-output-paging'
).format(task_args.get('cli_cmd'))
# desired configuration # desired configuration
config = task_args.get('config', False) config = task_args.get('config', False)
if not config and task_args.get('config_list', False): if not config and task_args.get('config_list', False):
config = task_args.get('config_list') config = task_args.get('config_list')
display.deprecated('"config_list" argument should not be used. ' display.deprecated('"config_list" argument should not be used. '
'Please use "config" argument instead.') 'Please use "config" argument instead')
# validate config argument # validate config argument
if isinstance(config, list): if isinstance(config, list):