ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.63k stars 1.31k forks source link

Implement simple HP ProCurve auto detect #1461

Closed aianbc closed 2 years ago

aianbc commented 5 years ago

Kirk,

Can you help me on this, unable to detect the device type of the switch as the device type is hp_procurve.

CODE

from netmiko import ConnectHandler from netmiko.ssh_autodetect import SSHDetect from netmiko.ssh_dispatcher import ssh_dispatcher

asw1 = { 'device_type': 'autodetect', 'ip': '10.84.10.1', 'session_timeout': 60, 'timeout': 60, 'username': 'admin', 'password': 'admin' }

guesser = SSHDetect(**asw1) match = guesser.autodetect()

print(match)

OUTPUT

(venv) C:\Users\aianbc\PycharmProjects\NETAUTO\PyX>python uat1.py None

ktbyers commented 5 years ago

Yes, it doesn't look like there is any autodetect for HP ProCurve someone would have to implement it via a PR.

If you send me over a show version output from a device I could see if there is an easy fix.

aianbc commented 5 years ago

Hi Kirk,

Here you go.

SHOW VERSION

ggc-cg3b11-asw2# show version Image stamp: /sw/code/build/bass(bh2) Oct 21 2008 16:33:39 N.11.15 25 Boot Image: Primary

SYSTEM INFORMATION

ProCurve J9021A Switch 2810-24G Software revision : N.11.15
ROM Version : N.10.01

ktbyers commented 4 years ago

Note, this will not work generally (as ProCurve is not consistently in the show version output). We could, however, implement show version and at least match on the set of HP ProCurve devices that do behave this way.

aianbc commented 4 years ago

Thanks kirk.

mitchellaxtell commented 4 years ago

Here's the output from two switches- one very legacy and one modern. It appears that a match for "Image stamp.*/code/build" would be suitable. I do have a number of other HP models I could check against if requested.

HP 2824# show version Image stamp: /sw/code/build/mako Aug 24 2015 16:29:50 I.10.107 2132 Boot Image: Primary HP 2824#

HP 2920-24G-PoE+# show ver Image stamp: /ws/swbuildm/rel_spokane_qaoff/code/build/anm(swbuildm_rel_spokane_qaoff_rel_spokane) Mar 30 2017 09:35:04 WB.16.02.0018 858 Boot Image: Primary

Boot ROM Version: WB.16.03 Active Boot ROM: Primary

HP 2920-24G-PoE+#

ktbyers commented 4 years ago

Is there no command in HP ProCurve where the output actually says "HP"/"HPE" and "ProCurve"/"Provision"?

We can potentially do:

"Image stamp.*/code/build"

But it would be better to actually get output that identifies the platform/vendor as opposed to having to infer it from pretty general text.

mitchellaxtell commented 4 years ago

Procurve and Provision do not appear in any command I am aware of, even in "show tech". As for "HP", that is shown in a "show modules" on stacking or chassis switches, or "show lldp info local-device" - see below

2920-48G-POE+# show lldp info local

 LLDP Local Device Information

  Chassis Type : mac-address
  Chassis Id   : aa bb cc dd ee ff
  System Name  : 2920-48G-POE+ (hostname)
  System Description : HP J9729A 2920-48G-POE+ Switch, revision WB.16.02.00... (line in question)
  System Capabilities Supported: bridge, router
  System Capabilities Enabled: bridge

  Management Address  :
     Type: ipv4
     Address: 10.0.0.1

  OOBM Management Address  :
     Type: all802
     Address: aa bb cc dd ee ff

 LLDP Port Information

  Port     PortType PortId   PortDesc
  -------- -------- -------- --------
  1        local    1        1
  2        local    2        2
  3        local    3        3
  4        local    4        4
  5        local    5        5
  6        local    6        6
  7        local    7        7
  8        local    8        8
  9        local    9        9
  10       local    10       10
  11       local    11       11
  12       local    12       12
  13       local    13       13
  14       local    14       14
  15       local    15       15
  16       local    16       16
  17       local    17       17
-- MORE --, next page: Space, next line: Enter, quit: Control-C

This does not explicitly define this as a Provision device, but as far as I am aware this command does not function on a Comware device and works on anything 10.74 and higher (end of 2008).

This is applicable at least until 16.10- HP is rebranding the Provision lines as Aruba, but I have not found one that displays as "Aruba JXXXX". Please note that the J naming is not J####, but can be displayed as JL (J[L0-9]{4}[A-Z]{0,1}).

ktbyers commented 4 years ago

Okay, I guess we will have to do something like this then...

"Image stamp.*/code/build"

If someone wants to implement a PR on that...that would be great.

ktbyers commented 2 years ago

Someone would need to implement this in a PR. Unforutnately HP ProCurve makes it hard by being so nondescript in their output.

robinreinhardt commented 1 year ago

I implemented it in #3132