Skip to content
Snippets Groups Projects
Commit e4a82fa9 authored by Erik Reid's avatar Erik Reid
Browse files

canonify peer addresses

parent d7e2cc79
Branches
Tags
No related merge requests found
......@@ -214,7 +214,8 @@ def list_interfaces(netconf_config):
def all_bgp_peers(netconf_config):
def _peering_params(neighbor_node):
info = {'address': neighbor_node.find('name').text}
address = neighbor_node.find('name').text
info = {'address': ipaddress.ip_address(address).exploded}
peer_as = neighbor_node.find('peer-as')
if peer_as is not None:
# lxml usage warning: can't just test `if peer_as:`
......
import ipaddress
import jsonschema
from inventory_provider import juniper
......@@ -85,6 +86,12 @@ def test_bgp_peering_data(netconf_doc):
jsonschema.validate(peerings, schema)
assert peerings # there's always at least one
# confirm the addresses are in canonical (exploded) form
for p in peerings:
canonical_address = ipaddress.ip_address(p['address']).exploded
assert p['address'] == canonical_address
def test_snmp_community_string(mocked_netifaces, netconf_doc):
assert juniper.snmp_community_string(netconf_doc) == '0pBiFbD'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment