[rancid] adding a "new" type for axos

Jon Lewis jlewis at lewis.org
Mon Dec 11 18:52:41 UTC 2023


On Mon, 11 Dec 2023, heasley wrote:

> right, so when it returns, the 'exit' line should be re-evaluated in the
> top loop and clean_run will be set.  There is some nuance, but all the
> other filter functions operate in the same manner.
>
>     94 TOP: while(<$INPUT>) {
> 	...
>    102         while (/[>#]\s*($cmds_regexp)\s*$/) {
>    121             $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd);
>    122             delete($commands{$cmd});
> 	...
>    127         }
>    128         if (/[>#]\s?exit$/) {  <<<<<<<<<<<<<<<<
>    129             $clean_run = 1;
>    130             last;
>    131         }
>    132     }
>    133 }

That's interesting.  The rancid 3.13 I have from the Ubuntu rancid 3.13-1 
package has that line 128 if statement up above the while loop that starts 
at line 102.  So, this was fixed a couple of years ago.

https://github.com/haussli/rancid/commit/f9c6dc261803a1340286d57ef4b16ac8900f7053

Now that I look, I see the Ubuntu (Debian?) rancid 3.13 package is based 
on at least a 3 year old snapshot of rancid.  Is there any point in using 
such a package?  It seems like we'd be far better off just using the 
latest from github, doing a configure and make install?

Backporting that change does resolve the WriteTerm function not setting 
$clean_run issue.  I still need this little tweak or something similar to 
deal with the no obvious end of config issue.

@@ -2787,7 +2804,7 @@
      # The ContentEngine lacks a definitive "end of config" marker.  If we
      # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines
      # of write term output, we can be reasonably sure that we have the config.
-    if (($type eq "CE" || $type eq "SAN" || $type eq "NXOS") && $linecnt > 5) {
+    if (($type eq "CE" || $type eq "SAN" || $type eq "NXOS" || $devtype eq "axos") && $linecnt > 5) {
         $found_end = 1;
         return(0);
      }

One solution I'd tested was

TOP:
         tr/\015//d;
+       if (/^$prompt\s?exit/ && $devtype eq "axos" && $linecnt > 5) {
+         $found_end = 1;
+         $clean_run = 1;
+         return(0);

----------------------------------------------------------------------
  Jon Lewis, MCP :)              |  I route
  Blue Stream Fiber, Sr. Neteng  |  therefore you are
_________ http://www.lewis.org/~jlewis/pgp for PGP public key_________



More information about the Rancid-discuss mailing list