Skip to content
Snippets Groups Projects
Commit 4b880f6c authored by Sam Roberts's avatar Sam Roberts
Browse files

minor improvements based on MR feedback

parent 676d1371
No related branches found
No related tags found
1 merge request!2Feature/reporting 307 msr vpn proxy endpoint
......@@ -1045,22 +1045,19 @@ def mdvpn():
yield formatted_peering
def _vpnrr_peerings(asn, vpnrr_index):
if asn in vpnrr_index:
vrr_peering_group = vpnrr_index[asn]
# rearrange into index using ipv4 as key
# this will collect related entries under the same ipv4
ip_index = _make_group_index(vrr_peering_group, 'address')
for ip in ip_index:
ip_details = ip_index[ip] # a list of all info for given ipv4
hostnames = [item['hostname'] for item in ip_details]
description = ip_details[0]['description']
# rearrange into index using ipv4 as key
# this will collect related entries under the same ipv4
ip_index = _make_group_index(vpnrr_index.get(asn, []), 'address')
for ip, ip_details in ip_index.items():
hostnames = [item['hostname'] for item in ip_details]
description = ip_details[0]['description']
formatted_peering = {
"description": _get_consistent_description(description),
"v4": ip,
"hostname": hostnames
}
yield formatted_peering
formatted_peering = {
"description": _get_consistent_description(description),
"v4": ip,
"hostname": hostnames
}
yield formatted_peering
def _peerings_for_nren(asn, bgplu_index, vpnrr_index):
return {
......@@ -1166,8 +1163,6 @@ def vpn_proxy():
"v4": peering.get("address")
}
yield formatted_peering
else:
yield False
r = common.get_current_redis()
cache_key = 'classifier-cache:msr:vpn-proxy'
......@@ -1175,6 +1170,6 @@ def vpn_proxy():
if not response:
vpnproxy = json.loads(
r.get('juniper-peerings:logical-system:VPN-PROXY').decode('utf-8'))
peerings = list(filter(None, _format_peerings(vpnproxy)))
peerings = list(_format_peerings(vpnproxy))
response = json.dumps(peerings)
return Response(response, mimetype='application/json')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment