[rancid] Re: hlogin script to ProCurve 2650

Mr. James W. Laferriere babydr at baby-dragons.com
Mon Aug 4 19:09:08 UTC 2008


 	Hello Steve ,

On Mon, 4 Aug 2008, Steve Ousley wrote:
> Hi
> We are just trying to add some ProCurve switches to RANCID.  I have got
> various PIX and ASA's on rancid, but this is my first attempt at a HP
> device.
>
> I have setup the method for this as {telnet} above the add method * line so
> it tries to use telnet rather than ssh for this device.
>
> When I run hlogin <device name> I see the following:
>
> nagios-1:/usr/local/rancid/var/mkone# hlogin <device name>
> <device name>
> spawn hpuifilter -- telnet <device name>
> Trying <ip>...
> Connected to <device name>
> Escape character is '^]'.
> ProCurve J4899B Switch 2650
> Software revision H.10.50
>
> Copyright (C) 1991-2007 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
>
> <company> procurve
>
> Press any key to continuePassword:
> ProCurve Switch 2650#
>
> To me, this looks to be all ok (after testing with telnet straight away),
> however, when I get to this point, the session seems to die, and I cannot do
> anything on the switch, then the connection times out after a short while
> and disconnects.
 	Please see both of the attachments .  One is a patch to Rancid's hlogin 
command that will appease the 'Press any key' gods ,  Tho Mr. john heasley has a 
better approach that would basically do the same thing .  The second is a method 
to get a ProCurve (of the version specified) back from Menu Mode .  Tho it does 
not look like you need that help .

> I have tried manually telnetting to the device, and can run commands on the
> switch no problems (sh run etc), and get output.

> Also, is there any way to use rancid to connect to a device on multiple
> ports? For instance I would like to get rancid to get configurations from 2
> switches, where the gateway forwards the relevant port to the relevant
> switch. Eg telnet 1.2.3.4 on port 23 telnet 1.2.3.4 on port 45.
 	I'm no help to you here ,  Also be patient ,  wait a good while before 
getting upset about not geeing responses ,  Many on this list will respond 
eventually they are all extremely busy .

> Regards
> Steve Ousley - SO620-RIPE
> Nuco Technologies Ltd
> <mailto:steve at host-it.co.uk> steve at host-it.co.uk
> <http://www.nucotechnologies.com/> www.nucotechnologies.com
> Tel. 0870 165 1300
> Nuco Technologies Ltd is a company registered in England and Wales
> with company number 04470751

 	Hth ,  JimL
-- 
+------------------------------------------------------------------+
| James   W.   Laferriere | System    Techniques | Give me VMS     |
| Network&System Engineer | 2133    McCullam Ave |  Give me Linux  |
| babydr at baby-dragons.com | Fairbanks, AK. 99701 |   only  on  AXP |
+------------------------------------------------------------------+
-------------- next part --------------
From babydr at baby-dragons.com Fri May 16 12:25:20 2008
Date: Fri, 16 May 2008 12:25:19 -0800 (AKDT)
From: Mr. James W. Laferriere <babydr at baby-dragons.com>
To: rancid <rancid-discuss at shrubbery.net>
Subject: Getting the HP Procurve 2534 J4813A Release #F.05.59 back to CLI ,  Howto

	Hello All ,

		As 'manager' account goto menu mode .
		Goto 'Run Setup'
		Press <Enter>
		Goto 'Edit' ,  Press <Enter>
		Goto  'Logon Default : ' Field ,
		Hit 'Space bar' ,	<<< this toggles between modes >>>
		Press <Enter>
		Goto 'Save' ,  Press <Enter>
		Should take you back to the 'main menu' .

	After that it's all upto you .

	For this device & firmware version 'hlogin' is the program to use .

	Setup a 'manager' user & then add something like ... To .cloginrc .

add autoenable          *-sw*   {1}
add user                *-sw*   {ManagerUser}
add password            *-sw*   {ManagerPassword}   {nosuchpassword}
add method              *-sw*   ssh telnet

		Hth ,  JimL

ps:	DISREGARD any previous patches to flogin as that was a BAD start .
-- 
+------------------------------------------------------------------+
| James   W.   Laferriere | System    Techniques | Give me VMS     |
| Network&System Engineer | 2133    McCullam Ave |  Give me Linux  |
| babydr at baby-dragons.com | Fairbanks, AK. 99701 |   only  on  AXP |
+------------------------------------------------------------------+
-------------- next part --------------
--- /usr/local/rancid/bin/hlogin-v1_40-20061208	2008-05-15 17:00:00.000000000 -0800
+++ /usr/local/rancid/bin/hlogin	2008-05-21 15:49:26.000000000 -0800
@@ -473,13 +473,45 @@
     return 0
 }
 
+# Check (as best we can) if we are on a HP router or switch .
+# Actually checking if is a router & saying otherwise it's a switch .
+# & Set the pageR off variable .
+proc chk_rtr {in_proc prompt timeout} {
+  set old_Timeout $timeout
+  set timeout 5
+  global pageR
+  set Buffer "" 
+  log_user 0
+  exp_send "show version\r"
+  expect {
+    -re "Image stamp|Router" {
+      set Buffer $expect_out(0,string); 
+    }
+  }
+  log_user 1
+  if { $Buffer eq "Image stamp" } {
+    # I'm a SWITCH ...
+    set pageR "no page"
+  }
+  if { $Buffer eq "Router" } {
+    # I'm a ROUTER ...
+    set pageR "terminal length 0"
+  }
+  if { $Buffer eq "" } {
+    # Default to (hoping) I'm a ROUTER ... 
+    set pageR "terminal length 0"
+  }
+  set timeout $old_Timeout
+  return
+}
+
 # Run commands given on the command line.
-proc run_commands { prompt command } {
+  proc run_commands { prompt command pageR } {
     global in_proc platform
     set in_proc 1
-
+    
     # Turn off the pager and escape regex meta characters in the $prompt
-    send "terminal length 0\r"
+    send "$pageR\r"
     regsub -all "\[)(]" $prompt {\\&} reprompt
     expect {
 	-re $reprompt	{}
@@ -716,14 +748,16 @@
 	-re "\[\r\n]+"		{ exp_continue; }
 	-re "^.+$prompt"	{ set prompt $expect_out(0,string); }
     }
-
+    # check if we are on a route or not ,
+    # & Set pageR variable accordingly .
+    chk_rtr $in_proc $prompt $timeout
     if { $do_command } {
-	if {[run_commands $prompt $command]} {
+	if {[run_commands $prompt $command $pageR]} {
 	    continue
 	}
     } elseif { $do_script } {
 	# disable the pager
-	send "terminal length 0\r"
+        send "$pageR\r"
 	expect -re $prompt	{}
 	source $sfile
 	close


More information about the Rancid-discuss mailing list