[rancid] Trying to backup InfiNet Devices

Daniel Thomas dtonline at gmail.com
Thu Jan 6 22:23:44 UTC 2022


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”



[..



    # 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20220106/06d2ca75/attachment.htm>


More information about the Rancid-discuss mailing list