-
Notifications
You must be signed in to change notification settings - Fork 4
04. JSNAPy command line tool
https://github.com/Juniper/jsnapy/wiki/3.-Command-Line-Tool
jsnapy -h
Use this subcommand to compare the current configuration or the current operational states against pre-defined criteria.
The default snapshot name is snap_temp:
jsnapy --snapcheck -f <config_file>
ls snapshots/*snap_temp* -l
You can define a snapshot name:
jsnapy --snapcheck <snap_file_name> -f <config_file>
ls snapshots/*<snap_file_name>* -l
- Alarms:
JSNAPy files details:
sublime-text cfg_file_snapcheck_alarms.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_snapcheck_alarms.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_alarms.yml
ls -l snapshots/*_snap_temp_*
Usage with another snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_alarms.yml snapshot_name
ls -l snapshots/*_snapshot_name_*
- Interfaces:
JSNAPy files details:
sublime-text cfg_file_snapcheck_intf_states.yml
sublime-text testfiles/devices.yml
sublime-text test_file_snapcheck_intf_states.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_intf_states.yml
- BGP:
JSNAPy files details:
sublime-text cfg_file_snapcheck_bgp_states.yml
sublime-text testfiles/test_file_snapcheck_bgp_states.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml
- LLDP:
JSNAPy files details:
sublime-text cfg_file_snapcheck_lldp_cfg.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_snapcheck_lldp_cfg.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_lldp_cfg.yml
- Name-servers:
JSNAPy files details:
sublime-text cfg_file_snapcheck_name_servers_cfg.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_snapcheck_name_servers_cfg.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_name_servers_cfg.yml
ls -l snapshots/*_snap_temp_*
Using another snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_name_servers_cfg.yml snapshot_name
ls -l snapshots/*_snapshot_name_*
- Various topics:
JSNAPy files details:
sublime-text cfg_file_snapcheck_cfg.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_snapcheck_cfg.yml
Usage with default snapshot name:
jsnapy --snapcheck -f cfg_file_snapcheck_cfg.yml
The default console logging level is info:
/etc/jsnapy/logging.yml
You can set the verbosity to debug level messages using -v
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml -v
You can use optional arguments.
Run this command to discover the optional arguments:
jsnapy -h
It is not required 172.30.179.73 exists in the config file config.snapcheck.states.yml:
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml -v -t 172.30.179.73 -l pytraining -p Poclab123 -P 830
Jsnapy will prompt you to provide the username and password:
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml -v -t 172.30.179.73
Presence of --local option runs the tests on stored snapshot.
To use this command one has to first create snapshot using --snap command.
https://github.com/Juniper/jsnapy/wiki/3.-Command-Line-Tool#optional-arguments
jsnapy --snapcheck <snap_name> -f <config_file> --local
jsnapy --snap -f cfg_file_snapcheck_bgp_states.yml snapshot_name
ls snapshots/*snapshot_name* -l
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml --local -v snapshot_name
snap_temp is the default snapshot name, so these 2 commands do the same thing:
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml --local -v
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml --local -v snap_temp
Use the key local in the configuration file if you want to run snapcheck on stored snapshots.
Works with --snapcheck command only.
For exemple in cfg_file_snapcheck_bgp_states_on_local_snapshots.yml, STORED is being used.
sublime-text cfg_file_snapcheck_bgp_states_on_local_snapshots.yml
So we might have already done a snap.
jsnapy --snap STORED -f cfg_file_snapcheck_bgp_states_on_local_snapshots.yml
ls snapshots/*STORED* -l
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states_on_local_snapshots.yml
You can specify custom jsnapy lookup directory (--folder).
https://github.com/Juniper/jsnapy/wiki/3.-Command-Line-Tool#optional-arguments
ls other_jsnapy_folder/ -l
ls other_jsnapy_folder/testfiles -l
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states.yml --folder other_jsnapy_folder
jsnapy --snap -f cfg_file_snapcheck_bgp_states_on_local_snapshots.yml --folder other_jsnapy_folder STORED
jsnapy --snapcheck -f cfg_file_snapcheck_bgp_states_on_local_snapshots.yml --folder other_jsnapy_folder
Use this subcommand to take a snapshot.
jsnapy --snap <file_name> -f <config_file>
- BGP operational states:
sublime-text cfg_file_check_bgp_states.yml
sublime-text testfiles/test_file_check_bgp_states.yml
jsnapy --snap pre -f cfg_file_check_bgp_states.yml -v
ls snapshots/*_pre_*
jsnapy --snap post -f cfg_file_check_bgp_states.yml
ls snapshots/*_post_*
Use this subcommand to compare two snapshots based on tests.
So you first need to take 2 snapshots (snap).
jsnapy --check <pre_snap> <post_snap> -f <config_file>
- BGP operational states:
jsnapy --snap pre -f cfg_file_check_bgp_states.yml
jsnapy --snap post -f cfg_file_check_bgp_states.yml
jsnapy --check pre post -f cfg_file_check_bgp_states.yml -v
- Interfaces configurations:
sublime-text cfg_file_check_intf_cfg.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_check_intf_cfg.yml
jsnapy --snap pre -f cfg_file_check_intf_cfg.yml
ls snapshots/*_pre_*
jsnapy --snap post -f cfg_file_check_intf_cfg.yml
ls snapshots/*_post_*
jsnapy --check pre post -f cfg_file_check_intf_cfg.yml -v
Use this subcommand to compare two snapshots (either in xml or text format) character by character.
So you first need to take 2 snapshots (snap).
Supported only in command line mode.
jsnapy --diff <pre_snap> <post_snap> -f <config_file>
sublime-text cfg_file_diff.yml
sublime-text testfiles/devices.yml
sublime-text testfiles/test_file_diff.yml
jsnapy --snap pre -f cfg_file_diff.yml
ls snapshots/*_pre_*
jsnapy --snap post -f cfg_file_diff.yml
ls snapshots/*_post_*
jsnapy --diff pre post -f cfg_file_diff.yml