Bases: object
Junos Device class.
When non-zero the call to open() will probe for NETCONF reachability before proceeding with the NETCONF session establishment. If you want to enable this behavior by default, you could do the following in your code:
from jnpr.junos import Device
# set all device open to auto-probe with timeout of 10 sec
Device.auto_probe = 10
dev = Device( ... )
dev.open() # this will probe before attempting NETCONF connect
Used to return a Jinja2 Template.
Parameters: | filename (str) – file-path to Jinja2 template file on local device |
---|---|
Returns: | Jinja2 Template give filename. |
Device object constructor.
Parameters: |
|
---|
Used to attach things to this Device instance and make them a property of the :class:Device instance. The most common use for bind is attaching Utility instances to a :class:Device. For example:
from jnpr.junos.utils.config import Config
dev.bind( cu=Config )
dev.cu.lock()
# ... load some changes
dev.cu.commit()
dev.cu.unlock()
Parameters: |
|
---|
Executes the CLI command and returns the CLI text output by default.
Parameters: |
|
---|
Note
You can also use this method to obtain the XML RPC command for a given CLI command by using the pipe filter | display xml rpc. When you do this, the return value is the XML RPC command. For example if you provide as the command show version | display xml rpc, you will get back the XML Element <get-software-information>.
Warning
This function is provided for DEBUG purposes only! DO NOT use this method for general automation purposes as that puts you in the realm of “screen-scraping the CLI”. The purpose of the PyEZ framework is to migrate away from that tooling pattern. Interaction with the device should be done via the RPC function.
Warning
You cannot use “pipe” filters with command such as | match or | count, etc. The only value use of the “pipe” is for the | display xml rpc as noted above.
Executes the CLI command and returns the CLI text output by default.
Parameters: |
|
---|
Executes an XML RPC and returns results as either XML or native python
Parameters: |
|
---|---|
Raises: |
|
Returns: | RPC-reply as XML object. If to_py is provided, then that function is called, and return of that function is provided back to the caller; presumably to convert the XML to native python data-types (e.g. dict). |
Returns: | list of Resource Managers/Utilities attached to this instance using the bind() method. |
---|
Opens a connection to the device using existing login/auth information.
Parameters: |
|
---|---|
Returns Device: | Device instance (self). |
Raises: |
|
Probe the device to determine if the Device can accept a remote connection. This method is meant to be called prior to :open(): This method will not work with ssh-jumphost environments.
Parameters: |
|
---|---|
Returns: | True if probe is successful, False otherwise |
Bases: jnpr.junos.exception.RpcError
Generated in response to a commit-check or a commit action.
Bases: jnpr.junos.exception.RpcError
Generated in response to a failure when loading a configuration.
Bases: jnpr.junos.exception.ConnectError
Generated if the user-name, password is invalid
Bases: exceptions.Exception
Parent class for all connection related exceptions
Bases: jnpr.junos.exception.ConnectError
Generated if the connection is made to a non-master routing-engine. This could be a backup RE on an MX device, or a virtual-chassis member (linecard), for example
Bases: jnpr.junos.exception.ConnectError
Generated if the specified host denies the NETCONF; could be that the services is not enabled, or the host has too many connections already.
Bases: jnpr.junos.exception.ConnectError
Generated if the NETCONF session fails to connect, could be due to the fact the device is not ip reachable; bad ipaddr or just due to routing
Bases: jnpr.junos.exception.ConnectError
Generated if the specific hostname does not DNS resolve
Bases: jnpr.junos.exception.RpcError
Generated in response to attempting to take an exclusive lock on the configuration database.
Bases: jnpr.junos.exception.RpcError
Generated in response to invoking an RPC for which the auth user does not have user-class permissions.
PermissionError.message gives you the specific RPC that cause the exceptions
Bases: jnpr.junos.exception.ConnectError
Generated if auto_probe is enabled and the probe action fails
Bases: exceptions.Exception
Parent class for all junos-pyez RPC Exceptions
Bases: jnpr.junos.exception.RpcError
Generated in response to a RPC execution timeout.
Bases: jnpr.junos.exception.RpcError
Generated in response to attempting to unlock the configuration database.
These are Junos XML ‘helper’ definitions use for generic XML processing
.DEL to delete an item .REN to rename an item, requires the use of NAME()
.INSERT(<’before’|’after’>) to reorder an item, requires the use of NAME() .BEFORE to reorder an item before another, requires the use of NAME() .AFTER to reorder an item after another, requires the use of NAME()
.NAME(name) to assign the name attribute
Bases: object
~PRIVATE CLASS~ creates an RPC meta-executor object bound to the provided ez-netconf :junos: object
retrieve configuration from the Junos device
Filter_xml: | is options, defines what to retrieve. if omitted then the entire configuration is returned |
---|---|
Options: | is a dict, creates attributes for the RPC |
loads :contents: onto the Junos device, does not commit the change.
Options: | is a dictionary of XML attributes to set within the <load-configuration> RPC. |
---|
The :contents: are interpreted by the :options: as follows:
format=’text’ and action=’set’, then :contents: is a string containing a series of “set” commands
format=’text’, then :contents: is a string containing Junos configuration in curly-brace/text format
<otherwise> :contents: is XML structure