Python version of Junos Snapshot Administrator
Python HTML
Clone or download
Permalink
Failed to load latest commit information.
docs
lib/jnpr Updating version (#320) May 31, 2018
logs removed unnecessary files from git Dec 15, 2016
samples SRX testing files Aug 5, 2017
snapshots removed unnecessary files from git Dec 15, 2016
static
testfiles removed unnecessary files from git Dec 15, 2016
tests
tools Removing problem for absolute path on element Apr 6, 2017
.gitignore prepare to replease 1.1.0 Dec 27, 2016
.travis.yml .travis update Jun 12, 2017
CONTRIBUTING.md updating Contributing.md Mar 19, 2018
COPYRIGHT adding license and copyright Apr 20, 2016
Dockerfile Remove Neconify as it’s not needed with Pyez 2.0.1 Nov 22, 2016
INSTALL-FEDORA.md installation steps added Jul 26, 2016
INSTALL-FREEBSD.md installation steps added Jul 26, 2016
INSTALL-OSX.md installation steps added Jul 26, 2016
INSTALL-UBUNTU-DEBIAN.md installation steps added Jul 26, 2016
LICENSE
MANIFEST.in keeping folder not related to library outside lib folder May 2, 2016
README adding feature of setting env using config file,jsnapy.cfg Dec 23, 2015
README.md Updating version (#320) May 31, 2018
development.txt trying with pytest Aug 26, 2016
docker_build
docker_run Change shell from Bash to Bourne Aug 2, 2016
requirements.txt
setup.cfg changes for UT and code coverage Aug 26, 2016
setup.py Bdist build wheel error May 31, 2018

README.md

PyPi Version Coverage Status Coverage Status

JSNAPy

Python version of Junos Snapshot Administrator

JSNAPy logo

Inspired by https://github.com/Juniper/junos-snapshot-administrator

Abstract

Junos Snapshot Administrator enables you to capture and audit runtime environment snapshots of your networked devices running the Junos operating system (Junos OS).

You can write your test cases in yaml file and run those tests cases against pre and post snapshots.

Installation

Installation requires Python 2.7 and associated pip tool

1. Install using pip command
      sudo pip install jsnapy
2. Install using pip command from github
      sudo pip install git+https://github.com/Juniper/jsnapy.git 
3. Updating using pip command (from github)
      sudo pip install -U git+https://github.com/Juniper/jsnapy.git 
4. Download or clone the source code from this git repository
      git clone https://github.com/Juniper/jsnapy
   Or Untar jsnapy-master.zip (if downloaded zip folder)
      unzip jsnapy-master.zip
   Go to jsnapy-master folder and install by:
      sudo python setup.py sdist
      sudo pip install dist/jsnapy-x.x.tar.gz

Hello, World

JSNAPy requires one main config file and test files. Config file contains device details and test files to be executed.

config_check.yml:

# for one device, can be given like this:
    hosts:
      - device: router 
        username : abc
        passwd: pqr
    tests:
      - test_no_diff.yml 

test_no_diff.yml

test_command_version:
  - command: show interfaces terse lo* 
  - iterate:
      xpath: physical-interface
      id: './name'
      tests:
        - no-diff: oper-status       # element in which test is performed
          err: "Test Failed!! oper-status  got changed, before it was <{{pre['oper-status']}}>, now it is <{{post['oper-status']}}>"
          info: "Test Passed!! oper-status is same, before it is <{{pre['oper-status']}}> now it is <{{post['oper-status']}}> 

To run this test execute following command:

1. jsnapy --snap pre -f config_check.yml (for taking pre snapshot)
2. jsnapy --snap post -f config_check.yml (for taking post snapshot after some modification)
3. jsnapy --check pre post -f config_check.yml (compares pre post snapshot as per test cases)
4. jsnapy --diff pre post -f config_check.yml (compares pre post snapshot files, shows the diff in 2 Columns)

Output will look something like this:

(venv)sh-3.2# jsnapy --check pre post -f config_single_check.yml 
*************************Performing test on Device: 10.209.16.204*************************
Tests Included: test_command_version 
*************************Command is show interfaces terse lo**************************
----------------------Performing no-diff Test Operation----------------------
Test succeeded!! oper_status is same, before it is <['up']> now it is <['up']> 
Final result of no-diff: PASSED 
------------------------------- Final Result!! -------------------------------
Total No of tests passed: 1
Total No of tests failed: 0 
Overall Tests passed!!! 

File Paths:

1. config file   
   can give either:
    - full file path  
    - only file name, in this case JSNAPy will first look in present working 
      directory, if file is not present then it will take file path from "config_file_path" 
      in jsnapy.cfg file. Default config file path is "/etc/jsnapy"
2. test file: 
    - full file path  
    - only file name, in this case it will take path from "test_file_path" in jsnapy.cfg file. 
      Default test file path is "/etc/jsnapy/testfiles"
3. snap file:
    - full file path
    - tag, in this case file name is formed automatically (<devicename>_<tag>_<command/rpc>.<xml/text>)
      Snap files will be taken from "snapshot_path" in jsnapy.cfg file. 
      Default path is "/etc/jsnapy/snapshots"

jsnap2py:

Tool to convert conf file of JSNAP slax into yaml file that can be consumed by JSNAPy.

jsnap2py -i test_interface.conf

This will convert slax conf file "test_interface.conf" into yaml file "test_interface.yaml".
If you want to give different output file name, then use -o option

jsnap2py -i test_interface.conf -o interface.yml

For more information please refer [jsnap2py-wiki] (https://github.com/Juniper/jsnapy/wiki/7.-jsnap2py)

CONTRIBUTORS

Juniper Networks is actively contributing to and maintaining this repo. Please contact jnpr-community-netdev@juniper.net for any queries.

Contributors: