Sanitizing all responses from aireos. (#27660)

This commit is contained in:
James Mighion 2017-08-02 14:01:38 -07:00 committed by John R Barker
parent aca4504e96
commit baaa1ef2ec
2 changed files with 5 additions and 4 deletions

View file

@ -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