JSNAPy 1.2.0 release
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
usingpip install jsnapy
. For Documentation related to Python virtual environment refer Virtual Environment support
- Now install jsnapy on windows using
-
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.