Revision 4bc8021f docs/source/manager.rst
b/docs/source/manager.rst | ||
---|---|---|
1 | 1 |
:mod:`~ncclient.manager` -- High-level API |
2 | 2 |
========================================== |
3 | 3 |
|
4 |
.. module:: ncclient.manager |
|
4 |
.. automodule:: ncclient.manager
|
|
5 | 5 |
:synopsis: High-level API |
6 | 6 |
|
7 |
.. data:: CAPABILITIES |
|
7 |
Module data |
|
8 |
----------- |
|
8 | 9 |
|
9 |
List of URI strings representing the client's capabilities. This is used during the initial
|
|
10 |
capability exchange. Modify this if you need to announce some capability not already included.
|
|
10 |
These attributes control what capabilties are exchanged with the NETCONF server and what operations
|
|
11 |
are available through the `Manager` API.
|
|
11 | 12 |
|
12 |
.. data:: OPERATIONS |
|
13 |
|
|
14 |
Dictionary of method names and corresponding `~ncclient.operations.RPC` classes. `Manager` uses |
|
15 |
this to lookup operations, e.g. "get_config" is mapped to `ncclient.operations.GetConfig`. It |
|
16 |
is thus possible to add additional operations to the `Manager` API. |
|
13 |
.. autodata:: CAPABILITIES |
|
14 |
|
|
15 |
.. autodata:: OPERATIONS |
|
17 | 16 |
|
18 | 17 |
Factory functions |
19 | 18 |
----------------- |
20 | 19 |
|
21 | 20 |
A `Manager` instance is created using a factory function. |
22 | 21 |
|
23 |
.. function:: connect_ssh(host[, port=830, timeout=None, unknown_host_cb=default_unknown_host_cb, username=None, password, key_filename=None, allow_agent=True, look_for_keys=True]) |
|
24 |
|
|
25 |
Initializes a NETCONF session over SSH, and creates a connected `Manager` instance. *host* must |
|
26 |
be specified, all the other arguments are optional and depend on the kind of host key |
|
27 |
verification and user authentication you want to complete. |
|
28 |
|
|
29 |
For the purpose of host key verification, on -NIX systems a user's :file:`~/.ssh/known_hosts` |
|
30 |
file is automatically considered. The *unknown_host_cb* argument specifies a callback that will |
|
31 |
be invoked when the server's host key cannot be verified. See |
|
32 |
:func:`~ncclient.transport.ssh.default_known_host_cb` for function signature. |
|
33 |
|
|
34 |
First, ``publickey`` authentication is attempted. If a specific *key_filename* is specified, it |
|
35 |
will be loaded and authentication attempted using it. If *allow_agent* is :const:`True` and an |
|
36 |
SSH agent is running, the keys provided by the agent will be tried. If *look_for_keys* is |
|
37 |
:const:`True`, keys in the :file:`~/.ssh/id_rsa` and :file:`~.ssh/id_dsa` will be tried. In case |
|
38 |
an encrypted key file is encountered, the *password* argument will be used as a decryption |
|
39 |
passphrase. |
|
40 |
|
|
41 |
If ``publickey`` authentication fails and the *password* argument has been supplied, |
|
42 |
``password`` / ``keyboard-interactive`` SSH authentication will be attempted. |
|
43 |
|
|
44 |
:param host: hostname or address on which to connect |
|
45 |
:type host: `string` |
|
46 |
|
|
47 |
:param port: port on which to connect |
|
48 |
:type port: `int` |
|
49 |
|
|
50 |
:param timeout: timeout for socket connect |
|
51 |
:type timeout: `int` |
|
52 |
|
|
53 |
:param unknown_host_cb: optional; callback that is invoked when host key verification fails |
|
54 |
:type unknown_host_cb: `function` |
|
55 |
|
|
56 |
:param username: username to authenticate with, if not specified the username of the logged-in |
|
57 |
user is used |
|
58 |
:type username: `string` |
|
59 |
|
|
60 |
:param password: password for ``password`` authentication or passphrase for decrypting |
|
61 |
private key files |
|
62 |
:type password: `string` |
|
63 |
|
|
64 |
:param key_filename: location of a private key file on the file system |
|
65 |
:type key_filename: `string` |
|
66 |
|
|
67 |
:param allow_agent: whether to try connecting to SSH agent for keys |
|
68 |
:type allow_agent: `bool` |
|
69 |
|
|
70 |
:param look_for_keys: whether to look in usual locations for keys |
|
71 |
:type look_for_keys: `bool` |
|
72 |
|
|
73 |
:raises: :exc:`~ncclient.transport.SSHUnknownHostError` |
|
74 |
:raises: :exc:`~ncclient.transport.AuthenticationError` |
|
75 |
|
|
76 |
:rtype: `Manager` |
|
77 |
|
|
78 |
.. function:: connect() |
|
22 |
.. autofunction:: connect_ssh(host[, port=830, timeout=None, unknown_host_cb=default_unknown_host_cb, username=None, password, key_filename=None, allow_agent=True, look_for_keys=True]) |
|
79 | 23 |
|
80 |
Same as :func:`connect_ssh`, since SSH is the default (and currently, the |
|
81 |
only) transport. |
|
24 |
.. autodata:: connect |
|
82 | 25 |
|
83 | 26 |
Manager |
84 | 27 |
------- |
... | ... | |
263 | 206 |
Valid values: |
264 | 207 |
|
265 | 208 |
* ``"all"`` -- any kind of *rpc-error* (error or warning) |
266 |
* ``"errors"`` -- where the *error-type* attribute says it is an error
|
|
209 |
* ``"errors"`` -- where the *error-type* element says it is an error
|
|
267 | 210 |
* ``"none"`` -- neither |
268 | 211 |
|
269 | 212 |
.. attribute:: client_capabilities |
Also available in: Unified diff