Skip to content
Snippets Groups Projects
Commit 97868f60 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Remove caching for /msr/services endpoint

parent bee28384
No related branches found
No related tags found
No related merge requests found
...@@ -944,8 +944,6 @@ def get_peering_services(): ...@@ -944,8 +944,6 @@ def get_peering_services():
return Response(response, mimetype="application/json") return Response(response, mimetype="application/json")
# TODO: @functools.cache is only available in py3.9
@functools.lru_cache(maxsize=None)
def _load_all_interfaces(): def _load_all_interfaces():
""" """
loads all ip interfaces in the network and returns as a dict loads all ip interfaces in the network and returns as a dict
...@@ -972,8 +970,6 @@ def _load_all_interfaces(): ...@@ -972,8 +970,6 @@ def _load_all_interfaces():
return result return result
# TODO: @functools.cache is only available in py3.9
@functools.lru_cache(maxsize=None)
def _load_redundant_access_peers(): def _load_redundant_access_peers():
""" """
load all peers that should be considered load all peers that should be considered
...@@ -997,7 +993,7 @@ def _load_redundant_access_peers(): ...@@ -997,7 +993,7 @@ def _load_redundant_access_peers():
return result return result
def _ip_endpoint_extractor(endpoint_details: dict): def _ip_endpoint_extractor(all_interfaces: Dict, endpoint_details: Dict):
""" """
special-purpose method used only by _endpoint_extractor special-purpose method used only by _endpoint_extractor
...@@ -1019,7 +1015,6 @@ def _ip_endpoint_extractor(endpoint_details: dict): ...@@ -1019,7 +1015,6 @@ def _ip_endpoint_extractor(endpoint_details: dict):
'interface': interface, 'interface': interface,
} }
all_interfaces = _load_all_interfaces()
# sanity: should have already been checked # sanity: should have already been checked
assert hostname in all_interfaces assert hostname in all_interfaces
...@@ -1039,7 +1034,7 @@ def _ip_endpoint_extractor(endpoint_details: dict): ...@@ -1039,7 +1034,7 @@ def _ip_endpoint_extractor(endpoint_details: dict):
return ip_endpoint return ip_endpoint
def _endpoint_extractor(endpoint_details: Dict): def _endpoint_extractor(all_interfaces: Dict, endpoint_details: Dict):
""" """
special-purpose method used only by get_system_correlation_services special-purpose method used only by get_system_correlation_services
...@@ -1057,9 +1052,9 @@ def _endpoint_extractor(endpoint_details: Dict): ...@@ -1057,9 +1052,9 @@ def _endpoint_extractor(endpoint_details: Dict):
return return
potential_hostname = ims_equipment_to_hostname( potential_hostname = ims_equipment_to_hostname(
endpoint_details['equipment']) endpoint_details['equipment'])
all_routers = _load_all_interfaces().keys() all_routers = all_interfaces.keys()
if potential_hostname in all_routers: if potential_hostname in all_routers:
return _ip_endpoint_extractor(endpoint_details) return _ip_endpoint_extractor(all_interfaces, endpoint_details)
else: else:
return { return {
'equipment': endpoint_details['equipment'], 'equipment': endpoint_details['equipment'],
...@@ -1107,6 +1102,8 @@ def get_system_correlation_services(): ...@@ -1107,6 +1102,8 @@ def get_system_correlation_services():
response = _ignore_cache_or_retrieve(request, cache_key, r) response = _ignore_cache_or_retrieve(request, cache_key, r)
if not response: if not response:
all_interfaces = _load_all_interfaces()
sid_services = json.loads(r.get('ims:sid_services').decode('utf-8')) sid_services = json.loads(r.get('ims:sid_services').decode('utf-8'))
response = [] response = []
...@@ -1123,7 +1120,7 @@ def get_system_correlation_services(): ...@@ -1123,7 +1120,7 @@ def get_system_correlation_services():
service_info['service_type'] = d['service_type'] service_info['service_type'] = d['service_type']
service_info['customer'] = d['customer'] service_info['customer'] = d['customer']
endpoint = _endpoint_extractor(d) endpoint = _endpoint_extractor(all_interfaces, d)
if endpoint: if endpoint:
service_info['endpoints'].append(endpoint) service_info['endpoints'].append(endpoint)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment