Chuck Anderson writes:
>Using NETCONF with Perl Net::Netconf::Manager, I'm trying to get the
>candidate configuration to see what changed before issuing a commit
>request so I can avoid "empty" commits after doing a "replace"
>operation on a subtree.  I see that NETCONF defines a standard
><get-config> call, and I believe <get-configuration> is a
>legacy/proprietary Junos call.  There is a <get-config> example in the
>documentation, but there doesn't appear to be a way to see what was
>changed in the candidate config vs. the committed config:

Yes, JUNOS supports all the older API calls side-by-side with the
standard NETCONF API.  When we were working on the NETCONF standard,
my preference was for full words, and the concensus was "we'll use
full word but 'config' is a word", which I thought was odd, but was
happy find it allowed us to use our configuration-as-a-full-word
versions in a slick backwards compatible way.

>But I can't for the life of me figure out how to pass the various
>attributes inside the <get-configuration> tag with Perl.  How does one
>map the attributes INSIDE a tag to the Perl API call as below?

The module needs a means of adding methods, as well as methods for
the legacy API calls.

><get-configuration changed="changed" compare="rollback" database="candidate">

I'm not sure this is really what you what.  This will return the
full configuration with "junos:changed='changed'" attributes on any
element that's changed.  You might be better served with the "compare"
attribute on the get-configuration RPC, which returns the text-based
diff-like format.  It's not usable in terms of XML content, but
will only return the changed items.  If the output is empty, then
you don't need to commit.

But that still leaves you with the same problem, how to put attributes
on the <get-configuration> RPC.  You need something in like:

sub add_method
    my %map = (
        'no-args' => $NO_ARGS,
        'toggle' => $TOGGLE,
        'toggle-no' => $TOGGLE_NO,
        'string' => $STRING,
        'dom' => $DOM,
        'attribute' => $ATTRIBUTE,
        'url' => $URL_STRING,
        'dom-string' => $DOM_STRING,
    my ($method, %args) = @_;

    my %info;

    foreach my $field (keys(%args)) {
        $info{$field} = $map{$args{$field}};
    $methods{$fn} = \%info;

My perl's a bit rusty and I need to bug out for the day, but that's
the gist of it.  I'll proof it and get it added to asap.
Then you can add_method('get-configuration') with the proper content.

juniper-nsp mailing list

Reply via email to