From ca118613aabd52c39b8ebe3aee225c7531b9d6a6 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Thu, 27 Aug 2020 23:17:40 +0530 Subject: [PATCH] Fixes https://github.com/ansible-collections/cisco.iosxr/issues/74 (#71292) * ncclient API expects commit timeout value in either unicode or bytes format, hence convert the timeout value explicitly to string type. --- changelogs/fragments/iosxr_netconf_config_commit_fix.yaml | 2 ++ lib/ansible/plugins/netconf/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/iosxr_netconf_config_commit_fix.yaml diff --git a/changelogs/fragments/iosxr_netconf_config_commit_fix.yaml b/changelogs/fragments/iosxr_netconf_config_commit_fix.yaml new file mode 100644 index 00000000000..429f3c5c595 --- /dev/null +++ b/changelogs/fragments/iosxr_netconf_config_commit_fix.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Confirmed commit fails with TypeError in IOS XR netconf plugin (https://github.com/ansible-collections/cisco.iosxr/issues/74) diff --git a/lib/ansible/plugins/netconf/__init__.py b/lib/ansible/plugins/netconf/__init__.py index b181f37696a..529cc260675 100644 --- a/lib/ansible/plugins/netconf/__init__.py +++ b/lib/ansible/plugins/netconf/__init__.py @@ -24,7 +24,7 @@ from functools import wraps from ansible.errors import AnsibleError from ansible.plugins import AnsiblePlugin -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_text from ansible.module_utils.basic import missing_required_lib try: @@ -269,6 +269,7 @@ class NetconfBase(AnsiblePlugin): and set a token on the ongoing confirmed commit :return: Returns xml string containing the RPC response received from remote host """ + timeout = to_text(timeout, errors='surrogate_or_strict') resp = self.m.commit(confirmed=confirmed, timeout=timeout, persist=persist) return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml