Fix netconf_config backup string issue (#56175)

*  Convert the ElementTree object to string
   before dumping the configuration in file.
This commit is contained in:
Ganesh Nalawade 2019-05-07 11:31:58 -04:00 committed by GitHub
parent 7608bc821e
commit 9c5745ad21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,6 +252,11 @@ from ansible.module_utils.basic import AnsibleModule, env_fallback
from ansible.module_utils.connection import Connection, ConnectionError
from ansible.module_utils.network.netconf.netconf import get_capabilities, get_config, sanitize_xml
try:
from lxml.etree import tostring
except ImportError:
from xml.etree.ElementTree import tostring
def main():
""" main entry point for module execution
@ -365,7 +370,7 @@ def main():
try:
if module.params['backup']:
response = get_config(module, target, lock=execute_lock)
before = to_text(response, errors='surrogate_then_replace').strip()
before = to_text(tostring(response), errors='surrogate_then_replace').strip()
result['__backup__'] = before.strip()
if validate:
conn.validate(target)