ixs / napalm-procurve

HP ProCurve Driver for NAPALM automation frontend
Apache License 2.0
21 stars 15 forks source link

_getMIB_value fails because of wrong interface name #6

Closed ffly90 closed 5 years ago

ffly90 commented 5 years ago

Hi, I am trying to use your driver to access some switches. However the get_lldp_neighbors_detail fails because the interface name is e.g. J8 this is not what the getMIB command on the switch is expecting, it is somehow encoded differently in the oid.

I added some debugging output to show what is happening: >>> device.get_lldp_neighbors_detail() OID: lldpRemSysDesc.0.A13.1 command: getMIB lldpRemSysDesc.0.A13.1 output: annot translate variable lldpRemSysDesc.0.A13.1. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/napalm_procurve/procurve.py", line 325, in get_lldp_neighbors_detail lldp_neighbors = self.get_lldp_neighbors() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/napalm_procurve/procurve.py", line 299, in get_lldp_neighbors local_port) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/napalm_procurve/procurve.py", line 364, in _get_lldp_neighbors_detail tmp_lldp_details = self._lldp_detail_parser(interface) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/napalm_procurve/procurve.py", line 386, in _lldp_detail_parser 'lldpRemSysDesc.0.{}.1'.format(interface)) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/napalm_procurve/procurve.py", line 195, in _getMIB_value return output.split(' = ')[1].strip() IndexError: list index out of range

Anyone else having this problem? Does anyone have a suggestion on how to get the right interface encoding to present the switch? Any help or hints will be appreciated.

ixs commented 5 years ago

Right. I understand the problem. Looks to be related to the way we build the OID Index.

Could you please give the following details: Switch Model Output of show lldp info remote-device Output of show lldp info remote-device A13

Please attach the output of the show lldp command as files, so that I am able to build a test case for these.

That should help me understand what is going on.

ffly90 commented 5 years ago

Hi, the Switch Model is "hp procurve 5412zl" I'm sorry but I cannot give you a verbose output of the infrastructure, but I can give you this much: Partial (sanitized) output of show lldp info remote-device:

LocalPort | ChassisId PortId PortDescr SysName
--------- + ------------------ ------------------ --------- ------------------ A1 | 00 00 00 00 00 00 48 48 sw123
A7 | 00 00 00 00 00 00 48 48 sw234
A10 | 00 00 00 00 00 00 48 48 sw345
A11 | 00 00 00 00 00 00 48 48 sw456 A13 | 00 00 00 00 00 00 M-GigabitEthern... M-Giga... sw567 [...] Sanitized output of show lldp info remote-device A13: LLDP Remote Device Information Detail ` Local Port : A13 ChassisType : mac-address ChassisId : 00 00 00 00 00 00 PortType : interface-name PortId : M-GigabitEthernet1/0/0/0 SysName : sw567 System Descr : HPE Comware Platform Software, Software Version 7.1.070, ... PortDescr : M-GigabitEthernet1/0/0/0 Interface Pvid : System Capabilities Supported : bridge, router System Capabilities Enabled : bridge, router Remote Management Address Type : all802 Address : 00 00 00 00 00 00 Poe Plus Information Detail Poe Device Type : Type2 PSE Power Source : Unknown Power Priority : Unknown Requested Power Value : 0.0 Watts Actual Power Value : 0.0 Watts`

I debugged the Problem to this point: sw1# getMIB lldpRemSysDesc.0.A13.1 Cannot translate variable lldpRemSysDesc.0.A13.1.

I suggested a quick fix for the problem in pull request #7

I am currently working in an environment with a variety of hp switches. Some of them work with your napalm driver, others not. I also found a bug with the portnames in the get_interfaces() function and already fixed it. If you want I can also make a pull request for that.

ixs commented 5 years ago

I had seen the "quick-fix" but while it will prevent the parser dying, it will also return empty data. Thus I need to fix the parser bug as well.

Thank you for the output from the switch. This helps a bit.

Could you please run walkMIB lldpLocPortId on the switch. That should give me an idea how the named ports (e.g.A13) are indexed and I can hopefully fix the bug.

I'd also be interested in the get_interfaces() problem you described. What is the error you're seeing and how did you fix it?

ffly90 commented 5 years ago

walkMIB lldpLocPortId lldpLocPortId.1 = 1 lldpLocPortId.2 = 2 lldpLocPortId.3 = 3 lldpLocPortId.4 = 4 lldpLocPortId.5 = 5 lldpLocPortId.6 = 6 lldpLocPortId.7 = 7 lldpLocPortId.8 = 8 lldpLocPortId.9 = 9 lldpLocPortId.10 = 10 lldpLocPortId.11 = 11 lldpLocPortId.12 = 12 lldpLocPortId.13 = 13 lldpLocPortId.14 = 14 lldpLocPortId.15 = 15 lldpLocPortId.16 = 16 lldpLocPortId.17 = 17 lldpLocPortId.18 = 18 lldpLocPortId.19 = 19 lldpLocPortId.20 = 20 lldpLocPortId.21 = 21 lldpLocPortId.22 = 22 lldpLocPortId.23 = 23 lldpLocPortId.24 = 24 lldpLocPortId.25 = 25 lldpLocPortId.26 = 26 lldpLocPortId.27 = 27 lldpLocPortId.28 = 28 lldpLocPortId.29 = 29 lldpLocPortId.30 = 30 lldpLocPortId.31 = 31 lldpLocPortId.32 = 32 lldpLocPortId.49 = 49 lldpLocPortId.50 = 50 lldpLocPortId.51 = 51 lldpLocPortId.52 = 52 lldpLocPortId.53 = 53 lldpLocPortId.54 = 54 lldpLocPortId.55 = 55 [...]

The problem with your implementation of the get_interfaces() function for me was, that you are using the 'idx' as interface key, which does not really work out for me because it does not match the portnames returned by the get_lldp_neighbors() function. So what I did to fix that for me was, that I modified line 735 if_names = self._walkMIB_values('ifName') (line number 735) and line 745 interfaces[py23_compat.text_type(if_names[idx])] = { to make the key in the dictionary match the portnames I expect. The output of walkMIB fName looks like this:

walkMIB ifName 
ifName.1 = A1
ifName.2 = A2
ifName.3 = A3
ifName.4 = A4
ifName.5 = A5
ifName.6 = A6
ifName.7 = A7
ifName.8 = A8
ifName.9 = A9
ifName.10 = A10
ifName.11 = A11
ifName.12 = A12
ifName.13 = A13
ifName.14 = A14
ifName.15 = A15
ifName.16 = A16
ifName.17 = A17
ifName.18 = A18
ifName.19 = A19
ifName.20 = A20
ifName.21 = A21
ifName.22 = A22
ifName.23 = A23
ifName.24 = A24
ifName.25 = B1
ifName.26 = B2
ifName.27 = B3
ifName.28 = B4
ifName.29 = B5
ifName.30 = B6
ifName.31 = B7
ifName.32 = B8
ifName.49 = C1
ifName.50 = C2
ifName.51 = C3
ifName.52 = C4
ifName.53 = C5
ifName.54 = C6
ifName.55 = C7
ifName.56 = C8
ixs commented 5 years ago

Jupp. The ifName dict is important.

It never mattered on the edge-switches I wrote this with as they have numerically port numbers which can serve as index keys. But your switch is different, so the ifName dict needs to be created.

That would also fix the LLDP issue... Let me see if I can come up with a clean implementation.

ffly90 commented 5 years ago

Thank you, that helps a lot :)

ixs commented 5 years ago

alright. working on it, quick question: are you on IRC? hangouts? whatsapp? or any other more realtime messenger?

ixs commented 5 years ago

Try the branch in https://github.com/ixs/napalm-procurve/tree/named_interfaces and see if that works. and I'd still appreciate a messenger contact as I want to build a decent testsuite for the new content to ensure it'll work in the future as well.

ixs commented 5 years ago

New commit to master branch. Should fix this issue.