This module is a thin layer of abstraction around the library. It exposes all core functionality.
These attributes control what capabilties are exchanged with the NETCONF server and what operations are available through the Manager API.
A Manager instance is created using a factory function.
Initializes a NETCONF session over SSH, and creates a connected Manager instance. host must be specified, all the other arguments are optional and depend on the kind of host key verification and user authentication you want to complete.
For the purpose of host key verification, on -NIX systems a user’s ~/.ssh/known_hosts file is automatically considered. The unknown_host_cb argument specifies a callback that will be invoked when the server’s host key cannot be verified. See default_unknown_host_cb() for function signature.
First, publickey authentication is attempted. If a specific key_filename is specified, it will be loaded and authentication attempted using it. If allow_agent is True and an SSH agent is running, the keys provided by the agent will be tried. If look_for_keys is True, keys in the ~/.ssh/id_rsa and ~.ssh/id_dsa will be tried. In case an encrypted key file is encountered, the password argument will be used as a decryption passphrase.
If publickey authentication fails and the password argument has been supplied, password / keyboard-interactive SSH authentication will be attempted.
Exposes an API for RPC operations as method calls. The return type of these methods depends on whether we are is in asynchronous or synchronous mode.
However in asynchronous mode, operations return immediately with an RPC object. Error handling and checking for whether a reply has been received must be dealt with manually. See the RPC documentation for details.
Note that in case of the get and get-config operations, the reply is an instance of GetReply which exposes the additional attributes data (as Element) and data_xml (as string), which are of primary interest in case of these operations.
Presence of capabilities is verified to the extent possible, and you can expect a MissingCapabilityError if something is amiss. In case of transport-layer errors, e.g. unexpected session close, TransportError will be raised.
For details on the expected behavior of the operations and their parameters refer to RFC 4741.
Manager instances are also context managers so you can use it like this:
with manager.connect("host") as m: # do your stuff
... or like this:
m = manager.connect("host") try: # do your stuff finally: m.close()
Retrieve all or part of a specified configuration.
Loads all or part of a specified configuration to the specified target configuration.
The "rollback-on-error" error_option depends on the :rollback-on-error capability.
Create or replace an entire configuration datastore with the contents of another complete configuration datastore.
Delete a configuration datastore.
|Parameter:||target – name or URL of configuration datastore to delete|
|Type:||Source and target parameters|
Allows the client to lock the configuration system of a device.
|Parameter:||target (string) – name of the configuration datastore to lock|
Release a configuration lock, previously obtained with the lock() operation.
|Parameter:||target (string) – name of the configuration datastore to unlock|
Returns a context manager for a lock on a datastore, e.g.:
with m.locked("running"): # do your stuff
... instead of:
m.lock("running") try: # do your stuff finally: m.unlock("running")
|Parameter:||target (string) – name of configuration datastore to lock|
Retrieve running configuration and device state information.
|Parameter:||filter (Filter parameters) – portions of the device configuration to retrieve (by default entire configuration is retrieved)|
Force the termination of a NETCONF session (not the current one!).
|Parameter:||session_id (string) – session identifier of the NETCONF session to be terminated|
Commit the candidate configuration as the device’s new current configuration. Depends on the :candidate capability.
A confirmed commit (i.e. if confirmed is True) is reverted if there is no followup commit within the timeout interval. If no timeout is specified the confirm timeout defaults to 600 seconds (10 minutes). A confirming commit may have the confirmed parameter but this is not required. Depends on the :confirmed-commit capability.
Validate the contents of the specified configuration.
|Parameter:||source (Source and target parameters) – name of the configuration datastore being validated or <config> element containing the configuration subtree to be validated|
Specify which errors are raised as RPCError exceptions. Valid values:
Some parameters can take on different types to keep the interface simple.
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".
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 Element object.
Where a method takes a filter argument, it can take on the following types:
A tuple of (type, criteria).
Here type has to be one of "xpath" or "subtree".
A <filter> element as an XML string or an Element object.