Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #257 from napalm-automation/develop
Browse files Browse the repository at this point in the history
Release 0.24.1
  • Loading branch information
mirceaulinic authored Jun 2, 2017
2 parents 8f644bb + 54adfe5 commit add0454
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
34 changes: 34 additions & 0 deletions napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,40 @@ def get_bgp_neighbors(self):
* received_prefixes (int)
* accepted_prefixes (int)
* sent_prefixes (int)
Note, if is_up is False and uptime has a positive value then this indicates the
uptime of the last active BGP session.
Example response:
{
"global": {
"router_id": "10.0.1.1",
"peers": {
"10.0.0.2": {
"local_as": 65000,
"remote_as": 65000,
"remote_id": "10.0.1.2",
"is_up": True,
"is_enabled": True,
"description": "internal-2",
"uptime": 4838400,
"address_family": {
"ipv4": {
"sent_prefixes": 637213,
"accepted_prefixes": 3142,
"received_prefixes": 3142
},
"ipv6": {
"sent_prefixes": 36714,
"accepted_prefixes": 148,
"received_prefixes": 148
}
}
}
}
}
}
"""
raise NotImplementedError

Expand Down
9 changes: 5 additions & 4 deletions napalm_base/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,11 @@ def ip(addr, version=None):
return py23_compat.text_type(addr_obj)


def as_number(as_number):
def as_number(as_number_val):
"""Convert AS Number to standardized asplain notation as an integer."""
if '.' in as_number:
big, little = as_number.split('.')
as_number_str = py23_compat.text_type(as_number_val)
if '.' in as_number_str:
big, little = as_number_str.split('.')
return (int(big) << 16) + int(little)
else:
return int(as_number)
return int(as_number_str)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="napalm-base",
version='0.24.0',
version='0.24.1',
packages=find_packages(),
author="David Barroso, Kirk Byers, Mircea Ulinic",
author_email="[email protected], [email protected], [email protected]",
Expand Down
1 change: 1 addition & 0 deletions test/unit/TestHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def test_as_number(self):
self.assertEqual(napalm_base.helpers.as_number('1.100'), 65636)
self.assertEqual(napalm_base.helpers.as_number('1.65535'), 131071)
self.assertEqual(napalm_base.helpers.as_number('65535.65535'), 4294967295)
self.assertEqual(napalm_base.helpers.as_number(64001), 64001)

def test_convert_uptime_string_seconds(self):
"""
Expand Down

0 comments on commit add0454

Please sign in to comment.