diff --git a/inventory_provider/juniper.py b/inventory_provider/juniper.py index 6208546adef774b4b95635174029ceee7014f380..ea98adb8b8f97e7f1400e6a7ea7f392a0e937cba 100644 --- a/inventory_provider/juniper.py +++ b/inventory_provider/juniper.py @@ -275,6 +275,20 @@ def ix_public_peers(netconf_config): } +def vpn_rr_peers(netconf_config): + for r in netconf_config.xpath( + '//configuration/logical-systems[name/text()="VRR"]/' + '/protocols/bgp/' + 'group[name/text()="VPN-RR" or name/text()="VPN-RR-INTERNAL"]/' + 'neighbor'): + name = r.find('name') + yield { + 'name': ipaddress.ip_address(name.text).exploded, + 'description': r.find('description').text, + 'peer-as': int(r.find('peer-as').text) + } + + # note for enabling vrr data parsing ... # def fetch_vrr_config(hostname, ssh_params): # diff --git a/test/test_ix_public_peers.py b/test/test_ix_public_peers.py index 75131a9f0c8160b73443f56f9006c57b5571b3e5..334de18b4dc3b8255ef4ca8331e7773ac290b270 100644 --- a/test/test_ix_public_peers.py +++ b/test/test_ix_public_peers.py @@ -12,7 +12,8 @@ TEST_DATA_DIRNAME = os.path.realpath(os.path.join( 'test', 'data')) -ROUTER_NAME = 'mx1.vie.at.geant.net' +# ROUTER_NAME = 'mx1.vie.at.geant.net' +ROUTER_NAME = 'mx2.lju.si.geant.net' @pytest.fixture @@ -56,3 +57,9 @@ def test_ix_public_peers(netconf): for p in juniper.ix_public_peers(netconf): jsonschema.validate(p, schema) + + +def test_vpn_rr_peers(netconf): + for p in juniper.vpn_rr_peers(netconf): + print(p) + # jsonschema.validate(p, schema)