diff options
author | Xu Yuandong <yuandongdeyouxiang@gmail.com> | 2019-09-23 21:13:42 +0800 |
---|---|---|
committer | Felix Fontein <felix@fontein.de> | 2019-09-23 15:13:42 +0200 |
commit | d6ef7c8530ca1f45cc1a0b41a97919fa4d98e1f1 (patch) | |
tree | 88db3f982fd4b9d1a39a0d7a790d9899462efa84 /lib/ansible/plugins | |
parent | bd8097ea91589c09a5341058b43beae905c716b2 (diff) | |
download | ansible-d6ef7c8530ca1f45cc1a0b41a97919fa4d98e1f1.tar.gz |
module_utils-network-cloudengine: fix get_nc_next. (#62587)
* fix get_nc_next.
* add a changelog fragment.
* upadte for changelgo fragment.
* merge two prs, one depens another.
* merge two prs, one depens another.
* update changelog.
Diffstat (limited to 'lib/ansible/plugins')
-rw-r--r-- | lib/ansible/plugins/netconf/ce.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/ansible/plugins/netconf/ce.py b/lib/ansible/plugins/netconf/ce.py index ef436d5229..784e283d57 100644 --- a/lib/ansible/plugins/netconf/ce.py +++ b/lib/ansible/plugins/netconf/ce.py @@ -36,6 +36,11 @@ try: except (ImportError, AttributeError): # paramiko and gssapi are incompatible and raise AttributeError not ImportError HAS_NCCLIENT = False +try: + from lxml.etree import fromstring +except ImportError: + from xml.etree.ElementTree import fromstring + class Netconf(NetconfBase): @@ -213,3 +218,19 @@ class Netconf(NetconfBase): @ensure_connected def discard_changes(self, *args, **kwargs): return self.m.discard_changes(*args, **kwargs).data_xml + + @ensure_ncclient + @ensure_connected + def dispatch_rpc(self, rpc_command=None, source=None, filter=None): + """ + Execute rpc on the remote device eg. dispatch('get-next') + :param rpc_command: specifies rpc command to be dispatched either in plain text or in xml element format (depending on command) + :param source: name of the configuration datastore being queried + :param filter: specifies the portion of the configuration to retrieve (by default entire configuration is retrieved) + :return: Returns xml string containing the rpc-reply response received from remote host + """ + if rpc_command is None: + raise ValueError('rpc_command value must be provided') + resp = self.m.dispatch(fromstring(rpc_command), source=source, filter=filter) + # just return rpc-reply xml + return resp.xml |