Skip to content
This repository has been archived by the owner on Feb 10, 2018. It is now read-only.

Error with "get_bgp_neighbors" #177

Closed
bdlamprecht opened this issue Jun 30, 2017 · 8 comments
Closed

Error with "get_bgp_neighbors" #177

bdlamprecht opened this issue Jun 30, 2017 · 8 comments
Labels
Milestone

Comments

@bdlamprecht
Copy link

bdlamprecht commented Jun 30, 2017

Description of Issue/Question

When running the NAPALM getter 'get_bgp_neighbors()' I get an IndexError: list index out of range error.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

[X] Yes
[ ] No

Setup

napalm-junos version

(Paste verbatim output from pip freeze | grep napalm-junos between quotes below)

$ pip list | grep napalm-junos
napalm-junos      0.10.3

JunOS version

(Paste verbatim output from show version and haiku between quotes below)

bl839s@pok-vsc-b> show version and haiku
Hostname: pok-vsc-b
Model: mx480
Junos: 14.2R6.5
JUNOS Base OS boot [14.2R6.5]
JUNOS Base OS Software Suite [14.2R6.5]
JUNOS platform Software Suite [14.2R6.5]
JUNOS Web Management [14.2R6.5]
JUNOS Runtime Software Suite [14.2R6.5]
JUNOS Online Documentation [14.2R6.5]
JUNOS Services AACL Container package [14.2R6.5]
JUNOS Services Application Level Gateways [14.2R6.5]
JUNOS AppId Services [14.2R6.5]
JUNOS Services Captive Portal and Content Delivery Container package [14.2R6.5]
JUNOS Border Gateway Function package [14.2R6.5]
JUNOS Services HTTP Content Management package [14.2R6.5]
JUNOS IDP Services [14.2R6.5]
JUNOS Services LL-PDF Container package [14.2R6.5]
JUNOS Services Jflow Container package [14.2R6.5]
JUNOS Services MobileNext Software package [14.2R6.5]
JUNOS Services Mobile Subscriber Service Container package [14.2R6.5]
JUNOS Services NAT [14.2R6.5]
JUNOS Services RPM [14.2R6.5]
JUNOS Services PTSP Container package [14.2R6.5]
JUNOS Services Stateful Firewall [14.2R6.5]
JUNOS Voice Services Container package [14.2R6.5]
JUNOS Macsec Software Suite [14.2R6.5]
JUNOS Services Crypto [14.2R6.5]
JUNOS Services SSL [14.2R6.5]
JUNOS Services IPSec [14.2R6.5]
JUNOS py-base-i386 [14.2R6.5]
JUNOS Kernel Software Suite [14.2R6.5]
JUNOS Crypto Software Suite [14.2R6.5]
JUNOS Packet Forwarding Engine Support (M/T/EX Common) [14.2R6.5]
JUNOS Packet Forwarding Engine Support (MX Common) [14.2R6.5]
JUNOS Routing Software Suite [14.2R6.5]


        Holiday spirit
        Christmas comes but once a year
        Keep it shining bright

Steps to Reproduce the Issue

Run the following code:

#!/usr/bin/env python

from getpass import getpass
from pprint import pprint as pp

from napalm_base import get_network_driver

hostname = 'pok-vsc-b'
username = 'ansible'
optional_args = {}
password = getpass()

driver = get_network_driver('junos')
device = driver(hostname, username, password, optional_args=optional_args)

print(">>>Test device open")
device.open()

print(">>>Test get facts")
output = device.get_bgp_neighbors()
pp(output)

Error Traceback

Provides the following error:

>>>Test device open
>>>Test get facts
Traceback (most recent call last):
  File "./testing_junos_bgp_neighbors.py", line 20, in <module>
    output = device.get_bgp_neighbors()
  File "/home/bl839s/.virtualenvs/napalm/local/lib/python2.7/site-packages/napalm_junos/junos.py", line 571, in get_bgp_neighbors
    uptime_table_items=uptime_table_items)
  File "/home/bl839s/.virtualenvs/napalm/local/lib/python2.7/site-packages/napalm_junos/junos.py", line 546, in _get_bgp_neighbors_core
    peer['address_family'] = self._parse_route_stats(neighbor_details)
  File "/home/bl839s/.virtualenvs/napalm/local/lib/python2.7/site-packages/napalm_junos/junos.py", line 464, in _parse_route_stats
    data[family]['sent_prefixes'] = neighbor['sent_prefixes'][idx]
IndexError: list index out of range
@bdlamprecht
Copy link
Author

@mirceaulinic Any updates on resolving this issue?

@ktbyers
Copy link
Contributor

ktbyers commented Aug 4, 2017

@bdlamprecht We probably need the output of the following to help us debug the information. Should be able to get this by using | display xml and | display xml rpc.

https://github.com/napalm-automation/napalm-junos/blob/develop/test/unit/mocked_data/test_get_bgp_neighbors/normal/get-bgp-neighbor-information.xml

@bdlamprecht
Copy link
Author

As discussed in the NetworkToCode Slack channel, here is the XML file for the peer that is crashing the get_bgp_neighbors. I've done a search and replace for the IPs and replaced the first 3 octets with RFC1918 addressing. The last octet was not changed at all.

xml for junos_bgp_getter issue.txt

Let me know if you need other information.
Thanks!

@ckishimo
Copy link
Contributor

The #209 should fix that as the error is exactly the same. However I cannot see the problem based on the xml file provided (ie: all ribs have the advertised-prefix-count node).

@bdlamprecht is it possible that get_bgp_neighbors is crashing because of a different peer than the one you provided ? would it be possible to get the full output of show bgp neighbors | display xml ?

@bdlamprecht
Copy link
Author

@ckishimo Yes, #209 did fix the error for get_bgp_neigbors_detail for this device (thanks!)

However, but when I checked the napalm get_bgp_neighbors (no _detail), the same error as posted above occurred.

I've done what you asked and posted the show bgp neighbors | display xml into this gist:
https://gist.github.com/bdlamprecht/0a2742ef0a649164b7b85783af9cbebb

Hope that provides you with enough information to troubleshoot the problem.

Note, I did change the addressing of the first two octets of the BGP peers to RFC1918 addresses.

FYI, I can't guarantee that it is the same as before as these are lab devices and multiple people may have changed the configuration since the previous information was posted.

@ckishimo
Copy link
Contributor

ckishimo commented Oct 4, 2017

@bdlamprecht thanks for the outputs! I was able to see an error while using get_bgp_neighbors however the error is not exactly the same as before, so not sure if it's the same as you saw or a new one...:

Traceback (most recent call last):
  File "client_junos_bgp.py", line 21, in <module>
    res = dev.get_bgp_neighbors()
  File "/home/ckishimo/python/devel/git/devel-bgp/napalm-junos/napalm_junos/junos.py", line 597, in get_bgp_neighbors
    uptime_table_items=uptime_table_items)
  File "/home/ckishimo/python/devel/git/devel-bgp/napalm-junos/napalm_junos/junos.py", line 563, in _get_bgp_neighbors_core
    peer['address_family'] = self._parse_route_stats(neighbor_details)
  File "/home/ckishimo/python/devel/git/devel-bgp/napalm-junos/napalm_junos/junos.py", line 478, in _parse_route_stats
    data[family]['sent_prefixes'] = neighbor['sent_prefixes'].pop(0)
AttributeError: 'int' object has no attribute 'pop'

Based on the data provided, sent_prefixes is of type int when a list was expected:

'send-state': ['in sync', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising', 'not advertising'], u'is_up': True, 'sent_prefixes': 5439, 'peer_as': 65143, 'accepted_prefixes': [622, 9, 0, 61, 41, 117, 121, 40, 36, 127, 6, 2]

I just pushed the change converting sent_prefixes into a list.
@bdlamprecht could you please confirm the error was the same I just posted ? and also please report if all errors are fixed now. Thanks!

@bdlamprecht
Copy link
Author

@ckishimo Yes, that fixed the issue I was having. I now get the expected values back correctly. Please submit this fix as PR so it can be merged into the main driver.

Thanks again for investigating this and revolving it so quickly.

@mirceaulinic
Copy link
Member

Closed via 0fbda09

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants