DiffProcessor Plugin

Processor plugin to run diff against previous task’s results saved using ToFileProcessor.

DiffProcessor Sample Usage

Code to demonstrate how to use DiffProcessor plugin:

from nornir import InitNornir
from nornir_netmiko import netmiko_send_command
from nornir_salt.plugins.processors import DiffProcessor

nr = InitNornir(config_file="config.yaml")

nr_with_processor = nr.with_processors([
    DiffProcessor(diff="config")
])

nr_with_processor.run(
    task=netmiko_send_command,
    command_string="show run"
)

DiffProcessor reference

nornir_salt.plugins.processors.DiffProcessor.DiffProcessor(diff, base_url='/var/nornir-salt/', last=1, in_diff=False, ignore_lines=None, remove_patterns=None, index=None)

DiffProcessor can report difference between current task’s results and previously saved results.

Parameters
  • diff – (str) filegroup name to run diff for

  • base_url – (str) OS path to folder with files, default “/var/nornir-salt/”

  • last – (int) default is 1, file index to compare with

  • ignore_lines – (list) list of regular expression pattern to filter lines through, if line matches any of the patterns, it is ignored by removing it; by default any line that contains only space characters ignored

  • remove_patterns – (list) list of regular expression pattern to remove from lines

  • in_diff – (bool) default is False, if True uses Result object diff attribute to store diff results, otherwise uses task’s Result.result attribute to store diffs

  • index – (str) ToFileProcessor index file name to read files info from

ignore_lines and remove_patterns arguments exists to clean difference results, for instance by ignoring timestamps, counters or other uninteresting data.