Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_bgp_neighbors() Fails for Arista Software image version: 4.28.5M #1862

Closed
1 task done
oshobu opened this issue Mar 14, 2023 · 1 comment
Closed
1 task done

get_bgp_neighbors() Fails for Arista Software image version: 4.28.5M #1862

oshobu opened this issue Mar 14, 2023 · 1 comment

Comments

@oshobu
Copy link

oshobu commented Mar 14, 2023

Description of Issue/Question

The get_bgp_method() fails for Arista EOS version 4.28.5M. I dug into the code, and found what the Problem is.
This is because the show command used to gather the information from the Arista box now returns additional lines compared to the older EOS Versions.

See below output from the command : show ip bgp neighbors vrf all | include remote AS | remote router ID |IPv[46] (Unicast|6PE):.*[0-9]+|^Local AS|Desc|BGP state

Sample old version output:

BGP neighbor is 23.x.x.1, remote AS 20006, internal link
 Description: Hostname_1
  BGP version 4, remote router ID 23.x.x.x, VRF default
  BGP state is Established, up for 298d22h
    IPv4 Unicast:                     1         9              2                   0
    IPv6 Unicast:                     0         0              0                   0
Local AS is 20006, local router ID 66.x.x.x

Sample output from Newer versions: -> Notice this now has additional Lines IPv4 and IPv6 Unicast (last 2 lines)

BGP neighbor is 54.x.x.106, remote AS 20006, internal link
 Description: Host_2
  BGP version 4, remote router ID 100.x.x.x, VRF default
  BGP state is Established, up for 13d05h
    IPv4 Unicast:                881093         0              0                   0
    IPv6 Unicast:                155144         0              0                   0
Local AS is 2906, local router ID 66.x.x.x
  IPv4 Unicast: 66.x.x.x
  IPv6 Unicast: 2a00:x::x

To fix the issue I basically added about 5 lines of code in the eos.py as shown below in my local environment to Pop those lines from the List if they exist.

    def get_bgp_neighbors(self):
       <SNIP>
            v4_stats = re.match(self._RE_BGP_PREFIX, lines.pop(0))
            v6_stats = re.match(self._RE_BGP_PREFIX, lines.pop(0))
            local_as = re.match(self._RE_BGP_LOCAL, lines.pop(0))
            
            # newer version, show commands have IPV4 UNicast in them
            if lines:  #my code
                if "  IPv4 Unicast:" in lines[0]:   # my code
                    lines.pop(0)  # my code
                if "  IPv6 Unicast:" in lines[0]:  # my code
                    lines.pop(0)  # my code

            data = {
                "remote_as": napalm.base.helpers.as_number(neighbor_info.group("as")),
                "remote_id": napalm.base.helpers.ip(
                    get_re_group(rid_info, "rid", "0.0.0.0")

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

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

napalm version

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

napalm==4.0.0
nornir-napalm==0.3.0

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Arista DCS-7280SR-48C6-M-F
Hardware version: 11.05
Software image version: 4.28.5M
Architecture: x86_64
Internal build version: 4.28.5M-29792660.4285M
Internal build ID: 1814c374-a4c3-4bd4-b7d3-ea4f68b1c4ec
Image format version: 3.0
Image optimization: Sand-4GB

Steps to Reproduce the Issue

import json
from napalm.base import get_network_driver

optional_args = {'transport': 'https'}
driver = get_network_driver('eos')
dev = driver(hostname='host1', username='username', password='pwd')
dev.open()
dev_info = dev.get_bgp_neighbors()
dev.close()
print(json.dumps(dev_info, sort_keys=True, indent=4))

Error Traceback

(Paste the complete traceback of the exception between quotes below)

"/Users/firene/git/mpls_backbone/./mpls_backbone_router.py", line 422, in get_snapshot
    bgp_neigh = device_conn.get_bgp_neighbors()
  File "/Users/firene/git/mpls_backbone/venv/lib/python3.9/site-packages/napalm/eos/eos.py", line 748, in get_bgp_neighbors
    "remote_as": napalm.base.helpers.as_number(neighbor_info.group("as")),
AttributeError: 'NoneType' object has no attribute 'group'
@forkwhilefork
Copy link

forkwhilefork commented May 22, 2023

I ran into this as well. Looks like it was reported in #1743 and fixed in #1746 but there hasn't been another release since then.

@ktbyers ktbyers closed this as completed May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants