Skip to content

7. jsnap2py

Priyal Jain edited this page Apr 11, 2016 · 3 revisions

Tool written in python to convert conf file in slax into yaml files. Using this tool you can convert JSNAP-SLAX conf files into yaml files that can be directly used by JSNAPy.

Installation

No explicit installation is required. It will automatically get installed while installing JSNAPy.

(venv)sh-3.2# jsnap2py
usage: jsnap2py [-h] [-i INPUT] [-o OUTPUT]

Converts JSNAP test to JSNAPy yml file.

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        JSNAP test file
  -o OUTPUT, --output OUTPUT
                        JSNAPy test file

Example

test_is_equal.conf

do {
      check_ospf;
}

check_ospf {
      command  show configuration protocols ospf ;
      item route-engine {
           is-equal mastership-state, "master" {
             info "Checking if RE0 is the Master RE ...";
             err " ERROR: RE0 is not the Master RE. Its current state is %s", $POST/mastership-state;
          }
      }
}

Run jsnap2py tool to convert above conf file into yaml file:

jsnap2py -i test_is_equal.conf

Output

check_ospf:
- command: show configuration protocols ospf
- item:
    tests:
    - err: ' ERROR: RE0 is not the Master RE. Its current state is {{post["mastership-state"]}}'
      info: Checking if RE0 is the Master RE ...
      is-equal: mastership-state, master
    xpath: route-engine
tests_include:
- check_ospf

If you want to give different output file name, then use -o option
For example:

jsnap2py -i test_is_equal.conf -o test_ospf.yml
Clone this wiki locally