Skip to content

Commit

Permalink
Fix netconf_config backup string issue (ansible#56175)
Browse files Browse the repository at this point in the history
*  Convert the ElementTree object to string
   before dumping the configuration in file.
  • Loading branch information
ganeshrn authored May 7, 2019
1 parent 7608bc8 commit 9c5745a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ansible/modules/network/netconf/netconf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@
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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9c5745a

Please sign in to comment.