mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix edit_config multiline commands on IOS (#35375)
* Fix edit_config multiline commands on IOS The current code for multiline commands in IOS is broken: If you pass a dict containing a command, prompt and answer it is seen later as unicode string, but if you do a json.loads it fails as the keys/values are enclosed in single quotes but JSON requires double quotes. Fixes #23539 * Fix pep8 * Use ast literal_eval It's safe to use, as it is just for types and wont execute arbitrary code.
This commit is contained in:
parent
5f1254697d
commit
d178df8f01
1 changed files with 2 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import ast
|
||||
import re
|
||||
import json
|
||||
|
||||
|
@ -71,7 +72,7 @@ class Cliconf(CliconfBase):
|
|||
def edit_config(self, command):
|
||||
for cmd in chain(['configure terminal'], to_list(command), ['end']):
|
||||
try:
|
||||
cmd = json.loads(cmd)
|
||||
cmd = ast.literal_eval(cmd)
|
||||
command = cmd['command']
|
||||
prompt = cmd['prompt']
|
||||
answer = cmd['answer']
|
||||
|
|
Loading…
Reference in a new issue