From 795cb90367c3f73ba1126193ee792df73ebe4b89 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Mon, 17 Jun 2019 16:22:23 +0530 Subject: [PATCH] Fix iosxr discard_changes netconf rpc issue (#57931) * If dispatch() rpc response has data element return the xml string from element else return the complete xml string from . Depends-On: #57909 Depends-On: #57919 --- lib/ansible/plugins/netconf/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/netconf/__init__.py b/lib/ansible/plugins/netconf/__init__.py index 39af3850ce7..84d416d188d 100644 --- a/lib/ansible/plugins/netconf/__init__.py +++ b/lib/ansible/plugins/netconf/__init__.py @@ -26,6 +26,7 @@ from ansible.errors import AnsibleError from ansible.plugins import AnsiblePlugin from ansible.module_utils._text import to_native from ansible.module_utils.basic import missing_required_lib +from ansible.module_utils.six import string_types try: from ncclient.operations import RPCError @@ -223,9 +224,9 @@ class NetconfBase(AnsiblePlugin): """ if rpc_command is None: raise ValueError('rpc_command value must be provided') - - resp = self.m.dispatch(fromstring(rpc_command), source=source, filter=filter) - return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml + req = fromstring(rpc_command) + resp = self.m.dispatch(req, source=source, filter=filter) + return resp.data_xml if resp.data_ele else resp.xml @ensure_connected def lock(self, target="candidate"):