A
0be02bd1f4
- Fix FileNotFoundError when database.path has no directory component (os.makedirs(os.path.dirname(path)) with path="subscribers.db" raised). Add ensure_parent_dir helper; use it in app.py and scripts/init_db.py. - Open5GS/free5gc adapters now use profile.apn for the core session/DNN name instead of a hardcoded "internet"; apn is threaded through get_adapter. Tests: +4 (ensure_parent_dir, adapter APN); 82 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
746 B
Python
21 lines
746 B
Python
from .base import CoreAdapter
|
|
from typing import Optional
|
|
|
|
|
|
def get_adapter(config: dict) -> Optional[CoreAdapter]:
|
|
"""Factory: return the configured core adapter, or None for export-only mode."""
|
|
core_cfg = config.get("core", {})
|
|
core_type = core_cfg.get("type", "none")
|
|
uri = core_cfg.get("mongodb_uri", "mongodb://localhost:27017")
|
|
db_name = core_cfg.get("database_name", "open5gs")
|
|
apn = config.get("profile", {}).get("apn", "internet")
|
|
|
|
if core_type == "open5gs":
|
|
from .open5gs import Open5GSAdapter
|
|
return Open5GSAdapter(uri, db_name, apn)
|
|
elif core_type == "free5gc":
|
|
from .free5gc import Free5GCAdapter
|
|
return Free5GCAdapter(uri, db_name, apn)
|
|
else:
|
|
return None
|