napalm-automation / napalm-junos

Apache License 2.0
22 stars 42 forks source link

get_bgp_neighbors generates keyerror exception on vMX #172

Closed ktbyers closed 7 years ago

ktbyers commented 7 years ago

Running:

napalm-base (0.24.1)
napalm-junos (0.10.1)

Generated the following exception:

>>>Test get bgp neighbors
Traceback (most recent call last):
  File "test_junos.py", line 41, in <module>
    bgp_neigh = device.get_bgp_neighbors()
  File "/home/kbyers/VENV/py27_venv/local/lib/python2.7/site-packages/napalm_junos/junos.py", line 574, in get_bgp_neighbors
    _get_bgp_neighbors_core(instance_neighbors)
  File "/home/kbyers/VENV/py27_venv/local/lib/python2.7/site-packages/napalm_junos/junos.py", line 538, in _get_bgp_neighbors_core
    py23_compat.text_type(neighbor_details['local_id'])
KeyError: u'local_id'

Show bgp summary showed the following:

pyclass@juniper1> show bgp summary 
Groups: 1 Peers: 1 Down peers: 1
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0               
                       0          0          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
10.100.1.2            65416          0          2       0       0     5:38:09 Active
ktbyers commented 7 years ago

Reproduced this against the development branch. Here is what neighbor_details dictionary contains right before KeyError exception:

$ python test_bgp.py 
Password: 
{u'is_enabled': True, u'uptime': 0, u'remote_as': 102, u'address_family': {}, 
u'remote_id': u'', u'local_as': 101, 'peer_as': 102, u'is_up': False, 
u'description': u''}
ktbyers commented 7 years ago

Here is what neighbor_details looks like when it works (BGP session is up):

{u'is_enabled': True, 'tables': 'inet.0', u'uptime': 0, u'remote_as': 102, 
u'address_family': {}, 'received_prefixes': 0, u'remote_id': u'10.0.0.32', 
u'local_as': 101, 'sent_prefixes': 0, 'local_id': '10.0.0.31', 'peer_as': 102, 
u'is_up': True, 'accepted_prefixes': 0, u'description': u''}