Debian Codegraph @

docs/source/manager.rst

raw
1 :mod:`~ncclient.manager` -- High-level API
2 ==========================================
3
4 .. automodule:: ncclient.manager
5 :synopsis: High-level API
6
7
8 Customizing
9 ------------
10
11 These attributes control what capabilties are exchanged with the NETCONF server and what operations are available through the :class:`Manager` API.
12
13 .. autodata:: OPERATIONS
14
15
16
17 Factory functions
18 -----------------
19
20 A :class:`Manager` instance is created using a factory function.
21
22 .. autofunction:: connect_ssh
23
24 .. autodata:: connect
25
26 Manager
27 -------
28
29 Exposes an API for RPC operations as method calls. The return type of these methods depends on whether we are in :attr:`asynchronous or synchronous mode <ncclient.manager.Manager.async_mode>`.
30
31 In synchronous mode replies are awaited and the corresponding :class:`~ncclient.operations.RPCReply` object is returned. Depending on the :attr:`exception raising mode <ncclient.manager.Manager.raise_mode>`, an `rpc-error` in the reply may be raised as an :exc:`~ncclient.operations.RPCError` exception.
32
33 However in asynchronous mode, operations return immediately with the corresponding :class:`~ncclient.operations.RPC` object. Error handling and checking for whether a reply has been received must be dealt with manually. See the :class:`~ncclient.operations.RPC` documentation for details.
34
35 Note that in case of the :meth:`~Manager.get` and :meth:`~Manager.get_config` operations, the reply is an instance of :class:`~ncclient.operations.GetReply` which exposes the additional attributes :attr:`~ncclient.operations.GetReply.data` (as :class:`~lxml.etree._Element`) and :attr:`~ncclient.operations.GetReply.data_xml` (as a string), which are of primary interest in case of these operations.
36
37 Presence of capabilities is verified to the extent possible, and you can expect a :exc:`~ncclient.operations.MissingCapabilityError` if something is amiss. In case of transport-layer errors, e.g. unexpected session close, :exc:`~ncclient.transport.TransportError` will be raised.
38
39 .. autoclass:: Manager
40
41 .. autoattribute:: HUGE_TREE_DEFAULT
42
43 .. method:: get_config(source, filter=None, with_defaults=None)
44
45 `get_config` is mapped to :class:`~ncclient.operations.GetConfig`
46
47 .. method:: get_schema(identifier, version=None, format=None)
48
49 `get_schema` is mapped to :class:`~ncclient.operations.GetSchema`
50
51 .. method:: edit_config(config, format='xml', target='candidate', default_operation=None, test_option=None, error_option=None)
52
53 `edit_config` is mapped to :class:`~ncclient.operations.EditConfig`
54
55 .. method:: copy_config(source, target)
56
57 `copy_config` is mapped to :class:`~ncclient.operations.CopyConfig`
58
59 .. method:: delete_config(target)
60
61 `delete_config` is mapped to :class:`~ncclient.operations.DeleteConfig`
62
63 .. method:: dispatch(rpc_command, source=None, filter=None)
64
65 `dispatch` is mapped to :class:`~ncclient.operations.Dispatch`
66
67 .. method:: lock(target="candidate")
68
69 `lock` is mapped to :class:`~ncclient.operations.Lock`
70
71 .. method:: unlock(target="candidate")
72
73 `unlock` is mapped to :class:`~ncclient.operations.Unlock`
74
75 .. method:: get(filter=None, with_defaults=None)
76
77 `get` is mapped to :class:`~ncclient.operations.Get`
78
79 .. method:: close_session()
80
81 `close_session` is mapped to :class:`~ncclient.operations.CloseSession`
82
83 .. method:: kill_session(session_id)
84
85 `kill_session` is mapped to :class:`~ncclient.operations.KillSession`
86
87 .. method:: commit(confirmed=False, timeout=None, persist=None, persist_id=None)
88
89 `commit` is mapped to :class:`~ncclient.operations.Commit`
90
91 .. method:: cancel_commit(persist_id=None)
92
93 `cancel_commit` is mapped to :class:`~ncclient.operations.CancelCommit`
94
95 .. method:: discard_changes()
96
97 `discard_changes` is mapped to :class:`~ncclient.operations.DiscardChanges`
98
99 .. method:: validate(source="candidate")
100
101 `validate` is mapped to :class:`~ncclient.operations.Validate`
102
103 .. method:: create_subscription(filter=None, stream_name=None, start_time=None, stop_time=None)
104
105 `create_subscription` is mapped to :class:`~ncclient.operations.CreateSubscription`
106
107 .. method:: reboot_machine()
108
109 `reboot_machine` is mapped to :class:`~ncclient.operations.RebootMachine`
110
111 .. method:: poweroff_machine()
112
113 `poweroff_machine` is mapped to :class:`~ncclient.operations.PoweroffMachine`
114
115 .. automethod:: locked(target)
116
117 .. automethod:: take_notification(block=True, timeout=None)
118
119 .. autoattribute:: async_mode
120
121 .. autoattribute:: timeout
122
123 .. autoattribute:: raise_mode
124
125 .. autoattribute:: client_capabilities
126
127 .. autoattribute:: server_capabilities
128
129 .. autoattribute:: session_id
130
131 .. autoattribute:: connected
132
133 .. autoattribute:: huge_tree
134
135 Special kinds of parameters
136 ---------------------------
137
138 Some parameters can take on different types to keep the interface simple.
139
140 .. _srctarget_params:
141
142 Source and target parameters
143 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144
145 Where an method takes a *source* or *target* argument, usually a datastore name or URL is expected. The latter depends on the `:url` capability and on whether the specific URL scheme is supported. Either must be specified as a string. For example, `"running"`, `"ftp://user:pass@host/config"`.
146
147 If the source may be a `config` element, e.g. as allowed for the `validate` RPC, it can also be specified as an XML string or an :class:`~xml.etree.ElementTree.Element` object.
148
149 .. _filter_params:
150
151 Filter parameters
152 ^^^^^^^^^^^^^^^^^
153
154 Where a method takes a *filter* argument, it can take on the following types:
155
156 * A tuple of *(type, criteria)*.
157
158 Here *type* has to be one of `"xpath"` or `"subtree"`.
159
160 * For `"xpath"` the *criteria* should be a string containing the XPath expression or a tuple containing a dict of namespace mapping and the XPath expression.
161 * For `"subtree"` the *criteria* should be an XML string or an :class:`~xml.etree.ElementTree.Element` object containing the criteria.
162
163 * A list of *spec*
164
165 Here *type* has to be `"subtree"`.
166
167 * the *spec* should be a list containing multiple XML string or multiple :class:`~xml.etree.ElementTree.Element` objects.
168
169 * A `<filter>` element as an XML string or an :class:`~xml.etree.ElementTree.Element` object.