diff --git a/mapping_provider/api/map.py b/mapping_provider/api/map.py index b42956bc1315927f3cecd4209b6074028423d702..5e2ee9b5ab5bc21c2438af7c9a6d92bcfb868572 100644 --- a/mapping_provider/api/map.py +++ b/mapping_provider/api/map.py @@ -139,7 +139,7 @@ def get_pops() -> PopList: city=pop_dict['city'], country=pop_dict['country'], ) - return PopList(pops=map(_make_pop, pop_list_obj)) + return PopList(pops=list(map(_make_pop, pop_list_obj))) @router.get("/equipment") @@ -163,7 +163,7 @@ def get_equipment() -> EquipmentList: pop=equipment_dict['pop'], status=equipment_dict['status'], ) - return EquipmentList(equipment=map(_make_equipment, equipment_list_obj)) + return EquipmentList(equipment=list(map(_make_equipment, equipment_list_obj))) @router.get("/trunks") diff --git a/mapping_provider/backends/inventory.py b/mapping_provider/backends/inventory.py index 6409cfaa3bcb6cbeffc30822c77df090f77e4c7c..459af846cda2dae7a49812db120cb9136c4a59ae 100644 --- a/mapping_provider/backends/inventory.py +++ b/mapping_provider/backends/inventory.py @@ -1,10 +1,10 @@ import concurrent.futures -import jsonschema import logging import time from threading import Event from typing import Any +import jsonschema import requests from . import cache diff --git a/mapping_provider/backends/services.py b/mapping_provider/backends/services.py index 124d9676d824ed6c57c3a09384dcd48421fc5d0e..b8f2cefb90b794535da04abbe5af1596d1dbf7cf 100644 --- a/mapping_provider/backends/services.py +++ b/mapping_provider/backends/services.py @@ -1,7 +1,7 @@ import functools import logging -from collections.abc import Generator import re +from collections.abc import Generator from typing import Any from pydantic import BaseModel @@ -36,9 +36,10 @@ class Service(BaseModel): class ServiceList(BaseModel): services: list[Service] -def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: list[dict[str, str]]) -> str: + +def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: dict[str, dict[str, Any]]) -> str: - def _hostname_to_equipment(_hn): + def _hostname_to_equipment(_hn: str) -> str: m = re.match(r'^(.+)\.geant\.net$', _hn) if not m: logger.error(f'unexpected hostname pattern: {_hn}') @@ -58,9 +59,9 @@ def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: list[dict[s logger.error(f'unknown endpoint equipment: {eq_name}') return '?' - return inprov_equipment_dict[eq_name]['pop'] - - + pop_name = inprov_equipment_dict[eq_name]['pop'] + assert isinstance(pop_name, str) # mypy noise + return pop_name def _services(service_type: str | None = None) -> Generator[Service]: