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

Finished feature POL1-463-multicast-subscriptions-per-hostname.

parents bf5d3627 13be8b8b
No related branches found
No related tags found
No related merge requests found
......@@ -894,13 +894,19 @@ def interface_speeds(hostname=None):
return Response(result, mimetype="application/json")
@routes.route("/eumetsat-multicast", methods=['GET', 'POST'])
MX1_FRA = 'mx1.fra.de.geant.net'
@routes.route('/eumetsat-multicast', methods=['GET', 'POST'])
@routes.route('/eumetsat-multicast/<hostname>', methods=['GET', 'POST'])
@common.require_accepts_json
def eumetsat_multicast(hostname=None):
def eumetsat_multicast(hostname=MX1_FRA):
"""
Handler for `/poller/eumetsat-multicast` which returns information about
multicast subscriptions on mx1.fra.de.geant.net.
The hostname is optional, with default value mx1.fra.de.geant.net
The response is a list of oid/router/community structures that all
all subscription octet counters to be polled.
......@@ -913,7 +919,6 @@ def eumetsat_multicast(hostname=None):
:return:
"""
MX1_FRA = 'mx1.fra.de.geant.net'
SUBSCRIPTIONS = [{
'subscription': f'232.223.222.{idx}',
'endpoint': '193.17.9.3',
......@@ -929,7 +934,7 @@ def eumetsat_multicast(hostname=None):
f'.{sub["subscription"]}.{sub["endpoint"]}'
'.255.255.255.255')
cache_key = 'classifier-cache:poller-eumetsat-multicast'
cache_key = f'classifier-cache:poller-eumetsat-multicast:{hostname}'
r = common.get_current_redis()
......@@ -937,22 +942,26 @@ def eumetsat_multicast(hostname=None):
if result:
result = result.decode('utf-8')
else:
netconf = r.get(f'netconf:{MX1_FRA}')
netconf = r.get(f'netconf:{hostname}')
if not netconf:
return Response(
status=503,
response=f'error loading netconf for {MX1_FRA}')
response=f'error loading netconf for {hostname}')
netconf_doc = etree.fromstring(netconf.decode('utf-8'))
community = juniper.snmp_community_string(netconf_doc)
if not community:
# HACKHACK: vpn source ip isn't in acl
# TODO: remove this when done testing!
community = '0pBiFbD'
if not community:
return Response(
status=503,
response=f'error extracting community string for {MX1_FRA}')
response=f'error extracting community string for {hostname}')
def _rsp_element(sub):
result = {
'router': MX1_FRA,
'router': hostname,
'oid': _oid(sub),
'community': community
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment