mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Fix netconf_config backup string issue (#56175)
* Convert the ElementTree object to string before dumping the configuration in file.
This commit is contained in:
parent
7608bc821e
commit
9c5745ad21
1 changed files with 6 additions and 1 deletions
|
@ -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.connection import Connection, ConnectionError
|
||||||
from ansible.module_utils.network.netconf.netconf import get_capabilities, get_config, sanitize_xml
|
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():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
|
@ -365,7 +370,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
if module.params['backup']:
|
if module.params['backup']:
|
||||||
response = get_config(module, target, lock=execute_lock)
|
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()
|
result['__backup__'] = before.strip()
|
||||||
if validate:
|
if validate:
|
||||||
conn.validate(target)
|
conn.validate(target)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue