[rancid] Issue with nx-os after switch upgrades

Jethro R Binks jethro.binks at strath.ac.uk
Thu Mar 5 09:42:28 UTC 2015


Now you mention it, I have done likewise for the comware stuff.  In fact I 
actually abstracted into subroutines to minimise repetition.  Now my 
command processing subs all look something like this near the start:

   while (<$INPUT>) {
        tr/\015//d;
        last if(/^\s*$prompt/);
        chomp;
        $_ = filter_lines($_);

        return(1) if command_not_valid($_);
        return(-1) if command_not_auth($_);
        next if skip_pattern($_);

and then I have:

# Some commands are not supported on some models or versions
# of code.
# Remove the associated error messages, and rancid will ensure that
# these are not treated as "missed" commands
sub command_not_valid {
    my ($l) = (@_);

    if ( $l =~
        /% Too many parameters found at '\^' position/ ||
        /% Unrecognized command found at '\^' position/ ||
        /% Incomplete command found at '\^' position./ ||
        /(% )?Wrong parameter found at '\^' position/ ||
        /% Wrong device .+/
    ) {
        return(1);
    } else {
        return(0);
    }
}

# Some commands are not authorized under the current
# user's permissions
sub command_not_auth {
    my ($l) = (@_);

    if ( $l =~
        /Permission denied\./
    ) {
        return(1);
    } else {
        return(0);
    }
}

# Some output lines are always skipped
sub skip_pattern {
    my ($l) = (@_);

    if ( $l =~
        /^\s+\^$/
    ) {
        return(1);
    } else {
        return(0);
    }
}



On Wed, 4 Mar 2015, Alan McKinnon wrote:

> On Wed, 4 Mar 2015 17:38:39 -0500
> Dan Anderson <dan.w.anderson at gmail.com> wrote:
> 
> > Sorry. Should have included the diff:
> > 
> > --- nxrancid.orig       2014-09-24 10:02:46.017969251 -0400
> > +++ nxrancid    2014-09-24 10:03:06.039305060 -0400
> > @@ -660,7 +660,7 @@
> >         next if (/^(\s*|\s*$cmd\s*)$/);
> >         return(1) if /Line has invalid autocommand /;
> >         return(1) if /(Invalid input detected|Type help or )/;
> > -       return(-1) if (/\% Invalid command at /);
> > +       return(1) if (/\% Invalid command at /);
> >         return(-1) if (/\% Permission denied/);
> >         return(-1) if (/command authorization failed/i);
> 
> 
> +1 to this
> 
> I recall now doing this for the Nexuses I had back in the day. Solved
> many problems just like for John.
> 
> I never could understand why Invalid Command would be a fatal error -
> if the device can't do it, the script should just move past it and deal
> with the output it *can* handle.
> 
> Alan
> 
> -- 
> alan.mckinnon at gmail.com
> 
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo/rancid-discuss
> 

.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
Jethro R Binks, Network Manager,
Information Services Directorate, University Of Strathclyde, Glasgow, UK

The University of Strathclyde is a charitable body, registered in
Scotland, number SC015263.


More information about the Rancid-discuss mailing list