{"action":"created","issue":{"url":"https://api.github.com/repos/napalm-automation/napalm/issues/759","repository_url":"https://api.github.com/repos/napalm-automation/napalm","labels_url":"https://api.github.com/repos/napalm-automation/napalm/issues/759/labels{/name}","comments_url":"https://api.github.com/repos/napalm-automation/napalm/issues/759/comments","events_url":"https://api.github.com/repos/napalm-automation/napalm/issues/759/events","html_url":"https://github.com/napalm-automation/napalm/pull/759","id":337906282,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4OTY4NjQ5","number":759,"title":"Fix issue with LLDP neighbors when remote device lacks system name on older IOS version","user":{"login":"jobec","id":16192496,"node_id":"MDQ6VXNlcjE2MTkyNDk2","avatar_url":"https://avatars3.githubusercontent.com/u/16192496?v=4","gravatar_id":"","url":"https://api.github.com/users/jobec","html_url":"https://github.com/jobec","followers_url":"https://api.github.com/users/jobec/followers","following_url":"https://api.github.com/users/jobec/following{/other_user}","gists_url":"https://api.github.com/users/jobec/gists{/gist_id}","starred_url":"https://api.github.com/users/jobec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jobec/subscriptions","organizations_url":"https://api.github.com/users/jobec/orgs","repos_url":"https://api.github.com/users/jobec/repos","events_url":"https://api.github.com/users/jobec/events{/privacy}","received_events_url":"https://api.github.com/users/jobec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-03T13:45:29Z","updated_at":"2018-07-03T13:58:48Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/napalm-automation/napalm/pulls/759","html_url":"https://github.com/napalm-automation/napalm/pull/759","diff_url":"https://github.com/napalm-automation/napalm/pull/759.diff","patch_url":"https://github.com/napalm-automation/napalm/pull/759.patch"},"body":"There is a bug where LLDP neighbors end up on the same interface when the remove device didn't have a system name and the LLDP output was missing `Local Intf` on older IOS versions.\r\n\r\nThis example returns the neighbor of interface Fa0/17 as being connected to Fa0/24.\r\n```\r\nCapability codes:\r\n    (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device\r\n    (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other\r\n\r\nDevice ID           Local Intf     Hold-time  Capability      Port ID\r\nswitch1             Fa0/24         120        B               Fa0/19\r\n480f.cf28.8a1b      Fa0/17         3601                       480f.cf28.8a1b\r\n\r\nTotal entries displayed: 2\r\n```\r\n```\r\n------------------------------------------------\r\nChassis id: a40c.c3c1.3980\r\nPort id: Fa0/19\r\nPort Description: FastEthernet0/19\r\nSystem Name: switch1\r\n\r\nSystem Description:\r\nCisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(1)SE2, RELEASE SOFTWARE (fc3)\r\nTechnical Support: http://www.cisco.com/techsupport\r\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\r\nCompiled Thu 22-Dec-11 00:46 by prod_rel_team\r\n\r\nTime remaining: 113 seconds\r\nSystem Capabilities: B\r\nEnabled Capabilities: B\r\nManagement Addresses:\r\n    IP: 10.127.15.129\r\nAuto Negotiation - supported, enabled\r\nPhysical media capabilities:\r\n    100base-TX(FD)\r\n    100base-TX(HD)\r\n    10base-T(FD)\r\n    10base-T(HD)\r\nMedia Attachment Unit type: 16\r\nVlan ID: 1\r\n\r\n------------------------------------------------\r\nChassis id: 480f.cf28.8a1b\r\nPort id: 480f.cf28.8a1b\r\nPort Description - not advertised\r\nSystem Name - not advertised\r\nSystem Description - not advertised\r\n\r\nTime remaining: 2787 seconds\r\nSystem Capabilities - not advertised\r\nEnabled Capabilities - not advertised\r\nManagement Addresses - not advertised\r\nAuto Negotiation - supported, enabled\r\nPhysical media capabilities:\r\n    1000baseT(FD)\r\nMedia Attachment Unit type - not advertised\r\nVlan ID: - not advertised\r\n\r\nMED Information:\r\n\r\n    MED Codes:\r\n          (NP) Network Policy, (LI) Location Identification\r\n          (PS) Power Source Entity, (PD) Power Device\r\n          (IN) Inventory\r\n\r\n    Inventory information - not advertised\r\n    Capabilities:\r\n    Device type: Endpoint Class I\r\n    Network Policies - not advertised\r\n    Power requirements - not advertised\r\n    Location - not advertised\r\n\r\n\r\nTotal entries displayed: 2\r\n```\r\nOutput\r\n```\r\nget_lldp_neighbors()\r\n----------------------------------\r\n{'FastEthernet0/24': [{'hostname': 'switch1', 'port': 'fa0/19'},\r\n                      {'hostname': 'N/A', 'port': '40b0.34e2.bcac'}]}\r\n\r\nget_lldp_neighbors_detail()\r\n----------------------------------\r\n{'FastEthernet0/24': [{'parent_interface': 'N/A',\r\n                       'remote_chassis_id': 'a40c.c3c1.3980',\r\n                       'remote_port': 'Fa0/19',\r\n                       'remote_port_description': 'FastEthernet0/19',\r\n                       'remote_system_capab': 'B',\r\n                       'remote_system_description': 'Cisco IOS Software, C2960 '\r\n                                                    'Software '\r\n                                                    '(C2960-LANBASEK9-M), '\r\n                                                    'Version 15.0(1)SE2, '\r\n                                                    'RELEASE SOFTWARE (fc3)',\r\n                       'remote_system_enable_capab': 'B',\r\n                       'remote_system_name': 'switch1'},\r\n                      {'parent_interface': 'N/A',\r\n                       'remote_chassis_id': '40b0.34e2.bcac',\r\n                       'remote_port': '40b0.34e2.bcac',\r\n                       'remote_port_description': 'N/A',\r\n                       'remote_system_capab': 'N/A',\r\n                       'remote_system_description': 'N/A',\r\n                       'remote_system_enable_capab': 'N/A',\r\n                       'remote_system_name': 'N/A'}]}\r\n```\r\nExpected Output\r\n```\r\nget_lldp_neighbors()\r\n----------------------------------\r\n{'FastEthernet0/16': [{'hostname': 'N/A', 'port': '40b0.34e2.bcac'}],\r\n 'FastEthernet0/24': [{'hostname': 'xwbs032101', 'port': 'Fa0/19'}]}\r\n\r\nget_lldp_neighbors_detail()\r\n----------------------------------\r\n{'FastEthernet0/16': [{'parent_interface': 'N/A',\r\n                       'remote_chassis_id': '40b0.34e2.bcac',\r\n                       'remote_port': '40b0.34e2.bcac',\r\n                       'remote_port_description': 'N/A',\r\n                       'remote_system_capab': 'N/A',\r\n                       'remote_system_description': 'N/A',\r\n                       'remote_system_enable_capab': 'N/A',\r\n                       'remote_system_name': 'N/A'}],\r\n 'FastEthernet0/24': [{'parent_interface': 'N/A',\r\n                       'remote_chassis_id': 'a40c.c3c1.3980',\r\n                       'remote_port': 'Fa0/19',\r\n                       'remote_port_description': 'FastEthernet0/19',\r\n                       'remote_system_capab': 'B',\r\n                       'remote_system_description': 'Cisco IOS Software, C2960 '\r\n                                                    'Software '\r\n                                                    '(C2960-LANBASEK9-M), '\r\n                                                    'Version 15.0(1)SE2, '\r\n                                                    'RELEASE SOFTWARE (fc3)',\r\n                       'remote_system_enable_capab': 'B',\r\n                       'remote_system_name': 'xwbs032101'}]}\r\n```"},"comment":{"url":"https://api.github.com/repos/napalm-automation/napalm/issues/comments/402167123","html_url":"https://github.com/napalm-automation/napalm/pull/759#issuecomment-402167123","issue_url":"https://api.github.com/repos/napalm-automation/napalm/issues/759","id":402167123,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjE2NzEyMw==","user":{"login":"jobec","id":16192496,"node_id":"MDQ6VXNlcjE2MTkyNDk2","avatar_url":"https://avatars3.githubusercontent.com/u/16192496?v=4","gravatar_id":"","url":"https://api.github.com/users/jobec","html_url":"https://github.com/jobec","followers_url":"https://api.github.com/users/jobec/followers","following_url":"https://api.github.com/users/jobec/following{/other_user}","gists_url":"https://api.github.com/users/jobec/gists{/gist_id}","starred_url":"https://api.github.com/users/jobec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jobec/subscriptions","organizations_url":"https://api.github.com/users/jobec/orgs","repos_url":"https://api.github.com/users/jobec/repos","events_url":"https://api.github.com/users/jobec/events{/privacy}","received_events_url":"https://api.github.com/users/jobec/received_events","type":"User","site_admin":false},"created_at":"2018-07-03T13:58:48Z","updated_at":"2018-07-03T13:58:48Z","author_association":"NONE","body":"Some background by the changes I made:\r\n\r\nInstead of trying to throw together a reverse lookup table from 2 different show commands, this code now goes by the assumption that the output of `show lldp neighbors` is in the same sequence as `show lldp neighbors detail`. Which is true for every device I tried, and also matches with the data in all test suites.\r\n\r\nThe key error was in the code before this line:\r\nhttps://github.com/napalm-automation/napalm/blob/d7961e8d0efbe6db3cfd4e373edc4d3f0d54f62f/napalm/ios/ios.py#L854\r\nWhere the variable `local_intf` was:\r\n\r\n1. Not reset on every iteration. Cause it to keep the value of the previous iteration with the example code above.\r\n1. Had already a value because the same name is used in this for loop:\r\nhttps://github.com/napalm-automation/napalm/blob/d7961e8d0efbe6db3cfd4e373edc4d3f0d54f62f/napalm/ios/ios.py#L826"}}
{"actor":{"display_login":"jobec"}}