Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ansible/library/bgp_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def collect_neighbors(self):

def parse_neighbors(self):

regex_ip = re.compile(r'^BGP neighbor is (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')
regex_ip = re.compile(r'^BGP neighbor is (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[0-9a-fA-F:]+)')
regex_remote_as = re.compile(r'.*remote AS (\d+)')
regex_local_as = re.compile(r'.*local AS (\d+)')
regex_desc = re.compile(r'.*Description: (.*)')
Expand All @@ -113,7 +113,7 @@ def parse_neighbors(self):
lines = n.splitlines()

for line in lines:
if regex_ip.match(line): neighbor_ip = regex_ip.match(line).group(1)
if regex_ip.match(line): neighbor_ip = regex_ip.match(line).group(1).lower()
if regex_remote_as.match(line): neighbor['remote AS'] = int(regex_remote_as.match(line).group(1))
if regex_local_as.match(line): neighbor['local AS'] = int(regex_local_as.match(line).group(1))
if regex_desc.match(line): neighbor['description'] = regex_desc.match(line).group(1)
Expand Down
12 changes: 6 additions & 6 deletions ansible/roles/test/tasks/bgp_fact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

- name: Verify bgp sessions are established
assert: { that: "'{{ bgp_neighbors[item]['state'] }}' == 'established'" }
with_items: bgp_neighbors.keys()
with_items: "{{ bgp_neighbors.keys() }}"

- name: Verify locat ASNs in bgp sessions
assert: { that: "'{{ bgp_neighbors[item]['local AS'] }}' == '{{ minigraph_bgp_asn }}'" }
with_items: bgp_neighbors.keys()
with_items: "{{ bgp_neighbors.keys() }}"

- name: Compare the bgp neighbors name with minigraph bgp neigbhors name
assert: { that: "'{{ item['name'] }}' == '{{ bgp_neighbors[item['addr']]['description'] }}'" }
with_items: minigraph_bgp
assert: { that: "'{{ item['name'] }}' == '{{ bgp_neighbors[item['addr'].lower()]['description'] }}'" }
with_items: "{{ minigraph_bgp }}"

- name: Compare the bgp neighbors ASN with minigraph
assert: { that: "'{{ item['asn'] }}' == '{{ bgp_neighbors[item['addr']]['remote AS'] }}'" }
with_items: minigraph_bgp
assert: { that: "'{{ item['asn'] }}' == '{{ bgp_neighbors[item['addr'].lower()]['remote AS'] }}'" }
with_items: "{{ minigraph_bgp }}"