Mailing List Archive

adding a "new" type for axos
I'm trying to get rancid to backup Calix AXOS E7-2's. I've run into a
snag with the end of run being properly recognized.

I'm running rancid-3.13-1 on Ubuntu 22.04.03. I decided to try re-using
the ios module for axos. I added this to rancid.types.conf:

axos;script;rancid -t axos
axos;login;clogin
axos;module;ios
axos;inloop;ios::inloop
axos;command;ios::ShowVersion;show version
axos;command;ios::WriteTerm;show running-config | nomore

Since the axos "show running-config" output has no "end tag" to it; the
output simply ends and you're returned to a prompt, I made the change
below so that $found_end will be set to 1 for axos device types if some
config was printed. I've verified this works and sets $found_end = 1.

--- ios.pm.orig 2020-10-15 11:26:17.000000000 -0400
+++ ios.pm 2023-12-09 22:21:50.408683973 -0500
@@ -2787,7 +2794,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);
}

The problem I think I've run into is, the final exit isn't being
recognized and $clean_run doesn't get set to 1, resulting in "End of run
not found".

Near the top of inloop in ios.pm, there's this bit of code:

if (/[>#]\s?exit$/) {
$clean_run = 1;
last;
}

which seems like it should be matching, but is not. The last few lines of
the raw file left by running rancid -d -t axos <some-device> are:

no shutdown
!
some-device#exit
Shared connection to X.X.X.X closed.

In the raw file, exit is followed CRLF.

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

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss
Re: adding a "new" type for axos [ In reply to ]
On Sat, 9 Dec 2023, Jon Lewis wrote:

> --- ios.pm.orig 2020-10-15 11:26:17.000000000 -0400
> +++ ios.pm 2023-12-09 22:21:50.408683973 -0500
> @@ -2787,7 +2794,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);
> }

I did some more debugging tonight, and see the problem now. I'm kind of
curious out the CE/SAN/NXOS types get around this...but the problem is,
with no clear end of config marker to the show running-config, the
WriteTerm function doesn't stop processing input until it's read all of
it. In WriteTerm, when

last if (/^$prompt/);

matches, the line matched has the exit command on it. So when
processing is handed back to inloop, there's nothing left for it to
process other than the "Shared connection to ... closed." message from
ssh.

Would it be an appropriate workaround for this to also set $clean_run = 1
in the above if statement at the end of WriteTerm...or make a new if
statment just for $devtype axos that sets both $found_end and $clean_run?

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

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss
Re: adding a "new" type for axos [ In reply to ]
Sun, Dec 10, 2023 at 11:18:53PM -0500, Jon Lewis:
> On Sat, 9 Dec 2023, Jon Lewis wrote:
>
> > --- ios.pm.orig 2020-10-15 11:26:17.000000000 -0400
> > +++ ios.pm 2023-12-09 22:21:50.408683973 -0500
> > @@ -2787,7 +2794,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);
> > }
>
> I did some more debugging tonight, and see the problem now. I'm kind of
> curious out the CE/SAN/NXOS types get around this...but the problem is, with
> no clear end of config marker to the show running-config, the WriteTerm
> function doesn't stop processing input until it's read all of it. In
> WriteTerm, when
>
> last if (/^$prompt/);
>
> matches, the line matched has the exit command on it. So when processing is
> handed back to inloop, there's nothing left for it to process other than the
> "Shared connection to ... closed." message from ssh.

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 }

Are you certain that the exit prompt is exactly:
some-device#exit
there are no spaces or other garbage on the line?

> Would it be an appropriate workaround for this to also set $clean_run = 1 in
> the above if statement at the end of WriteTerm...or make a new if statment
> just for $devtype axos that sets both $found_end and $clean_run?

it should not be necessary.

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss
Re: adding a "new" type for axos [ In reply to ]
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_________

_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss