Jsnapy

Latest version: v1.3.7

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

Scan your dependencies

Page 3 of 4

1.1.0

Not secure
Feature addition:
- **ignore-null** attribute support via 170
- Set it to True if you want to skip tests where nodes are not present in any of the specified xpaths in test.
- refer example [5](https://github.com/Juniper/jsnapy/wiki/2.-Writing-test-and-config-file#example-5-ignore-null-example) and [6](https://github.com/Juniper/jsnapy/wiki/2.-Writing-test-and-config-file#example-6-ignore-null-example-2)

Sample Output
![sample output](https://cloud.githubusercontent.com/assets/4725770/18831590/1ff828ae-8404-11e6-975f-7648e3e91f6e.png)
- **stored snapshots** can be used with snapcheck using `--local` option 172
Example:

`jsnapy --snapcheck STORED -f config.yml --local`
Where _STORED_ might have already been used by snap function to fetch snapshots

`jsnapy --snap STORED -f config.yml`
- Operators for **chained tests** 178
Now user can use `AND`, `OR` and `NOT` operators to chain their test cases. Final result will be decided depending on the mathematical calculation based on operators used. For more details refer: [PR](https://github.com/Juniper/jsnapy/pull/178) or [wiki](https://github.com/Juniper/jsnapy/wiki/8.-Conditional-Test-Operators)
- Docker image for JSNAPy

Feature enhancements:
- Added test based mail support 149
Depending on test results user can decide on which condition of overall test result mail to be sent.

yaml
mail:
pass: <filename>
fail: <filename>
all: <filename>

- User defined path for jsnapy.cfg
- The default location for jsnapy.cfg and logging.yml is /etc/jsnapy. User can change the default lookup location for jsnapy.cfg by setting JSNAPY_HOME environment variable.
- Alternatively, one can keep custom jsnapy.cfg and logging.yml at ~/.jsnapy also.
- Lookup order followed is: `JSNAPY_HOME -> ~/.jsnapy -> /etc/jsnapy`
- Location of all the other custom configuration files parked at /etc/jsnapy can now be specified at the installation time. Doing so will modify the jsnapy.cfg file at /etc/jsnapy
- Added option for the user to specify the default directory for snapshots, testfiles and custom configuration file directories during installation
- Installation via pip:
`sudo pip install jsnapy --install-option="--install-data=~/Desktop/test_inst"`

**Note** User still need to use _sudo_ to do the installation as we still create different config file at /etc/jsnapy

Bug fixes:
- Unable to use device with '-' in name -- Fix 158
- Slow printing and high cpu utilization -- Fix 143 and 157
- Groups should be able to have overlap and not run the test twice on the same IP 126 via 169
- Command line port parameter ignored if host/credentials specified in config file 136 via 169
- Unable to define multiple devices in the config file 138 via 169
- got error if the xpath return nothing 139 via 170
- snapcheck support for stored snapshots 132 via 172
- The location of /etc/jsnapy/ should be user-configurable

1.0.0

Not secure
Python version of Junos Snapshot Administrator

Junos® Snapshot Administrator in Python (jsnapy) enables you to capture and audit
runtime environment snapshots of your networked devices running the Junos OS. You
can capture and validate the operational status of a device and review operational
changes to a device. You create configuration files that define the scope of snapshots
and customize the test criteria for the snapshot data.
You can use Junos Snapshot Administrator in Python to perform the following functions
on either a single device or list of devices running Junos OS:

• Take a snapshot of the runtime environment on a device.
• Compare two snapshots.
• Audit a device’s runtime environment against pre-defined criteria.
• Use as a module in other Python programs.
• Send e-mail alerts that include test results.
• Store and compare snapshots in an SQLite database.

0.1.9beta

Feature Enhancement:
1. Added unit test cases
2. Added details of tests included in debug mode, while taking snapshot.
3. Ignoring extra arguments passed from command line when using JSNAPy as a module

0.1.8beta

Feature Enhancement:
1. making username prompt optional in case of --diff and --check option.

Bug Fixes:
1. putting validation on values in in-range and not-range test operation.
2. Making error messages more verbose and user friendly.

0.1.7beta

Feature Enhancement:
1] Modifying output in case of module


test_command_version:
- command: show interfaces terse
- iterate:
xpath: physical-interface
id: ['./name', 'admin-status']
tests:
- no-diff: oper-status
err: "Test Failed!! oper-status got changed, before it was <{{pre['oper-status']}}>, now it is <{{post['oper-status']}}> with name <{{id_0}}> and admin status <{{post['admin-status']}}>"
info: "Test Passed! oper-status is same with value, before it is <{{pre['oper-status']}}> now it is <{{post['oper-status']}}> with admin status <{{post['admin-status']}}> "


Below is the output of “no-diff” test operation.

Tested on adora
Final result: Passed
Total passed: 1
Total failed: 0
{'show interfaces terse': [{'count': {'fail': 0, 'pass': 59},
'failed': [],
'node_name': 'oper-status',
'passed': [[{'id': {'./name': 'tap',
'admin-status': 'up'},
'post': {'admin-status': 'up',
'oper-status': ['up']},
'post_node_value': ['up'],
'pre': {'oper-status': ['up']},
'pre_node_value': ['up']}],
[{'id': {'./name': 'pimd',
'admin-status': 'up'},
'post': {'admin-status': 'up',
'oper-status': ['up']},
'post_node_value': ['up'],
'pre': {'oper-status': ['up']},
'pre_node_value': ['up']}]],
'post_xml': <lxml.etree._ElementTree object at 0x10d958f80>,
'pre_xml': <lxml.etree._ElementTree object at 0x10d958ef0>,
'result': True,
'testoperation': 'no-diff',
'xpath': 'physical-interface'}]}


2] Added verbosity:


-v, --verbosity Set verbosity
-v: Debug level messages
-vv: Info level messages
-vvv: Warning level messages
-vvvv: Error level messages
-vvvvv: Critical level messages


Bug Fixes:
1] Making error messages more precise for better understanding.

0.1.6beta

Feature Enhancement:

1] Added functionality to pass port number:


hosts:
- device: 100.219.16.204
username : foo
passwd: baar
port: 830
tests:
- test_is_gt.yml


From command line
-P PORT, --port PORT port no to connect to device


(venv)sh-3.2 jsnapy --snap pre -l foo -p bar -t 10.209.16.204 -P 830 -f config_single_snapcheck.yml
Connecting to device 10.209.16.204 ................
Taking snapshot for show interfaces terse ................


2] Added new test operator
It can be used to compare node values using regular expression:

yaml
(venv)sh-3.2 cat test_regx.yml
test_interfaces_terse:
- command: show interfaces terse
- iterate:
xpath: //physical-interface/name[starts-with(normalize-space(text()),'ge-')]
tests:
- regex: ../name , ge-\d/\d/\d
info: "Test Succeeded !! name is equal to <{{post['../name']}}> "
err: "Test Failed !! name is equal to <{{post['../name']}}> "


Output:


(venv)sh-3.2 jsnapy --snapcheck -f config_single_snapcheck.yml
Connecting to device adora ................
Taking snapshot for show interfaces terse ................
******************************* Device: adora *******************************
Tests Included: test_interfaces_terse
*********************** Command: show interfaces terse ***********************
-----------------------Performing regex Test Operation-----------------------
Test Succeeded !! name is equal to <ge-1/0/0>
Test Succeeded !! name is equal to <ge-1/0/1>
Test Succeeded !! name is equal to <ge-1/0/2>
Test Succeeded !! name is equal to <ge-1/0/3>
Test Succeeded !! name is equal to <ge-1/0/4>
Test Succeeded !! name is equal to <ge-1/0/5>
Test Succeeded !! name is equal to <ge-1/0/6>
Test Succeeded !! name is equal to <ge-1/0/7>
Test Succeeded !! name is equal to <ge-1/0/8>
Test Succeeded !! name is equal to <ge-1/0/9>
Test Succeeded !! name is equal to <ge-1/1/0>
Test Succeeded !! name is equal to <ge-1/1/1>
Test Succeeded !! name is equal to <ge-1/1/2>
Test Succeeded !! name is equal to <ge-1/1/3>
Test Succeeded !! name is equal to <ge-1/1/4>
Test Succeeded !! name is equal to <ge-1/1/5>
Test Succeeded !! name is equal to <ge-1/1/6>
Test Succeeded !! name is equal to <ge-1/1/7>
Test Succeeded !! name is equal to <ge-1/1/8>
Test Succeeded !! name is equal to <ge-1/1/9>
PASS | All "../name" matches with regex "ge-\d/\d/\d" [ 20 matched ]
------------------------------- Final Result!! -------------------------------
Total No of tests passed: 1
Total No of tests failed: 0
Overall Tests passed!!!

Page 3 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.