Skip to content

BGP api module truncating asdot notation #255

@bh-rr

Description

@bh-rr

Hi,

EOS version used: cEOS-lab-4.29.2F
pyeapi version is 0.8.4

I tried to retrieve the currently configured AS number on a switch.
Switch config:

router bgp 65001.10
    bgp asn notation asdot
    <snip>

I noticed, that when retrieving the own bgp as of the switch, using the api module, it cuts off the AS after the dot:

import pyeapi
eapi_param = {'host': '<hostname>', 'username': '<username>', 'password': '<password>'}
eapi = pyeapi.connect(**eapi_param)
node = eapi.client.Node(eapi)

node.api('bgp').get()['bgp_as']

This will return 65001.

However, if i get the running (or startup) config and "greping" for "router bgp xyz", i can get the asnumber in asdot notation:

import re
configStringIncludingAS = re.findall(r'router bgp .*', node.running_config)[0]
print(configStringIncludingAS)

This will return router bgp 65001.10 which can be used to further process.

I think the issue is in https://github.com/arista-eosplus/pyeapi/blob/develop/pyeapi/api/bgp.py

def _parse_bgp_as(self, config):
    match = re.search(r'^router bgp (\d+)', config)
    return dict(bgp_as=int(match.group(1)))

I think it would be beneficial if you could edit the regex to also include asdot notation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions