Skip to content

Releases: Juniper/jsnapy

JSNAPy 1.2.1 release

09 Nov 11:18
93a2118
Compare
Choose a tag to compare

Bug Fixes

  • Ansible mulitple device Testing issue --Fix #263 via #274
  • bdist_wheel error during pip install jsnapy --Fix #265 via #268
  • MacOS Darwin jsnapy install failure- Fix #266 via #267
  • list-not-more function not showing failed messages -Fix #269 via #273
  • Including kwargs hash value in snapshot file name #282

JSNAPy 1.2.0 release

16 Jun 11:12
Compare
Choose a tag to compare

Feature addition

  • Compatibility to Windows and Python Virtual Environment.#252

    • Now install jsnapy on windows using pip install jsnapy. For Documentation related to Windows refer
      windows support
    • If user does not have sudo permissions, create virtual environment in python and activate it. Install jsnapy
      using pip install jsnapy. For Documentation related to Python virtual environment refer Virtual Environment support
  • JSNAPy Compatible to Python 3.4+

    • In addition to existing features, the newer version of JSNAPy also supports python 3.4+ .

Feature Enhancement

  • Running testfile through CLI #199
    Enabling passing testfile through Command Line.
    For Single Testfile
    jsnapy --snapcheck <snap_name> --testfiles <test_file1> --hostname <host_name> --login <login> --passwd <passwd>
    For Multiple Testfiles
    jsnapy --snapcheck <snap_name> --testfiles <test_file1> <test_file2> <test_file3> --hostname <host_name> --login <login> --passwd <passwd>

For more Reference, see how to use optional arguments in jsnapy through cli

  • Adding message to Dictionary #254
from jnpr.jsnapy import SnapAdmin
from pprint import pprint

js = SnapAdmin()
pre_pass = js.snap('config.yml', 'pre_check')
post_pass = js.snap('config.yml', 'post_check')
snapval = js.check('config.yml', 'pre_check', 'post_check')

for item in snapval:
    print("\n -----------check----------")
    print("Tested on", item.device)
    print("Final result: ", item.result)
    print("Total passed: ", item.no_passed)
    print("Total failed:", item.no_failed)
    pprint(item.test_results)

config.yml

hosts:
  - device: 1.1.1.1
    username: abc
    passwd: xyz

tests:
  - test_in_range.yml

test_in_range.yml

check_chassis_fpc:
  - command: show chassis fpc
  - iterate:
      xpath: fpc[normalize-space(slot) = "0"]
      tests:
       - in-range: memory-heap-utilization, 5, 40
         info: "Test Succeeded!! memory heap utilisation of the FPCs is within the range of 5-40, it is <{{post['memory-heap-utilization']}}> with temperature: <{{post['temperature']}}>"
         err: "Test Failed!! memory heap utilisation of the FPCs is not in range of 5-40, it is <{{post['memory-heap-utilization']}}> with temperature: <{{post['temperature']}}>"

Output

-----------check----------
('Tested on', '1.1.1.1')
('Final result: ', 'Passed')
('Total passed: ', 1)
('Total failed:', 0)
{'show chassis fpc': [{'count': {'fail': 0, 'pass': 1},
                       'expected_node_value': [5.0, 40.0],
                       'failed': [],
                       'node_name': 'memory-heap-utilization',
                       'passed': [{'actual_node_value': '20',
                                   'id': {},
                                   'message': 'Test Succeeded!! memory heap utilisation of the FPCs is within the range of 5-40, it is <20> with temperature: <Testing>',
                                   'post': {'memory-heap-utilization': '20',
                                            'temperature': 'Testing'},
                                   'pre': {'memory-heap-utilization': '20'}}],
                       'result': True,
                       'test_name': 'check_chassis_fpc',
                       'testoperation': 'in-range',
                       'xpath': 'fpc[normalize-space(slot) = "0"]'}]}
  • Report results using test name as key with new attribute testname_results  #253
    Using above files
from pprint import pprint

js = SnapAdmin()
pre_pass = js.snap('config.yml', 'pre_check')
post_pass = js.snap('config.yml', 'post_check')
snapval = js.check('config.yml', 'pre_check', 'post_check')

for item in snapval:
    print("\n -----------check----------")
    print("Tested on", item.device)
    print("Final result: ", item.result)
    print("Total passed: ", item.no_passed)
    print("Total failed:", item.no_failed)
    pprint(item.testname_results)
-----------check----------
('Tested on', '1.1.1.1')
('Final result: ', 'Passed')
('Total passed: ', 1)
('Total failed:', 0)
{'check_chassis_fpc': [{'command': 'show chassis fpc',
                        'count': {'fail': 0, 'pass': 1},
                        'expected_node_value': [5.0, 40.0],
                        'failed': [],
                        'node_name': 'memory-heap-utilization',
                        'passed': [{'actual_node_value': '20',
                                    'id': {},
                                    'message': 'Test Succeeded!! memory heap utilisation of the FPCs is within the range of 5-40, it is <20> with temperature: <Testing>',  
                                    'post': {'memory-heap-utilization': '20',
                                             'temperature': 'Testing'},
                                    'pre': {'memory-heap-utilization': '20'}}],
                        'result': True,
                        'testoperation': 'in-range',
                        'xpath': 'fpc[normalize-space(slot) = "0"]'}]}

Bug Fixes

  • Port issue fixed -- Fix #215 via #216
  • Jsnapy python module and snapcheck method with local=True argument --Fix #217 via #218
  • Changes for virtualenv --Fix #221 via #252
  • Corrected --diff command example #234
  • Duplicate log for delta operator if ID is missing #236 via #237
  • ID.1 not getting converted to id_0 solved #226 via #238
  • Delta Operator-fix for positive percentages #241
  • Fix for range in positive value for delta #243
  • Finding Testop error #245
  • multiple devices thread infinite loop issue #256

NOTE

  • For Extending the support to virtualenv Python there have been a few major structure changes, Keeping into consideration the user's with no sudo permissions. This will help to extend code to wider audience.

JSNAPy 1.1.0 release

03 Jan 11:18
Compare
Choose a tag to compare

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 and 6

    Sample Output
    sample output

  • 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 or wiki

  • 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.

      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

JSNAPy v1.0.0

26 Aug 10:50
Compare
Choose a tag to compare

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.

For systests(v0.1.9-beta)

29 Jun 10:24
Compare
Choose a tag to compare
Pre-release

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

For systests(v0.1.8-beta)

31 May 11:07
Compare
Choose a tag to compare
Pre-release

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.

For systests(v0.1.7-beta)

23 May 07:05
Compare
Choose a tag to compare
Pre-release

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.

For systests(v0.1.6-beta)

26 Apr 11:30
Compare
Choose a tag to compare
Pre-release

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:

(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!!! 

For systests(v0.1.5-beta)

25 Apr 12:57
Compare
Choose a tag to compare
Pre-release

Feature Enhancement:

1] Functionality to pass id as a list.
Now IDs can be passed both as string or list.
For Example

One way:

test_command_bgp_neighbor:
  - command: show bgp neighbor
  - iterate:
      xpath: bgp-peer
      id: [ ./peer-address, ./peer-as ]
........

Second way:
test_command_bgp_neighbor:
  - command: show bgp neighbor
  - iterate:
      xpath: bgp-peer
      id: ./peer-address, ./peer-as
.....

2] Modified test cases to compare attribute values.
Can compare attributes via:

check_int_ext:
    - command: show interfaces extensive
    - iterate:
        xpath: //interface-information/physical-interface[normalize-space(admin-status)="up" and logical-interface/address-family/address-family-name and interface-flapped[@seconds]]
        tests:
          - is-gt: interface-flapped/@seconds, 600
            info: Interfaces {{post['name']}} with family defined is UP for more than 10 min
            err: Interface {{post['name']}} is Up since XX seconds

3] Less verbose CLI output.
Modified info and debug level messages in case of test pass and fail.
4] Changes for module feature.
5] JSNAPy can also take test file from present working directory.

Now user can give test files by:
1. giving complete path
2. it is present in current working directory
3. it looks in default directory mentioned in jsnapy.cfg (/etc/jsnapy/testfiles)

6] More verbose error message.
Now error message is also printing xpath and id details when no node is found.

Bug Fixes:

  1. Modified messages in case of id miss match
  2. resolving space issue in info and err messages
  3. resolving issue in printing err/info messages (hyphen was getting converted into underscore)
  4. If arguments are not given properly, then it should print help message

For systests(v0.1.4-beta)

01 Apr 10:59
Compare
Choose a tag to compare
Pre-release

Feature Enhancement:

  1. Added support for configuration command by using display xml
    For example:
check_certificate:
  - command: show configuration security certificates | display xml
  - iterate:
      xpath: //configuration/security/certificates
      tests:
        - is-equal: local/name, mycert
          info: "Name matches .. PASS...NAME -  <{{pre['local/name']}}>"
          err:  "Name Not matching.. FAIL...NAME -  <{{pre['local/name']}}>"
  1. Added jsnap2py tool to convert JSNAP-slax conf files into yaml files that can be directly consumed by JSNAPy.
  2. Added wiki page containing documentation about JSNAPy.
  3. Modified sample examples.

Bug Fixes

  1. Fix bug in no-diff and delta test operator, in case when no of post nodes are greater than no of pre nodes.
  2. Added color to error and exception messages.
  3. Modified no_diff, not_less, not_more and delta for id miss match error.