summaryrefslogtreecommitdiffstats
path: root/bin/clogin.in
diff options
context:
space:
mode:
authorTore Anderson <tore@linpro.no>2007-05-22 16:30:16 +0200
committerJeffrey C. Ollie <jeff@ocjtech.us>2007-05-22 11:19:12 -0500
commit722fb7049d406174d3f4afc963059a2eb71b47f8 (patch)
tree14ebcc1616e7c4d64b28b74a18af4360ec67e98a /bin/clogin.in
parent1a7c45398738cdb4eaafdc9e0962272f19d54816 (diff)
downloadrancid-722fb7049d406174d3f4afc963059a2eb71b47f8.tar.gz
rancid-722fb7049d406174d3f4afc963059a2eb71b47f8.tar.xz
rancid-722fb7049d406174d3f4afc963059a2eb71b47f8.zip
Fixing Extreme support
Hi. I finally got around to fix RANCID so it worked flawlessly with my Extreme devices (I've got switches running both ExtremeWare and XOS): * Identify XOS as a separate platform, this is done by looking for a period before the command number instead of a colon. Fix the prompt match regex in xrancid to recognise both cases. * Always "disable clipaging [session]" to avoid pagination, which earlier caused me to lose a configuration line every 24 or so lines for XOS. Remove comments suggesting such commands isn't available. * XOS doesn't have a marker for the end of the configuration file, so use a prompt match to look for the end too. Also make it so that invalid commands are detected, thus preventing an error message to be mistaken for the complete configuration. * Work around a strange bug in XOS where once in a while the line containing the SSH key will only contain the last seven hundred or so octets (causing spurious diffs to be mailed all the time). If we see a line containing only hex octets, assume we hit the bug and replace it like we would the complete line. * Fix the while loop that's supposed to swallow the SSL privkey for ExtremeWare devices, which earlier caused the next valid configuration line following the key to be swallowed also. * Remove special-casing of the quit/exit command for Extreme products, use "quit" always. This fixes all the bugs I experienced using RANCID with Extreme devices running XOS 11.3.3.7 and EW 7.5e.2.6 / 7.5e.3.8. Hope it's useful to others and that it can be applied to the next alpha release. Regards -- Tore Anderson
Diffstat (limited to 'bin/clogin.in')
-rw-r--r--bin/clogin.in65
1 files changed, 34 insertions, 31 deletions
diff --git a/bin/clogin.in b/bin/clogin.in
index 81c654e..725bca8 100644
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -572,28 +572,28 @@ proc run_commands { prompt command } {
# If the prompt is (enable), then we are on a switch and the
# command is "set length 0"; otherwise its "term length 0".
- # skip if its an extreme (since the pager can not be disabled on a
- # per-vty basis).
- if { [ string compare "extreme" "$platform" ] } {
- if [ regexp -- ".*> .*enable" "$prompt" ] {
- send "set length 0\r"
- # This is ugly, but reduces code duplication, allowing the
- # subsequent expects to handle everything as normal.
- set command "set logging session disable;$command"
- } else {
- send "term length 0\r"
- }
- # escape any parens in the prompt, such as "(enable)"
- regsub -all {[)(]} $prompt {\\&} reprompt
- # match cisco config mode prompts too, such as router(config-if)#,
- # but catalyst does not change in this fashion.
- regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
- expect {
- -re $reprompt {}
- -re "\[\n\r]+" { exp_continue }
- }
+ # ExtremeWare uses "disable clipaging session", XOS
+ # "disable clipaging".
+ if [ regexp -- ".*> .*enable" "$prompt" ] {
+ send "set length 0\r"
+ # This is ugly, but reduces code duplication, allowing the
+ # subsequent expects to handle everything as normal.
+ set command "set logging session disable;$command"
+ } elseif { ! [ string compare "extreme" "$platform" ] } {
+ send "disable clipaging session\r"
+ } elseif { ! [ string compare "extremexos" "$platform" ] } {
+ send "disable clipaging\r"
} else {
- regsub -all "\[)(]" $prompt {\\&} reprompt
+ send "term length 0\r"
+ }
+ # escape any parens in the prompt, such as "(enable)"
+ regsub -all {[)(]} $prompt {\\&} reprompt
+ # match cisco config mode prompts too, such as router(config-if)#,
+ # but catalyst does not change in this fashion.
+ regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
+ expect {
+ -re $reprompt {}
+ -re "\[\n\r]+" { exp_continue }
}
# this is the only way i see to get rid of more prompts in o/p..grrrrr
@@ -603,8 +603,7 @@ proc run_commands { prompt command } {
set commands [split $command \;]
set num_commands [llength $commands]
# the pager can not be turned off on the PIX, so we have to look
- # for the "More" prompt. the extreme is equally obnoxious, with a
- # global switch in the config.
+ # for the "More" prompt.
for {set i 0} {$i < $num_commands} { incr i} {
send "[subst -nocommands [lindex $commands $i]]\r"
expect {
@@ -637,8 +636,7 @@ proc run_commands { prompt command } {
}
} else {
# the pager can not be turned off on the PIX, so we have to look
- # for the "More" prompt. the extreme is equally obnoxious, with a
- # global switch in the config.
+ # for the "More" prompt.
send "[subst -nocommands $command]\r"
expect {
-re "\b+" { exp_continue }
@@ -670,11 +668,8 @@ proc run_commands { prompt command } {
}
log_user 1
- if { [ string compare "extreme" "$platform" ] } {
- send -h "exit\r"
- } else {
- send -h "quit\r"
- }
+ send -h "quit\r"
+
expect {
-re "^\[^\n\r *]*$reprompt" {
# the Cisco CE and Jnx ERX
@@ -837,7 +832,7 @@ foreach router [lrange $argv $i end] {
send "\r"
expect {
-re "\[\r\n]+" { exp_continue; }
- -re "^(.+\[:.])1 ($prompt)" { # stoopid extreme cmd-line numbers and
+ -re "^(.+:)1 ($prompt)" { # stoopid extreme cmd-line numbers and
# prompt based on state of config changes,
# which may have an * at the beginning.
set junk $expect_out(1,string)
@@ -845,6 +840,14 @@ foreach router [lrange $argv $i end] {
set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)";
set platform "extreme"
}
+ -re "^(.+\.)1 ($prompt)" { # stoopid extreme cmd-line numbers and
+ # prompt based on state of config changes,
+ # which may have an * at the beginning.
+ set junk $expect_out(1,string)
+ regsub -all "^\\\* " $expect_out(1,string) {} junk
+ set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)";
+ set platform "extremexos"
+ }
-re "^.+$prompt" { set junk $expect_out(0,string);
regsub -all "\[\]\[]" $junk {\\&} prompt;
}