jnpr.junos.device.
Device
(*vargs, **kvargs)[source]¶Bases: jnpr.junos.device._Connection
Junos Device class.
ON_JUNOS
:True
when this code is running on a Junos device,
vs. running on a local-server remotely connecting to a device.auto_probe
: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
ON_JUNOS
= False¶__init__
(*vargs, **kvargs)[source]¶Device object constructor.
Parameters: |
|
---|
auto_probe
= 0¶open
(*vargs, **kvargs)[source]¶Opens a connection to the device using existing login/auth information.
Parameters: |
|
---|---|
Returns Device: | Device instance (self). |
Raises: |
|
transform
¶Returns: | the current RPC XML Transformation. |
---|
jnpr.junos.exception.
CommitError
(rsp, cmd=None, errs=None)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to a commit-check or a commit action.
jnpr.junos.exception.
ConfigLoadError
(rsp, cmd=None, errs=None)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to a failure when loading a configuration.
jnpr.junos.exception.
ConnectAuthError
(dev, msg=None)[source]¶Bases: jnpr.junos.exception.ConnectError
Generated if the user-name, password is invalid
jnpr.junos.exception.
ConnectClosedError
(dev)[source]¶Bases: jnpr.junos.exception.ConnectError
Generated if connection unexpectedly closed
jnpr.junos.exception.
ConnectError
(dev, msg=None)[source]¶Bases: exceptions.Exception
Parent class for all connection related exceptions
host
¶login host name/ipaddr
msg
¶login SSH port
port
¶login SSH port
user
¶login user-name
jnpr.junos.exception.
ConnectNotMasterError
(dev, msg=None)[source]¶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
jnpr.junos.exception.
ConnectRefusedError
(dev, msg=None)[source]¶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.
jnpr.junos.exception.
ConnectTimeoutError
(dev, msg=None)[source]¶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
jnpr.junos.exception.
ConnectUnknownHostError
(dev, msg=None)[source]¶Bases: jnpr.junos.exception.ConnectError
Generated if the specific hostname does not DNS resolve
jnpr.junos.exception.
LockError
(rsp)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to attempting to take an exclusive lock on the configuration database.
jnpr.junos.exception.
PermissionError
(rsp, cmd=None, errs=None)[source]¶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
jnpr.junos.exception.
ProbeError
(dev, msg=None)[source]¶Bases: jnpr.junos.exception.ConnectError
Generated if auto_probe is enabled and the probe action fails
jnpr.junos.exception.
RpcError
(cmd=None, rsp=None, errs=None, dev=None, timeout=None, re=None)[source]¶Bases: exceptions.Exception
Parent class for all junos-pyez RPC Exceptions
__init__
(cmd=None, rsp=None, errs=None, dev=None, timeout=None, re=None)[source]¶Cmd: | is the rpc command |
---|---|
Rsp: | is the rpc response (after <rpc-reply>) |
Errs: | is a list of dictionaries of extracted <rpc-error> elements. |
Dev: | is the device rpc was executed on |
Timeout: | is the timeout value of the device |
Re: | is the RE or member exception occured on |
jnpr.junos.exception.
RpcTimeoutError
(dev, cmd, timeout)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to a RPC execution timeout.
jnpr.junos.exception.
SwRollbackError
(rsp, re=None)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to a SW rollback error.
jnpr.junos.exception.
UnlockError
(rsp)[source]¶Bases: jnpr.junos.exception.RpcError
Generated in response to attempting to unlock the configuration database.
jnpr.junos.rpcmeta.
_RpcMetaExec
(junos)[source]¶Bases: object
__init__
(junos)[source]¶~PRIVATE CLASS~ creates an RPC meta-executor object bound to the provided ez-netconf :junos: object
get_config
(filter_xml=None, options={})[source]¶retrieve configuration from the Junos device
Filter_xml: | fully XML formatted tag which defines what to retrieve, when omitted the entire configuration is returned; the following returns the device host-name configured with “set system host-name”: |
---|
config = dev.rpc.get_config(filter_xml=etree.XML(‘<configuration><system><host-name/></system></configuration>’))
Options: | is a dictionary of XML attributes to set within the <get-configuration> RPC; the following returns the device host-name either configured with “set system host-name” and if unconfigured, the value inherited from apply-group re0|re1, typical for multi-RE systems: |
---|
load_config
(contents, **options)[source]¶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
format=’json’, then :contents: is a string containing Junos configuration in json format
<otherwise> :contents: is XML structure