Skip to content

Commit

Permalink
Add "baseline" to nk-compare-configs
Browse files Browse the repository at this point in the history
You are now able to set a baseline key in the config files, this will
allow users to choose which device is used as their baseline.
  • Loading branch information
ogenstad committed Mar 10, 2018
1 parent 9e23724 commit b36408f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
language: python
env:
- TOXENV=py27
- TOXENV=py34
- TOXENV=py35
- TOXENV=py36
install:
- pip install tox
- pip install coveralls
Expand Down
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
---------------

0.0.5
+++++

* Allow configuration of baseline file for nk-compare-configs

0.0.4
+++++

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Install using pip:

These tools are currently included:

* nk-compare-configs - Preforms audits of configuration files for network devices
* [nk-compare-configs](https://networklore.com/nk-compare-configs/) - Preforms audits of configuration files for network devices
* nk-snmp-deviceinfo - Polls a network device using SNMP to show vendor and version information
2 changes: 1 addition & 1 deletion lib/nelkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Nelkit - Networklore Toolkit."""

__author__ = 'Patrick Ogenstad'
__version__ = '0.0.4'
__version__ = '0.0.5'
1 change: 1 addition & 0 deletions lib/nelkit/cli/compare_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ def main():
cc = CompareConfigs(settings_file=args.c)
cc.output_diff()


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions lib/nelkit/modules/compare_configs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def __init__(self, settings_file=None, config_dir=None, baseline=None):
self._baseline = self._config_files[0]
else:
raise FileNotFound('No config files found')
else:
if '/' not in self._baseline:
self._baseline = self._config_dir + '/' + self._baseline

self._parse_config_files()
self._parse_sort_rules()
Expand Down Expand Up @@ -90,6 +93,7 @@ def _parse_configs_dir(self, config_setting, data):
config_dir = data['configs']
else:
raise NelkitException('config key not found in file')
self._config_dir = config_dir

if not isinstance(config_dir, list):
config_dir = [config_dir]
Expand Down Expand Up @@ -142,6 +146,9 @@ def _parse_settings(self):
data = l.data
self._parse_configs_dir(self._config_dir, data)

if not self._baseline:
self._baseline = data.get('baseline')

if 'rules' not in data.keys():
raise NelkitException('rules key not found in file')
rules = data['rules']
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34, py35
envlist = py27, py35, py36
[testenv]
deps =
pytest
Expand Down

0 comments on commit b36408f

Please sign in to comment.