Sanitizing all responses from aireos. (#27660)
This commit is contained in:
parent
aca4504e96
commit
baaa1ef2ec
2 changed files with 5 additions and 4 deletions
|
@ -47,8 +47,9 @@ ARGS_DEFAULT_VALUE = {}
|
|||
|
||||
|
||||
def sanitize(resp):
|
||||
# Takes config from device and strips whitespace from all lines
|
||||
# Takes response from device and strips whitespace from all lines
|
||||
# Aireos adds in extra preceding whitespace which netcfg parses as children/parents, which Aireos does not do
|
||||
# Aireos also adds in trailing whitespace that is unused
|
||||
cleaned = []
|
||||
for line in resp.splitlines():
|
||||
cleaned.append(line.strip())
|
||||
|
@ -112,7 +113,7 @@ def run_commands(module, commands, check_rc=True):
|
|||
rc, out, err = exec_command(module, cmd)
|
||||
if check_rc and rc != 0:
|
||||
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), rc=rc)
|
||||
responses.append(to_text(out, errors='surrogate_then_replace'))
|
||||
responses.append(sanitize(to_text(out, errors='surrogate_then_replace')))
|
||||
return responses
|
||||
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ backup_path:
|
|||
type: string
|
||||
sample: /playbooks/ansible/backup/aireos_config.2016-07-16@22:28:34
|
||||
"""
|
||||
from ansible.module_utils.aireos import run_commands, get_config, load_config, sanitize
|
||||
from ansible.module_utils.aireos import run_commands, get_config, load_config
|
||||
from ansible.module_utils.aireos import aireos_argument_spec
|
||||
from ansible.module_utils.aireos import check_args as aireos_check_args
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -281,7 +281,7 @@ def main():
|
|||
|
||||
if module._diff:
|
||||
output = run_commands(module, 'show run-config commands')
|
||||
contents = sanitize(output[0])
|
||||
contents = output[0]
|
||||
|
||||
# recreate the object in order to process diff_ignore_lines
|
||||
running_config = NetworkConfig(indent=1, contents=contents, ignore_lines=diff_ignore_lines)
|
||||
|
|
Loading…
Reference in a new issue