-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
Description
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.