1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix networking *_command check_mode (#28407)

* Fix check_mode in nxos_command

* Fix check_mode for ios_command

* fix check_mode for iosxr_command

* Fix check_mode in vyos_command

* Fix check_mode in eos_command

* Fix check_mode in junos_config
This commit is contained in:
Nathaniel Case 2017-08-22 14:02:55 -04:00 committed by Chris Alfonso
parent 96abfde189
commit e1def05ba2
6 changed files with 29 additions and 19 deletions

View file

@ -163,12 +163,14 @@ def parse_commands(module, warnings):
transform = ComplexList(spec, module) transform = ComplexList(spec, module)
commands = transform(module.params['commands']) commands = transform(module.params['commands'])
for index, item in enumerate(commands): if module.check_mode:
if module.check_mode and not item['command'].startswith('show'): for item in list(commands):
if not item['command'].startswith('show'):
warnings.append( warnings.append(
'Only show commands are supported when using check_mode, not ' 'Only show commands are supported when using check_mode, not '
'executing %s' % item['command'] 'executing %s' % item['command']
) )
commands.remove(item)
return commands return commands

View file

@ -151,12 +151,13 @@ def parse_commands(module, warnings):
answer=dict() answer=dict()
), module) ), module)
commands = command(module.params['commands']) commands = command(module.params['commands'])
for index, item in enumerate(commands): for item in list(commands):
if module.check_mode and not item['command'].startswith('show'): if module.check_mode and not item['command'].startswith('show'):
warnings.append( warnings.append(
'only show commands are supported when using check mode, not ' 'only show commands are supported when using check mode, not '
'executing `%s`' % item['command'] 'executing `%s`' % item['command']
) )
commands.remove(item)
elif item['command'].startswith('conf'): elif item['command'].startswith('conf'):
module.fail_json( module.fail_json(
msg='ios_command does not support running config mode ' msg='ios_command does not support running config mode '

View file

@ -145,12 +145,13 @@ def parse_commands(module, warnings):
), module) ), module)
commands = command(module.params['commands']) commands = command(module.params['commands'])
for index, item in enumerate(commands): for item in list(commands):
if module.check_mode and not item['command'].startswith('show'): if module.check_mode and not item['command'].startswith('show'):
warnings.append( warnings.append(
'only show commands are supported when using check mode, not ' 'only show commands are supported when using check mode, not '
'executing `%s`' % item['command'] 'executing `%s`' % item['command']
) )
commands.remove(item)
elif item['command'].startswith('conf'): elif item['command'].startswith('conf'):
module.fail_json( module.fail_json(
msg='iosxr_command does not support running config mode ' msg='iosxr_command does not support running config mode '

View file

@ -314,6 +314,7 @@ def parse_commands(module, warnings):
'Only show commands are supported when using check_mode, not ' 'Only show commands are supported when using check_mode, not '
'executing %s' % command 'executing %s' % command
) )
continue
parts = command.split('|') parts = command.split('|')
text = parts[0] text = parts[0]

View file

@ -181,15 +181,18 @@ def parse_commands(module, warnings):
commands = transform(module.params['commands']) commands = transform(module.params['commands'])
for index, item in enumerate(commands): if module.check_mode:
if module.check_mode and not item['command'].startswith('show'): for item in list(commands):
if not item['command'].startswith('show'):
warnings.append( warnings.append(
'Only show commands are supported when using check_mode, not ' 'Only show commands are supported when using check_mode, not '
'executing %s' % item['command'] 'executing %s' % item['command']
) )
commands.remove(item)
return commands return commands
def to_cli(obj): def to_cli(obj):
cmd = obj['command'] cmd = obj['command']
if obj.get('output') == 'json': if obj.get('output') == 'json':

View file

@ -155,14 +155,16 @@ def parse_commands(module, warnings):
answer=dict(), answer=dict(),
), module) ), module)
commands = command(module.params['commands']) commands = command(module.params['commands'])
items = []
for index, cmd in enumerate(commands): for item in commands:
if module.check_mode and not cmd['command'].startswith('show'): if module.check_mode and not item['command'].startswith('show'):
warnings.append('only show commands are supported when using ' warnings.append('only show commands are supported when using '
'check mode, not executing `%s`' % cmd['command']) 'check mode, not executing `%s`' % item['command'])
commands[index] = module.jsonify(cmd) else:
items.append(module.jsonify(item))
return commands return items
def main(): def main():