mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
check cli context to be sure out of config mode in ios (#21493)
This change will now check the cli context after a module runs and if the cli is still in config mode it will exit config mode. Also fixes a minor issue with converting list of commands to a dict fixes #21481
This commit is contained in:
parent
edf2b00614
commit
34e6cc788f
2 changed files with 18 additions and 9 deletions
|
@ -65,18 +65,19 @@ def get_config(module, flags=[]):
|
|||
_DEVICE_CONFIGS[cmd] = cfg
|
||||
return cfg
|
||||
|
||||
def to_commands(commands):
|
||||
transform = ComplexList(dict(
|
||||
command=dict(key=True),
|
||||
prompt=dict(),
|
||||
response=dict()
|
||||
))
|
||||
def to_commands(module, commands):
|
||||
spec = {
|
||||
'command': dict(key=True),
|
||||
'prompt': dict(),
|
||||
'response': dict()
|
||||
}
|
||||
transform = ComplexList(spec, module)
|
||||
return transform(commands)
|
||||
|
||||
|
||||
def run_commands(module, commands, check_rc=True):
|
||||
responses = list()
|
||||
commands = to_commands(to_list(commands))
|
||||
commands = to_commands(module, to_list(commands))
|
||||
for cmd in commands:
|
||||
cmd = module.jsonify(cmd)
|
||||
rc, out, err = exec_command(module, cmd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue