Discussion:
[rancid] HP Procurve (hlogin): interaction in configure mode: possible?
Emmanuel Halbwachs
2008-01-07 18:25:49 UTC
Permalink
Hi Everybody,

I'm a newbie on this list.

I'm happily using rancid (2.3.1, the one in Debian stable etch) for
several monthes, but till now only for pushing/retrieving some info
with {c,h}login. I plan to use version control for config later.

My point:

I am trying to change some config parameters in ~50 HP Procurve with
some commands like this:

$ hlogin -v foo -e bar -c "conf t; foobar; wr mem" $switch

The output then hangs after the "conf t" command:

switch> enable
Password:
switch#
switch# no page
switch# conf t

-> hang :-(


When using hlogin without entering in configure mode, everything works
just fine.

I tried to massage the -c command with "\n" without any results.

I understand that dealing with the HP CLI seems to be a PIA (thus
hpuifilter), but is there a way to enter some commands in configure
mode?

TIA for any hint,
--
Emmanuel Halbwachs
Resp. Réseau/Sécurité Observatoire de Paris-Meudon
tel : (+33)1 45 07 75 54 5 Place Jules Janssen
fax : (+33)1 45 07 76 13 F 92195 MEUDON CEDEX
john heasley
2008-01-12 18:08:43 UTC
Permalink
Post by Emmanuel Halbwachs
Hi Everybody,
I'm a newbie on this list.
I'm happily using rancid (2.3.1, the one in Debian stable etch) for
several monthes, but till now only for pushing/retrieving some info
with {c,h}login. I plan to use version control for config later.
I am trying to change some config parameters in ~50 HP Procurve with
$ hlogin -v foo -e bar -c "conf t; foobar; wr mem" $switch
two things; 1) your string of commands would leave cli in configuration mode,
and hlogin would run "exit;exit" then leaving it at the un-enabled cli. you
need
-c "conf t; foo; exit"
2) it appears that hlogin has difficulty with the prompt changing. A change
was applied to clogin to make this work, but apparently not applied to hlogin.
you should be able to work-around it using the -x method.
Post by Emmanuel Halbwachs
switch> enable
switch#
switch# no page
switch# conf t
-> hang :-(
When using hlogin without entering in configure mode, everything works
just fine.
I tried to massage the -c command with "\n" without any results.
I understand that dealing with the HP CLI seems to be a PIA (thus
hpuifilter), but is there a way to enter some commands in configure
mode?
TIA for any hint,
--
Emmanuel Halbwachs
Resp. R?seau/S?curit? Observatoire de Paris-Meudon
tel : (+33)1 45 07 75 54 5 Place Jules Janssen
fax : (+33)1 45 07 76 13 F 92195 MEUDON CEDEX
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Emmanuel Halbwachs
2008-01-15 13:28:20 UTC
Permalink
Hello,

First, thank you very much for your answer.
you need
-c "conf t; foo; exit"
Yes, you're right, it was missing in my example.
2) it appears that hlogin has difficulty with the prompt changing. A change
was applied to clogin to make this work, but apparently not applied
to hlogin. you should be able to work-around it using the -x
method.
Well, I tried this as well (I forgot to tell it) and it hangs the same
way:

***@sionet:~# cat ~eh/rancid/rancid-cmd
conf t
sh sys
exit

***@sionet:~# /usr/lib/rancid/bin/hlogin -v foo -e bar -x ~eh/rancid/rancid-cmd switch
switch
spawn hpuifilter -- telnet switch
Trying 145.238.x.y...
Connected to switch.obspm.fr.
Escape character is '^]'.
HP J4899B ProCurve Switch 2650
Firmware revision H.08.60

Copyright (C) 1991-2005 Hewlett-Packard Co. All Rights Reserved.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.

HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303

Password:

switch> enable
Password:
switch#
switch# no page
switch# conf t

-> hang

Error: TIMEOUT reached

I will try rancid 2.3.2a7 to see if it give some improvement on the
subject.

Nevertheless, I am still open to any hint with HP and configure mode
;-)
--
Emmanuel Halbwachs
Resp. Réseau/Sécurité Observatoire de Paris-Meudon
tel : (+33)1 45 07 75 54 5 Place Jules Janssen
fax : (+33)1 45 07 76 13 F 92195 MEUDON CEDEX
john heasley
2008-01-18 00:14:59 UTC
Permalink
Post by Emmanuel Halbwachs
Hello,
First, thank you very much for your answer.
you need
-c "conf t; foo; exit"
Yes, you're right, it was missing in my example.
2) it appears that hlogin has difficulty with the prompt changing. A change
was applied to clogin to make this work, but apparently not applied
to hlogin. you should be able to work-around it using the -x
method.
the attached patch should fix both issues; -c and -x.
Post by Emmanuel Halbwachs
Well, I tried this as well (I forgot to tell it) and it hangs the same
conf t
sh sys
exit
switch
spawn hpuifilter -- telnet switch
Trying 145.238.x.y...
Connected to switch.obspm.fr.
Escape character is '^]'.
HP J4899B ProCurve Switch 2650
Firmware revision H.08.60
Copyright (C) 1991-2005 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
switch> enable
switch#
switch# no page
switch# conf t
-> hang
Error: TIMEOUT reached
I will try rancid 2.3.2a7 to see if it give some improvement on the
subject.
Nevertheless, I am still open to any hint with HP and configure mode
;-)
--
Emmanuel Halbwachs
Resp. R?seau/S?curit? Observatoire de Paris-Meudon
tel : (+33)1 45 07 75 54 5 Place Jules Janssen
fax : (+33)1 45 07 76 13 F 92195 MEUDON CEDEX
Emmanuel Halbwachs
2008-01-18 07:27:39 UTC
Permalink
Hello,
Post by john heasley
the attached patch should fix both issues; -c and -x.
# Turn off the pager and escape regex meta characters in the $prompt
send "no page\r"
- regsub -all "\[)(]" $prompt {\\&} reprompt
+ regsub -all {[)(]} $prompt {\\&} reprompt
+ regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
Works like a charm, tested with -c and -x

Thanks a lot!
--
Emmanuel Halbwachs
Resp. Réseau/Sécurité Observatoire de Paris-Meudon
tel : (+33)1 45 07 75 54 5 Place Jules Janssen
fax : (+33)1 45 07 76 13 F 92195 MEUDON CEDEX
Loading...