Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ansible/library/bgp_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def parse_neighbors(self):
regex_conn_dropped = re.compile(r'.*Connections established \d+; dropped (\d+)')
regex_peer_group = re.compile(r'.*Member of peer-group (.*) for session parameters')
regex_subnet = re.compile(r'.*subnet range group: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2})')
regex_cap_gr = re.compile(r'.*Graceful Restart Capabilty: (\w+)')
regex_cap_gr_peer_restart_time = re.compile(r'.*Remote Restart timer is (\d+)')
regex_cap_gr_peer_af_ip4 = re.compile(r'.*IPv4 Unicast\((.*)\)')
regex_cap_gr_peer_af_ip6 = re.compile(r'.*IPv6 Unicast\((.*)\)')

neighbors = {}

Expand All @@ -117,6 +121,7 @@ def parse_neighbors(self):
# ignore empty rows
if 'BGP' in n:
neighbor = {}
capabilities = {}
message_stats = {}
n = "BGP neighbor is" + n
lines = n.splitlines()
Expand All @@ -143,6 +148,11 @@ def parse_neighbors(self):
if regex_peer_group.match(line): neighbor['peer group'] = regex_peer_group.match(line).group(1)
if regex_subnet.match(line): neighbor['subnet'] = regex_subnet.match(line).group(1)

if regex_cap_gr.match(line): capabilities['graceful restart'] = regex_cap_gr.match(line).group(1).lower()
if regex_cap_gr_peer_restart_time.match(line): capabilities['peer restart timer'] = int(regex_cap_gr_peer_restart_time.match(line).group(1))
if regex_cap_gr_peer_af_ip4.match(line): capabilities['peer af ipv4 unicast'] = regex_cap_gr_peer_af_ip4.match(line).group(1).lower()
if regex_cap_gr_peer_af_ip6.match(line): capabilities['peer af ipv6 unicast'] = regex_cap_gr_peer_af_ip6.match(line).group(1).lower()

if regex_stats.match(line):
try:
key, values = line.split(':')
Expand All @@ -155,6 +165,9 @@ def parse_neighbors(self):
except Exception as e:
print"NonFatal: line:'{}' should not have matched for sent/rcvd count".format(line)

if capabilities:
neighbor['capabilities'] = capabilities

if message_stats:
neighbor['message statistics'] = message_stats

Expand Down