Junos-eznc

Latest version: v2.7.2

Safety actively analyzes 682361 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 10

1.2.0

Not secure
New Features

Enhanced Exception Handling
- ConnectError
- Added more information including underlying message
- CommitError
- Added field descriptors
- RpcError
- Added field descriptors
- ConnectClosedError
- New exception – for devices that are unexpectedly closed or never opened. When this exception is thrown `device.connected` is set to `False`

XML Normalization Support
- New feature adds the ability to normalize-space entire XML-RPC reply data. Some JUNOS RPC's return data wrapped in newlines which can interfere with text based searches.
- Normalization is off by default (except for OpTables) and can be enabled by default per-device or on a per-RPC basis.

No normalization

python
rsp = dev.rpc.get_interface_information(interface_name='ge-0/0/0.0', terse=True)
rsp.xpath(".//address-family[address-family-name='\ninet\n']/interface-address/ifa-local")[0].text
'\n192.168.74.31/24\n‘


Normalized

python
rsp = dev.rpc.get_interface_information(interface_name='ge-0/0/0.0', terse=True, normalize=True)
rsp.xpath(".//address-family[address-family-name='inet']/interface-address/ifa-local")[0].text
'192.168.74.31/24'


Enabling Normalization

python
Per Device
dev = Device(host='1.1.1.1', normalize=True)
dev.open(normalize=True)
Per RPC
dev.rpc.any_rpc(normalize=True)


OpTables normalization
- OpTables previously used `normalize-space` for table keys. Utilizing the new normalization function keys and values are now normalized.
- This can be disabled in the table definition or via the `get` function

yaml
SessionTable:
rpc: get-flow-session-information
item: .//flow-session
key: session-identifier
args:
normalize: False
view: SessionView


python
session_table.get(normalize=False)


Mixed Mode Virtual Chassis Upgrade Support
- Added `pkg_set` to `sw.install`

Example

python
sw.install(pkg_set=['jinstall-qfx-5-13.2X51-D35.3-domestic-signed.tgz', 'jinstall-ex-4300-13.2X51-D35.3-domestic-signed.tgz'], progress=sw.progress)


Add sync, force_sync, full, detail to Config.commit(),
- Added additional options to commit
- http://www.juniper.net/documentation/en_US/junos14.2/topics/reference/tag-summary/junos-xml-protocol-commit-configuration.html

Example

python
cu.commit(comment='combo!', force_sync=True, detail=True, full=True)


Configuration Table Support
- Ability to load configuration tables from device or XML file / object.
- By default `{'inherit': 'inherit', 'groups': 'groups'}` and full child values are retrieved. (This is opposite of before).
- `get` now has kwargs of `namesonly` and `options`.
- group operator has also been added to simplify the gathering of apply-group inheritance.

Example

yaml
---
UserTable:
get: system/login/user
required_keys:
user: name
view: userView

userView:
groups:
auth: authentication
fields:
uid: uid
class: class
uidgroup: { uid: group }
fullgroup: { full-name: group }
fields_auth:
pass: encrypted-password

PolicyRuleTable:
get: security/policies/policy/policy
required_keys:
policy:
- from-zone-name
- to-zone-name
view: policyRuleView

policyRuleView:
groups:
match: match
then: then
fields_match:
match_src: source-address
match_dst: destination-address
match_app: application
fields_then:
log_init : { log/session-init: flag }
action : deny | permit


Support for SSH ProxyCommand in SCP
- Utils.scp updated to utilize ProxyCommand

Set minimum paramiko version
- Required version is now 1.15.2
- **Note** If paramiko or ecdsa was installed via system packages `pip -U` encounter issues.

Bugs Fixed

Facts
- MX Virtual Chassis
- All physical RE's are now accounted for in facts in the format `Device-RE` => 'RE1-RE0'
- Master fact is same format as other VC systems.

python
{'2RE': True,
'HOME': '/var/home/regress',
'RE0-RE0': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
'mastership_state': 'master',
'model': 'RE-S-1800x4',
'status': 'OK',
'up_time': '13 days, 22 hours, 27 minutes, 23 seconds'},
'RE0-RE1': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
'mastership_state': 'backup',
'model': 'RE-S-1800x4',
'status': 'OK',
'up_time': '13 days, 22 hours, 27 minutes, 22 seconds'},
'RE1-RE0': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
'mastership_state': 'master',
'model': 'RE-S-1800x4',
'status': 'OK',
'up_time': '13 days, 22 hours, 28 minutes, 19 seconds'},
'RE1-RE1': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
'mastership_state': 'backup',
'model': 'RE-S-1800x4',
'status': 'OK',
'up_time': '13 days, 22 hours, 28 minutes, 5 seconds'},
'RE_hw_mi': True,
'domain': 'juniper.net',
'fqdn': 'host.juniper.net',
'hostname': 'host',
'ifd_style': 'CLASSIC',
'master': 'RE0',
'model': 'MX2010',
'personality': 'MX',
'serialnumber': 'JN11CAXXXXXX',
'switch_style': 'BRIDGE_DOMAIN',
'vc_capable': True,
'version': '14.2I20150327_2246',
'version_RE0': '14.2I20150327_2246',
'version_RE1': '14.2I20150327_2246',
'version_info': junos.version_info(major=(14, 2), type=I, minor=20150327_2246, build=None)}

- Domain
- Domain lookup now checks configuration first before attempting to parse `/etc/resolv.conf` or `/var/etc/resolv.conf`
- 2RE
- Fixed false positive of 2RE on vc_capable systems

StartShell root user
- Utils.start_shell now supports the user `root`

utils.fs multiple RE support
- Fixed bug affecting multiple RE systems

OpTables loading from XML files and objects
- OpTables were not properly loading when passing in a XML file path or lxml object

1.1.2

Not secure
Bugs Fixed:
- onbox Device()

1.1.1

Not secure
Bugs Fixed:
- Device _auth_user overwritten after device open.
- This was breaking SCP

1.1

1.1.0

Not secure
New Features

Enhanced Exception Handling
- Default exception
- Look for ncclient RPCError to process XML (ncclient 0.4.3 exception handling improved)
- Otherwise will raise a generic
- CommitError
- Added information as to why the commit failed
- ConfigLoadError
- New exception – gives information on why loading a config failed.
- RpcTimeoutError
- New exception – displays device, rpc, and timeout value.

Per execution timeout
- New feature adds the keyword argument dev_timeout with the value of seconds to the RPC on demand function. This will set the timeout for only that operation. (The device timeout is still globally updated automatically before and after execution).

Example

python
dev.rpc.get_route_information(table='inet.0', dev_timeout=55)


Serialization of Junos facts
- Custom encoders added for the object in both YAML and JSON. Default encoders set to this custom version by default in the library.

Example

python
import yaml
print yaml.dump(dev.facts['version_info'])
build: 6
major: !!python/tuple [14, 2]
minor: '1'
type: R

import json
print json.dumps(dev.facts['version_info'])
{"major": [14, 2], "type": "R", "build": 6, "minor": "1"}


Composite table key support for missing XPATH
- Table items are defined by a key, that is either a single element (such as name), or as a list of multiple XPATHs ('FPC 0', 'MIC 0', 'PIC 0'). In 1.0 if one of the XPATH elements was missing, an uncaught exception was thrown.
- Updated the code to replace missing elements with None.

Example

yaml
PicHwTable:
rpc: get-chassis-inventory
item: .//name[starts-with(.,'PIC')]/parent::*
key:
- ancestor::*[starts-with(name,'FPC')]/name
- ancestor::*[starts-with(name,'MIC')]/name
- name
view: _pic_hw_view


python
pic.name: ('FPC 2', 'MIC 0', 'PIC 1')
pic.pn: BUILTIN
pic.sn: XXXX
pic.desc: 10x 1GE(LAN) SFP
pic.name: ('FPC 3', None, 'PIC 0')
pic.pn: BUILTIN
pic.sn: XXXX


Regex support for View boolean values
- Values in views can be set to a Boolean based on the presence of a field.
- Regex support was added to allow for easier matching and multiple values. This is done by setting the format to True/False=regex():

Example

yaml
no_absorb: { no-absorb: True=regex(no-absorb) }
no_refresh: { no-refresh: True=regex(\dx\d) }
no_refresh: { no-refresh: 'True=regex(Session ID: 0x0|no-refresh)' }


OS Install force-host
- Added force_host to support QFX OS Install

Example

python
SW.install('file', no_copy=True, force_host=True)


Added display_xml_rpc command
- To support the limiting of cli() a new function display_xml_rpc is introduced. By default it will return the XML element and text format is also supported.

Example

python
dev.display_xml_rpc('show system login lockout')
<Element get-system-login-lockout-information at 0x37b4b48>

dev.display_xml_rpc('show system login lockout', format='text')
'<get-system-login-lockout-information>\n</get-system-login-lockout-information>\n'



ncclient proxycommand support
- Updated to be compatible with the enhancements in ncclient 0.4.2 and added optional path variable for sshconfig file (by default ~/.ssh/config is queried).

Example


[rshermanlocalhost ~]$ cat .ssh/config
Host 192.168.74.31
User juniper
ProxyCommand ssh -l juniper 192.168.74.128 nc %h 22 2>/dev/null

>>> dev = Device('192.168.74.31')
>>> dev.open()
Device(192.168.74.31)


Added support for pipe (union) operator in Table keys
- Added the ability to use an XPATH pipe (union) operator for Table keys. This feature was already supported with View fields.
- The syntax is ' | ' (space + pipe + space) between the values. The table will automatically append the item value + / to each element specified in the piped key.
- The most common use case for this is the implicit "or"; there are situations where keys may have a different name between releases or types of configuration (as is the case with LLDP on ELS and non-ELS switches).
- If there are multiple keys (of fields) listed with pipes that are found in the RPC reply they will be added to the list.

Example


key: lldp-local-interface | lldp-local-port-id

lldp.keys()
['me0.0', 'me0.0', 'me0.0', 'me0.0', 'xe-0/1/0.0']


Format optional for configuration strings
- When passing configuration data in as a string the library will attempt to automatically determine the format.

Example

python
config_string = "set interfaces ge-0/0/1 unit 10 family inet address 10.10.10.10/24"
cu.load(config_string)


Bugs Fixed

JSON Output
- Views that had compound keys failed to dump.
- RPC command output failed to dump.

Example

python
pic = PicHwTable(dev)
pic.get()
PicHwTable:sprite.englab.juniper.net: 1 items
pic.to_json()
'{"(\'FPC 2\', \'MIC 0\', \'PIC 0\')": {"pn": "BUILTIN", "sn": "BUILTIN", "name": ["FPC 2", "MIC 0", "PIC 0"], "desc": "4x 10GE(LAN) SFP+"}}'

import json
json.dumps(dev.rpc.get_system_uptime_information())
'{"system-booted-time": {"time-length": "3w3d 01:44", "date-time": "2014-11-11 13:47:28 PST"}, "uptime-information": {"active-user-count": "\\n1\\n", "load-average-5": "\\n0.03\\n", "load-average-15": "\\n0.03\\n", "up-time": "\\n24 days, 1:44\\n", "load-average-1": "\\n0.00\\n", "date-time": "\\n3:31PM\\n"}, "protocols-started-time": {"time-length": "2d 04:10", "date-time": "2014-12-03 11:21:27 PST"}, "last-configured-time": {"time-length": "2d 00:58", "user": "regress", "date-time": "2014-12-03 14:33:27 PST"}, "current-time": {"date-time": "2014-12-05 15:31:35 PST"}}'


FutureWarning
- Config utility would output a FutureWarning

1.0.2

Not secure
Bugs fixed:
- XML Templates not properly loading
- Templates without a file extension no longer assumed to be XML

Page 8 of 10

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.