Revision ad82bf43 ncclient/operations/retrieve.py
b/ncclient/operations/retrieve.py | ||
---|---|---|
87 | 87 |
return self._request(node) |
88 | 88 |
|
89 | 89 |
class Dispatch(RPC): |
90 |
"""Generic retrieving wrapper. Eg. dispatch('clear-arp-table') or dispatch element |
|
91 |
like : |
|
92 |
xsd_fetch = new_ele('get-xnm-information') |
|
93 |
sub_ele(xsd_fetch, 'type').text="xml-schema" |
|
94 |
sub_ele(xsd_fetch, 'namespace').text="junos-configuration |
|
95 |
dispatch(xsd_fetch) |
|
96 |
to fetch entire xsd sxhema file from Juniper |
|
97 |
""" |
|
98 |
|
|
90 |
|
|
91 |
"Generic retrieving wrapper" |
|
92 |
|
|
99 | 93 |
REPLY_CLS = GetReply |
100 |
|
|
94 |
"See :class:`GetReply`." |
|
95 |
|
|
101 | 96 |
def request(self, rpc_command, source=None, filter=None): |
97 |
""" |
|
98 |
*rpc_command* specifies rpc command to be dispatched either in plain text or in xml element format (depending on command) |
|
99 |
|
|
100 |
*source* name of the configuration datastore being queried |
|
101 |
|
|
102 |
*filter* specifies the portion of the configuration to retrieve (by default entire configuration is retrieved) |
|
103 |
|
|
104 |
:seealso: :ref:`filter_params` |
|
105 |
|
|
106 |
Examples of usage:: |
|
107 |
|
|
108 |
dispatch('clear-arp-table') |
|
109 |
|
|
110 |
or dispatch element like :: |
|
111 |
|
|
112 |
xsd_fetch = new_ele('get-xnm-information') |
|
113 |
sub_ele(xsd_fetch, 'type').text="xml-schema" |
|
114 |
sub_ele(xsd_fetch, 'namespace').text="junos-configuration" |
|
115 |
dispatch(xsd_fetch) |
|
116 |
""" |
|
117 |
|
|
102 | 118 |
if ET.iselement(rpc_command): |
103 | 119 |
node = rpc_command |
104 | 120 |
else: |
... | ... | |
107 | 123 |
node.append(util.datastore_or_url("source", source, self._assert)) |
108 | 124 |
if filter is not None: |
109 | 125 |
node.append(util.build_filter(filter)) |
110 |
return self._request(node) |
|
126 |
return self._request(node) |
|
127 |
|
Also available in: Unified diff