Discussion:
[rancid] HP procurve Menu logon
Marc Boisis-Delavaud
2013-02-18 13:11:29 UTC
Permalink
Hello,
For different reason I 've to use "Menu" logon on my HP procure switch. With my test hlogin only works with "CLI" logon. Is there any fix or patch to make "Menu" logon working with rancid ?
Thanks
Marc Boisis-Delavaud
2013-02-19 07:12:37 UTC
Permalink
It look like this :

sw28cri 19-Feb-2013 8:11:21
===========================- TELNET - MANAGER MODE -============================
Main Menu

1. Status and Counters...
2. Switch Configuration...
3. Console Passwords...
4. Event Log
5. Command Line (CLI)
6. Reboot Switch
7. Download OS
8. Run Setup
9. Stacking...
0. Logout







Provides the menu to display configuration, status, and counters.
To select menu item, press item number, or highlight item and press <Enter>.
Post by Marc Boisis-Delavaud
Hello,
For different reason I 've to use "Menu" logon on my HP procure switch. With my test hlogin only works with "CLI" logon. Is there any fix or patch to make "Menu" logon working with rancid ?
what does "menu logon" look like?
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
***@univ-lr.fr | 05 46 45 82 14
Marc Boisis-Delavaud
2013-02-20 14:00:12 UTC
Permalink
I 've made this patch which is working :

#diff hlogin hloginULR
398a399
475a477,480
-re ".*=============================================- TELNET - MANAGER MODE" {
send "5"
exp_continue
}
thanks
Post by Marc Boisis-Delavaud
sw28cri 19-Feb-2013 8:11:21
===========================- TELNET - MANAGER MODE -============================
Main Menu
1. Status and Counters...
2. Switch Configuration...
3. Console Passwords...
4. Event Log
5. Command Line (CLI)
6. Reboot Switch
7. Download OS
8. Run Setup
9. Stacking...
0. Logout
Provides the menu to display configuration, status, and counters.
To select menu item, press item number, or highlight item and press <Enter>.
add a match in the login function of hlogin to find 'and press <Enter>.' and
send '5\r'.
Post by Marc Boisis-Delavaud
Post by Marc Boisis-Delavaud
Hello,
For different reason I 've to use "Menu" logon on my HP procure switch. With my test hlogin only works with "CLI" logon. Is there any fix or patch to make "Menu" logon working with rancid ?
what does "menu logon" look like?
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
***@univ-lr.fr | 05 46 45 82 14
heasley
2013-02-20 17:43:18 UTC
Permalink
Post by Marc Boisis-Delavaud
#diff hlogin hloginULR
398a399
475a477,480
-re ".*=============================================- TELNET - MANAGER MODE" {
send "5"
exp_continue
}
its better, imo, to match all or at least the majority of input before
sending. that way, your output and its response, is not mixed in with
the input. its cleaner, easier, and more reliable - again, imo.

btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
Post by Marc Boisis-Delavaud
thanks
Post by Marc Boisis-Delavaud
sw28cri 19-Feb-2013 8:11:21
===========================- TELNET - MANAGER MODE -============================
Main Menu
1. Status and Counters...
2. Switch Configuration...
3. Console Passwords...
4. Event Log
5. Command Line (CLI)
6. Reboot Switch
7. Download OS
8. Run Setup
9. Stacking...
0. Logout
Provides the menu to display configuration, status, and counters.
To select menu item, press item number, or highlight item and press <Enter>.
add a match in the login function of hlogin to find 'and press <Enter>.' and
send '5\r'.
Post by Marc Boisis-Delavaud
Post by Marc Boisis-Delavaud
Hello,
For different reason I 've to use "Menu" logon on my HP procure switch. With my test hlogin only works with "CLI" logon. Is there any fix or patch to make "Menu" logon working with rancid ?
what does "menu logon" look like?
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Alex DEKKER
2013-02-20 21:19:39 UTC
Permalink
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with
'menu'.
Per-Olof Olsson
2013-02-21 07:40:23 UTC
Permalink
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with 'menu'.
heasley
2013-03-01 23:19:45 UTC
Permalink
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with 'menu'.
Per-Olof Olsson
2013-03-04 16:00:37 UTC
Permalink
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with 'menu'.
Per-Olof Olsson
2013-03-21 12:03:42 UTC
Permalink
Not just a small fix make menu login to work.
Found some more that I think needs to be fixed.

Now tested on some HP's
HP2524, H41xx, HP2510, HP2610, HP2620, HP2824, HP2910 och HP2920.
Telnet and ssh login to operator and manager level.
Ssh key login to manager level.

Also tested just hlogin on some Cisco's.

Look like have this to work.

How will this new hlogin work for agmrancid and srancid that make
use of hlogin?

Files from rancid 2.8.3.

hrancid:
- Fix to prevent hrancid from find/parse "Logout"-text from menu.
Looks like code is move to WriteTerm and not used any more.

- Also include ShowReloadAt just to get a proper diff output.

===================================================================
diff -c hrancid.in_ORG hrancid.in_NEW
*** hrancid.in_ORG 2012-08-29 13:39:33.060145292 +0200
--- hrancid.in_NEW 2013-03-18 20:18:31.535617594 +0100
***************
*** 168,173 ****
--- 168,192 ----
&ipaddrval($a) <=> &ipaddrval($b);
}

+ # This routine parses "show reload at"
+ sub ShowReloadAt {
+ print STDERR " In ShowReloadAt: $_" if ($debug);
+
+ while (<INPUT>) {
+ tr/\015//d;
+ last if (/^$prompt/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
+ return(-1) if (/command authorization failed/i);
+ return(1) if /^(Invalid|Ambiguous) input:/i;
+
+ next if (/ \(in /);
+ next if (/ reload is not scheduled/);
+
+ ProcessHistory("COMMENTS","keysort","I0",";$_");
+ }
+ return(0);
+ }
+
# This routine parses "show config files"
sub ShowConfigFiles {
print STDERR " In ShowConfigFiles: $_" if ($debug);
***************
*** 533,538 ****
--- 552,558 ----
{'show module' => 'ShowModule'},
{'show stack' => 'ShowStack'},
{'show tech transceivers' => 'ShowTechTransceivers'},
+ {'show reload at' => 'ShowReloadAt'},
{'show config files' => 'ShowConfigFiles'},
{'show config status' => 'ShowConfigStatus'},
{'write term' => 'WriteTerm'}
***************
*** 602,614 ****
ProcessHistory("COMMENTS","keysort","F0",";\n"); # showstack
ProcessHistory("COMMENTS","keysort","G0",";\n"); # showtechtransceivers
ProcessHistory("COMMENTS","keysort","H0",";\n"); # showconfigfiles
! ProcessHistory("COMMENTS","keysort","I0",";\n");
TOP: while(<INPUT>) {
tr/\015//d;
! if (/$prompt\s*(exit|logout)\s*$/i) {
! $clean_run=1;
! last;
! }
if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
--- 622,641 ----
ProcessHistory("COMMENTS","keysort","F0",";\n"); # showstack
ProcessHistory("COMMENTS","keysort","G0",";\n"); # showtechtransceivers
ProcessHistory("COMMENTS","keysort","H0",";\n"); # showconfigfiles
! ProcessHistory("COMMENTS","keysort","I0",";\n"); # showreloadat
! ProcessHistory("COMMENTS","keysort","J0",";\n");
!
TOP: while(<INPUT>) {
tr/\015//d;
!
! # Moved to WriteTerm and not removed from here!!!
! ## "Logout" text in menu! Don't look for exit or logout before prompt is defined
! ## if (/$prompt\s*(exit|logout)\s*$/i) {
! # if (defined($prompt) && /$prompt\s*(exit|logout)\s*$/i) {
! # print STDERR ("EXIT:$_") if ($debug);
! # $clean_run=1;
! # last;
! # }
if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);

=============================================



hlogin:

- Select "Exit to cli" if menu is default for login.
Include answer to "save config" prompter before menu is started.

- Handle some more error text to speed up exit on error.

- Remove/replace code for two inner expect loops to
just have a single expect loop for login.
Don't like to duplicate expect code into inner loops.

- Include fix for "prompt" characters in banner text.
Will handle banner text except if it the match "/#\s*($cmds_regexp)\s*$/" in hrancid

- Speed up logout. Don't need to use human wait/type speed.

=============================================
diff -c hlogin.in_20130318 hlogin.in_NEW
*** hlogin.in_20130318 2013-02-27 07:56:51.332898135 +0100
--- hlogin.in_NEW 2013-03-18 20:16:02.286363285 +0100
***************
*** 412,417 ****
--- 412,427 ----
send "\r"
exp_continue
}
+ "Do you want to save current configuration" {
+ send "n"
+ exp_continue
+ }
+ # Menu output "<Enter>" grab all in menu to not match prompter!
+ -re "(\[0-9])\\. Command Line \\(CLI\\).*" {
+ set menu_exit "$expect_out(1,string)"
+ send "$menu_exit"
+ exp_continue
+ }
-re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" {
catch {close}; catch {wait};
if !$progs {
***************
*** 444,450 ****
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts
file accordingly.\n"
return 1
}
! eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-nocase "unknown host\r" {
catch {close}; catch {wait};
send_user "\nError: Unknown host\n"; wait; return 1
--- 454,483 ----
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts
file accordingly.\n"
return 1
}
! "Could not resolve hostname" {
! send_user "\nError: Could not resolve hostname $router\n";
! catch {close}; catch {wait};
! return 1
! }
! eof {
! send_user "\nError: Couldn't login\n";
! wait; return 1
! }
! "Permission denied" {
! send_user "\nError: Permission denied. Check your access to $router\n";
! catch {close}; catch {wait};
! return 1
! }
! "Invalid password" {
! send_user "\nError: Invalid password. Check your passwd for $router\n";
! catch {close}; catch {wait};
! return 1
! }
! "Login invalid" {
! send_user "\nError: Invalid login\n";
! catch {close}; catch {wait};
! return 1
! }
-nocase "unknown host\r" {
catch {close}; catch {wait};
send_user "\nError: Unknown host\n"; wait; return 1
***************
*** 455,473 ****
send -- "$passphrase\r"
exp_continue
}
! -re "$u_prompt" { send -- "$user\r"
! expect {
! eof { send_user "\nError: Couldn't login\n"; wait;
return 1 }
! "Login invalid" { send_user "\nError: Invalid login\n";
! catch {close}; catch {wait};
! return 1 }
! -re "$p_prompt" { send -- "$userpswd\r" }
! "$prompt" { set in_proc 0; return 0 }
! "Press any key to continue" {
! send " "
! exp_continue
! }
! }
exp_continue
}
-re "$p_prompt" {
--- 488,498 ----
send -- "$passphrase\r"
exp_continue
}
! -re "\[#>]+.*\[\n\r]+" {
! exp_continue
! }
! -re "$u_prompt" {
! send -- "$user\r"
exp_continue
}
-re "$p_prompt" {
***************
*** 476,502 ****
} else {
send -- "$passwd\r"
}
- expect {
- eof { send_user "\nError: Couldn't login\n";
- wait;
- return 1
- }
- "Press any key to continue" {
- send " ";
- exp_continue
- }
- -re "$e_prompt" { send -- "$enapasswd\r" }
- "$prompt" { set in_proc 0;
- return 0
- }
- }
exp_continue
}
! "$prompt" { break; }
! denied { send_user "\nError: Check your passwd for $router\n"
! catch {close}; catch {wait}; return 1
! }
! "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}

--- 501,519 ----
} else {
send -- "$passwd\r"
}
exp_continue
}
! "$prompt" {
! break
! }
! denied {
! send_user "\nError: Check your passwd for $router\n"
! catch {close}; catch {wait}; return 1
! }
! "% Bad passwords" {
! send_user "\nError: Check your passwd for $router\n"
! return 1
! }
}
}

***************
*** 583,589 ****
}
}
log_user 1
! send -h "logout\r"
expect {
"Do you want to save current configuration" {
if {$do_saveconfig} {
--- 600,606 ----
}
}
log_user 1
! send "logout\r"
expect {
"Do you want to save current configuration" {
if {$do_saveconfig} {

=============================================
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with 'menu'.
Marc Boisis-Delavaud
2013-04-09 12:17:44 UTC
Permalink
Hello

Are these patch are integrated into rancid github repository ?
Post by Per-Olof Olsson
Not just a small fix make menu login to work.
Found some more that I think needs to be fixed.
Now tested on some HP's
HP2524, H41xx, HP2510, HP2610, HP2620, HP2824, HP2910 och HP2920.
Telnet and ssh login to operator and manager level.
Ssh key login to manager level.
Also tested just hlogin on some Cisco's.
Look like have this to work.
How will this new hlogin work for agmrancid and srancid that make
use of hlogin?
Files from rancid 2.8.3.
- Fix to prevent hrancid from find/parse "Logout"-text from menu.
Looks like code is move to WriteTerm and not used any more.
- Also include ShowReloadAt just to get a proper diff output.
===================================================================
diff -c hrancid.in_ORG hrancid.in_NEW
*** hrancid.in_ORG 2012-08-29 13:39:33.060145292 +0200
--- hrancid.in_NEW 2013-03-18 20:18:31.535617594 +0100
***************
*** 168,173 ****
--- 168,192 ----
&ipaddrval($a) <=> &ipaddrval($b);
}
+ # This routine parses "show reload at"
+ sub ShowReloadAt {
+ print STDERR " In ShowReloadAt: $_" if ($debug);
+
+ while (<INPUT>) {
+ tr/\015//d;
+ last if (/^$prompt/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
+ return(-1) if (/command authorization failed/i);
+ return(1) if /^(Invalid|Ambiguous) input:/i;
+
+ next if (/ \(in /);
+ next if (/ reload is not scheduled/);
+
+ ProcessHistory("COMMENTS","keysort","I0",";$_");
+ }
+ return(0);
+ }
+
# This routine parses "show config files"
sub ShowConfigFiles {
print STDERR " In ShowConfigFiles: $_" if ($debug);
***************
*** 533,538 ****
--- 552,558 ----
{'show module' => 'ShowModule'},
{'show stack' => 'ShowStack'},
{'show tech transceivers' => 'ShowTechTransceivers'},
+ {'show reload at' => 'ShowReloadAt'},
{'show config files' => 'ShowConfigFiles'},
{'show config status' => 'ShowConfigStatus'},
{'write term' => 'WriteTerm'}
***************
*** 602,614 ****
ProcessHistory("COMMENTS","keysort","F0",";\n"); # showstack
ProcessHistory("COMMENTS","keysort","G0",";\n"); # showtechtransceivers
ProcessHistory("COMMENTS","keysort","H0",";\n"); # showconfigfiles
! ProcessHistory("COMMENTS","keysort","I0",";\n");
TOP: while(<INPUT>) {
tr/\015//d;
! if (/$prompt\s*(exit|logout)\s*$/i) {
! $clean_run=1;
! last;
! }
if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
--- 622,641 ----
ProcessHistory("COMMENTS","keysort","F0",";\n"); # showstack
ProcessHistory("COMMENTS","keysort","G0",";\n"); # showtechtransceivers
ProcessHistory("COMMENTS","keysort","H0",";\n"); # showconfigfiles
! ProcessHistory("COMMENTS","keysort","I0",";\n"); # showreloadat
! ProcessHistory("COMMENTS","keysort","J0",";\n");
!
TOP: while(<INPUT>) {
tr/\015//d;
!
! # Moved to WriteTerm and not removed from here!!!
! ## "Logout" text in menu! Don't look for exit or logout before prompt is defined
! ## if (/$prompt\s*(exit|logout)\s*$/i) {
! # if (defined($prompt) && /$prompt\s*(exit|logout)\s*$/i) {
! # print STDERR ("EXIT:$_") if ($debug);
! # $clean_run=1;
! # last;
! # }
if (/^Error:/) {
print STDOUT ("$host clogin error: $_");
print STDERR ("$host clogin error: $_") if ($debug);
=============================================
- Select "Exit to cli" if menu is default for login.
Include answer to "save config" prompter before menu is started.
- Handle some more error text to speed up exit on error.
- Remove/replace code for two inner expect loops to
just have a single expect loop for login.
Don't like to duplicate expect code into inner loops.
- Include fix for "prompt" characters in banner text.
Will handle banner text except if it the match "/#\s*($cmds_regexp)\s*$/" in hrancid
- Speed up logout. Don't need to use human wait/type speed.
=============================================
diff -c hlogin.in_20130318 hlogin.in_NEW
*** hlogin.in_20130318 2013-02-27 07:56:51.332898135 +0100
--- hlogin.in_NEW 2013-03-18 20:16:02.286363285 +0100
***************
*** 412,417 ****
--- 412,427 ----
send "\r"
exp_continue
}
+ "Do you want to save current configuration" {
+ send "n"
+ exp_continue
+ }
+ # Menu output "<Enter>" grab all in menu to not match prompter!
+ -re "(\[0-9])\\. Command Line \\(CLI\\).*" {
+ set menu_exit "$expect_out(1,string)"
+ send "$menu_exit"
+ exp_continue
+ }
-re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" {
catch {close}; catch {wait};
if !$progs {
***************
*** 444,450 ****
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts
file accordingly.\n"
return 1
}
! eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
-nocase "unknown host\r" {
catch {close}; catch {wait};
send_user "\nError: Unknown host\n"; wait; return 1
--- 454,483 ----
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts
file accordingly.\n"
return 1
}
! "Could not resolve hostname" {
! send_user "\nError: Could not resolve hostname $router\n";
! catch {close}; catch {wait};
! return 1
! }
! eof {
! send_user "\nError: Couldn't login\n";
! wait; return 1
! }
! "Permission denied" {
! send_user "\nError: Permission denied. Check your access to $router\n";
! catch {close}; catch {wait};
! return 1
! }
! "Invalid password" {
! send_user "\nError: Invalid password. Check your passwd for $router\n";
! catch {close}; catch {wait};
! return 1
! }
! "Login invalid" {
! send_user "\nError: Invalid login\n";
! catch {close}; catch {wait};
! return 1
! }
-nocase "unknown host\r" {
catch {close}; catch {wait};
send_user "\nError: Unknown host\n"; wait; return 1
***************
*** 455,473 ****
send -- "$passphrase\r"
exp_continue
}
! -re "$u_prompt" { send -- "$user\r"
! expect {
! eof { send_user "\nError: Couldn't login\n"; wait;
return 1 }
! "Login invalid" { send_user "\nError: Invalid login\n";
! catch {close}; catch {wait};
! return 1 }
! -re "$p_prompt" { send -- "$userpswd\r" }
! "$prompt" { set in_proc 0; return 0 }
! "Press any key to continue" {
! send " "
! exp_continue
! }
! }
exp_continue
}
-re "$p_prompt" {
--- 488,498 ----
send -- "$passphrase\r"
exp_continue
}
! -re "\[#>]+.*\[\n\r]+" {
! exp_continue
! }
! -re "$u_prompt" {
! send -- "$user\r"
exp_continue
}
-re "$p_prompt" {
***************
*** 476,502 ****
} else {
send -- "$passwd\r"
}
- expect {
- eof { send_user "\nError: Couldn't login\n";
- wait;
- return 1
- }
- "Press any key to continue" {
- send " ";
- exp_continue
- }
- -re "$e_prompt" { send -- "$enapasswd\r" }
- "$prompt" { set in_proc 0;
- return 0
- }
- }
exp_continue
}
! "$prompt" { break; }
! denied { send_user "\nError: Check your passwd for $router\n"
! catch {close}; catch {wait}; return 1
! }
! "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
}
}
--- 501,519 ----
} else {
send -- "$passwd\r"
}
exp_continue
}
! "$prompt" {
! break
! }
! denied {
! send_user "\nError: Check your passwd for $router\n"
! catch {close}; catch {wait}; return 1
! }
! "% Bad passwords" {
! send_user "\nError: Check your passwd for $router\n"
! return 1
! }
}
}
***************
*** 583,589 ****
}
}
log_user 1
! send -h "logout\r"
expect {
"Do you want to save current configuration" {
if {$do_saveconfig} {
--- 600,606 ----
}
}
log_user 1
! send "logout\r"
expect {
"Do you want to save current configuration" {
if {$do_saveconfig} {
=============================================
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with 'menu'. From what Marc
is saying, it sounds like there is a way to make it go straight into the menu on login for
a given username.
alexd
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Only setting I found for this is in "8. Run Setup" menu
where you select "Logon Default" to "CLI" or "Menu"
Would you propose a patch for this, since you can test it?
Yes but it will take some time to have it to work and is fully tested.
telnet/ssh login to manager and/or operator level
ssh key-login
and some switch types.
"5" only works if you do direct login to manager level.
Login to operator level needs "3" for "CLI exit".
And one more thing.
When you start menu mode and not saved config
"Do you want to save current configuration"-prompt
shows up before menu is started, even at login.
...
Have part of it working but not all.
/Peo
----------------------------------------------------------
Chalmers tekniska högskola IT-service
Hörsalsvägen 5 412 96 Göteborg
Tel: 031/772 6738 Fax: 031/772 8660
----------------------------------------------------------
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
/Peo
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
***@univ-lr.fr | 05 46 45 82 14

Alex DEKKER
2013-02-20 20:59:41 UTC
Permalink
Post by heasley
btw, is this menu a standard thing with procurves? I've never seen it,
but the one that i have is a lower-end model.
It's not the default on current Procurves, you can access it with
'menu'.
Loading...