[rancid] Trying to backup InfiNet Devices
Daniel Thomas
dtonline at gmail.com
Fri Jan 7 11:31:25 UTC 2022
Thank you very much for your swift response. I will have a look at clogin
hlogin (specifically the hpuifilter) to see what I can learn from them.
I will also clean up the "$prompt" so that it accepts both versions of the
prompt.
It doesn't appear to be a cmd-line counter - I know that one aspect of the
behaviour is that the <Dollar Sign><Number> part of the hostname relates to
how many simultaneous SSH sessions there are. However I cannot understand
how on some occasions it "reports back" as not including the <Dollar
Sign><Number> suffix. I will play with the debug again and see what I get.
I'm reticent to mention this bit as I think it relates to our installation
of RANCID and the behaviour of the *nix system on which it lives . . but
when I have been executing the "rancid -d -t <type>" I get (what I think
is) non standard behaviour.
If I execute "./rancid -d -t <type>" I get the following behaviour:
./rancid -d -t infinet 10.126.254.208
loadtype: device type infinet
loadtype: found device type infinet at
/usr/local/rancid/etc/rancid.types.conf:119
device script (rancid) does not appear to be me (./rancid): exec(rancid -t
infinet -d 10.126.254.208)
Can't exec "rancid": No such file or directory at ./rancid line 104.
exec(rancid) failed: No such file or directory
And so no .raw nor .new is generated.
If I execute
perl rancid -d -t infinet 10.126.254.208
loadtype: device type infinet
loadtype: found device type infinet at
/usr/local/rancid/etc/rancid.types.conf:119
executing infilogin -t 90 -c"system version;config show" 10.126.254.208
10.126.254.208: missed cmd(s): all commands
10.126.254.208: End of run not found
10.126.254.208: clean_run is false
10.126.254.208: found_end is false
!
Then raw and new are generated but the .raw then contains:
sh: infilogin: command not found
Which I understand to be the shell expressing it does not recognise that
command. However as mentioned previously everything seems to run fine when
“rancid-run” is called.
I mention this as it hampers me a bit on the more granular troubleshooting
that is available.
Thanks again
DeeTee
On Thu, 6 Jan 2022 at 22:55, heasley <heas at shrubbery.net> wrote:
> Thu, Jan 06, 2022 at 10:23:44PM +0000, Daniel Thomas:
> > Hi
> >
> >
> >
> > I have been working on getting RANCID to collect configuration
> information
> > from some equipment that is made by InfiNet. So far I have been unable to
> > locate any similar work performed previously and so made a start on
> getting
> > RANCID to connect to the devices.
> >
> >
> >
> > Through trial and error I found that the “jlogin” login script was able
> to
> > connect to the device but would not allow interaction once connected. I
> > decided to use that script as a base for my work and so made a copy of it
> > and named that copy “infilogin” I found that the reason that issues were
> > being hit was that the match of the prompt string was being thrown off as
> > the InfiNet device changes it’s prompt, and that there were trailing
> > charaters what were causing issues.
> >
> > With regards the changing prompt I saw it take the two following forms:
> > basehostname>
> > basehostname$1>
> >
> > And the trailing characters I saw were:
> >
> > \r\u001b[16C\u001b[K\r\u001b[16C
> >
> > To work around this I created an “”altprompt” which took a substring of
> > “$prompt” and then did some greedy matching which then gave the following
> > in the “we are now logged in, figure out the full prompt”
>
> You might look at clogin; the EXOS also has a command line counter. Is it
> a cmd-line counter?
>
> And, look at hlogin, which uses hpuifilter to remove most of the screen
> manipulation escape codes. Sometimes a more rudimentary TERM type causes
> devices no use the escape codes; like 'network' or 'dumb'. there are at
> least 2 *.pm's that do this.
>
> I think that if you combine these two methods, it will be easier. copy
> clogin and modify for the prompt alternatives, add the hpuifilter changes
> from hlogin.
>
> if thats not attractive, debug the missed commands with rancid -d -t <type>
> looking for the command matches. I expect there will be none and the *.new
> file will be empty. Compare the prompt matchine in inloop() to whats in
> the *.raw file and look for escape codes in the prompts within the *.raw
> file.
>
> below, I would just alter $prompt to accept either version of the prompt.
> That will make it easier (more consistent with other scripts) for -x or
> -s.
>
> > [..
> >
> >
> >
> > # we are logged in, now figure out the full prompt
> >
> > send "\r"
> >
> > expect {
> >
> > -re "(\r\n|\n)" { exp_continue; }
> >
> > -re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);
> >
> > *regsub ">" $prompt ">" prompt;
> > *
> > <<<<
> >
> > }
> >
> > }
> >
> > # send $prompt
> >
> > set in_proc 0
> >
> > return 0
> >
> > }
> >
> >
> >
> > # Run commands given on the command line.
> >
> > proc run_commands { prompt command } {
> >
> > global do_interact in_proc
> >
> > set in_proc 1
> >
> >
> >
> > * set altprompt [string range $prompt 0 11] *
> > <<<<
> >
> > # handle escaped ;s in commands, and ;; and ^;
> >
> > regsub -all {([^\\]);} $command \\1\u0002; esccommand
> >
> > regsub -all {([^\\]);;} $esccommand \\1;\u0002; command
> >
> > regsub {^;} $command "\u0002;" esccommand
> >
> > regsub -all {[\\];} $esccommand ";" command
> >
> > regsub -all {\u0002;} $command "\u0002" esccommand
> >
> > set sep "\u0002"
> >
> > set commands [split $esccommand $sep]
> >
> > set num_commands [llength $commands]
> >
> > for {set i 0} {$i < $num_commands} { incr i} {
> >
> > send -- "[subst -nocommands [lindex $commands $i]]\r"
> >
> > expect {
> >
> > *-re "^\[^\n\r *]*$prompt.*" {}*
> > <<<<
> >
> > * -re "^$altprompt.*>.*" {} *
> > <<<<
> >
> > -re "^\[^\n\r]*$prompt." { exp_continue }
> >
> > -re "(\r\n|\n)" { exp_continue }
> >
> > * -re "\r-- more --\r" { send " "; exp_continue }
> > *
> > <<<<
> >
> > }
> >
> > }
> >
> >
> >
> >
> >
> > ..]
> >
> >
> >
> > I have marked my deviations from “jlogin” with four less than signs.
> >
> >
> >
> > With these bodges applied I can successfully get connected to a device,
> > execute commands and exit. I can also issue the “infilogin” with -c or -x
> > and the relevant commands will execute, and I see the output. I then
> went
> > and updated the “rancid.types.conf” with an entry as below:
> >
> >
> >
> > [..
> >
> > infinet;script;rancid -t infinet
> >
> > infinet;login;jlogin
> >
> > infinet;module;infinet
> >
> > infinet;inloop;infinet::inloop
> >
> > infinet;command;infinet::ShowVersion;system version
> >
> > infinet;command;infinet::ShowConfiguration;config show
> >
> > ..]
> >
> >
> >
> > I created an “infinet.pm” based on “mrv.pm”, made an addition to the
> > “router.db” and now I can see when “rancid-run” is called that the system
> > connects out 4 times to the InfiNet device (tcpdump helped here) but in
> the
> > log file for the run I keep seeing :
> >
> >
> >
> > 10.12.25.208 <http://10.126.254.208/>: missed cmd(s): all commands
> >
> > 10.12.25.208 <http://10.126.254.208/>: End of run not found
> >
> >
> >
> > >From what I have read it would seem that my issue lies with the “inloop”
> > within my “infinet.pm” file, but cannot get to grips with what needs to
> be
> > there, or if the “$prompt” hacks I made in “infilogin” are coming back to
> > bite me now. If anyone can point me in the right direction I will be very
> > grateful.
> >
> >
> >
> > Thank you for taking the time to read this and for supporting this great
> > tool. (By that I mean RANCID not that I am a tool . . but now I come to
> > mention it)
> >
> > DeeTee
>
> > _______________________________________________
> > Rancid-discuss mailing list
> > Rancid-discuss at www.shrubbery.net
> > https://www.shrubbery.net/mailman/listinfo/rancid-discuss
>
>
--
Regards
Daniel Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20220107/a66eee1e/attachment.htm>
More information about the Rancid-discuss
mailing list