diff --git a/changelogs/fragments/netconf-python3-ab45f4c5bf155b6b.yaml b/changelogs/fragments/netconf-python3-ab45f4c5bf155b6b.yaml new file mode 100644 index 0000000000..b8d7ec20a3 --- /dev/null +++ b/changelogs/fragments/netconf-python3-ab45f4c5bf155b6b.yaml @@ -0,0 +1,2 @@ +bugfixes: + - netconf - Make netconf_get python3 compatible. diff --git a/lib/ansible/modules/network/netconf/netconf_get.py b/lib/ansible/modules/network/netconf/netconf_get.py index debed8c91a..68bf1b3aeb 100644 --- a/lib/ansible/modules/network/netconf/netconf_get.py +++ b/lib/ansible/modules/network/netconf/netconf_get.py @@ -159,6 +159,7 @@ except ImportError: from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.netconf.netconf import get_capabilities, locked_config, get_config, get from ansible.module_utils.network.common.netconf import remove_namespaces +from ansible.module_utils._text import to_text try: import jxmlease @@ -235,7 +236,7 @@ def main(): else: response = get(module, filter_spec, execute_lock) - xml_resp = tostring(response) + xml_resp = to_text(tostring(response)) output = None if display == 'xml': @@ -246,7 +247,7 @@ def main(): except Exception: raise ValueError(xml_resp) elif display == 'pretty': - output = tostring(response, pretty_print=True) + output = to_text(tostring(response, pretty_print=True)) result = { 'stdout': xml_resp,