I am new to Opconfig , and been reading documentation. Also am not a full fledged programmer, I know some python that I usually use to automate device configuration ( I know the basics).. I ve setup a lab with opconfig and two Juniper VMX device. I am basically trying to run before I could walk at this stage but I think I grasped the basics,, I am trying to do the following : VMX-VCP1 device considered has base config, and am comparing that configuration against another device VMX-VCP2. I have wrote a python script and basically used some module to compare the files and have an output of the difference with ignoring some parameters.

In Opconfig Command set:

'commands' => [ { 'tags' => ['DAILY', 'configuration', 'detect-change', 'junos'], 'command' => "ler-pair-diff", 'use_collection_plugin' => "VMXDIFF", }, 'tags' => ['DAILY', 'configuration', 'detect-change', 'junos'], 'command' => 'show configuration | display set | match interfaces',
'privileged' => 'true', 'store_internal' => 'false',
'multipage' => 'true',
'command_filters' => [ '/Last commit/', '/MEL-DN1-LAB-LER/', '/192.168.4./',

I have the two devices files configuration output of "show configuration | display set | match interfaces" saved locally from Opconfig on :

abooda@nmis-opconfig:/usr/local/omk/var/opconfig/external$ ls -l

total 12 -rwxr-xr-x 1 root root 226 Jul 9 05:19 VMX-COMMON.txt drwxr-xr-x 6 root root 4096 Jul 7 05:42 VMX-VCP1 drwxr-xr-x 6 root root 4096 Jul 7 05:42 VMX-VCP2

I created a txt file called VMX-COMMON.txt which have the commands sets that I want to ignore, Then I have a python script that uses a module (not reinventing the wheel here) to do the comparison, the script is simple and looks like this :

abooda@nmis-opconfig:/usr/local/omk/conf/config_plugins$ cat vmx-diff.py

import diffios
def config_diff(f1,f2,ignore):
diff = diffios.Compare(f1,f2,ignore) if not diff.delta() == '--- baseline\n+++ comparison\n\n\n': return print(diff.delta())

conf_file1= "/usr/local/omk/var/opconfig/external/VMX-VCP1/show_configuration___display_set___match_interfaces/latest"

conf_file2= "/usr/local/omk/var/opconfig/external/VMX-VCP2/show_configuration___display_set___match_interfaces/latest"

ignored_vmx ="/usr/local/omk/var/opconfig/external/VMX-COMMON.txt" config_diff(conf_file1,conf_file2,ignored_vmx)

if you execute it : abooda@nmis-opconfig:/usr/local/omk/conf/config_plugins$ python3 vmx-diff.py

--- baseline
+++ comparison
+ 1: set interfaces ge-0/0/7 unit 0 family inet address

so its telling you after ignoring contents in VMX-COMMON.txt , returing the difference. So now I am trying to feed this data into opconfig and be able to event on it if there is a difference, I am using a collection plugin, but I am kinda confused how to feed the data from the python script to the plugin .pm file. String/dictionary? Although I watched the video but still not sure how . my .pm file looks like this

: root@nmis-opconfig:/usr/local/omk/conf/config_plugins# cat VMXDIFF.pm

package VMXDIFF;
our $VERSION = "1.0.0";
use strict;
use Data::Dumper;

sub collect_configuration { my (%args) = @_; my ($node, $node_info, $command, $credential_set, $logger, $opconfig) = @args{qw(node node_info command credential_set logger opconfig)}; $logger->info("Plugin ".__PACKAGE__." about to collect data for $node, command $command->{command}");
# maybe we need to shell out to some program?
system ("/usr/bin/python3 /usr/local/omk/conf/config_plugins/vmx-diff.py P") or return { error => "failed to start complicated_operation: $!" };
my $goodies =<P>;
close P;
return { error => "complicated_operation failed: $?" } if ($?); return { success => 1, configuration_data => $goodies }; }

on debug,looks I am getting something and the output of the script somewhere, but errors too. Not sure about my understanding here, can I have some tips/help?

/usr/local/omk/bin/opconfig-cli.pl act=run_command_sets command=VMXDIFF node=VMX-VCP2 debug=1

[Mon Jul 12 01:19:56 2021] [debug] worker.command[337500] Found suitable plugin VMXDIFF

[Mon Jul 12 01:19:56 2021] [debug] worker.command[337482] No changes since revision 3 for VMX-VCP1 (, command "show configuration", adjusting updated_at --- baseline +++ comparison + 1: set interfaces ge-0/0/7 unit 0 family inet address

[Mon Jul 12 01:19:56 2021] [warn] worker.command[337488] Failed to run command ler-pair-diff: Plugin "VMXDIFF" reported failure: failed to start complicated_operation:

[Mon Jul 12 01:19:56 2021] [error] worker.command[337488] $VAR1 = {};

    CommentAdd your comment...