Fix netconf_config backup string issue (#56175)
* Convert the ElementTree object to string before dumping the configuration in file.pull/4420/head
parent
7608bc821e
commit
9c5745ad21
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue