2626 CURRENT_CONFIG_FILE ,
2727 SECRETS_DIR ,
2828 SUPPORTED_MODELS ,
29+ CREATE_MONITOR_PAIRS_DEFAULT ,
30+ CREATE_MONITOR_PAIRS_UNINIT ,
2931)
3032from wlanpi_core .core .config import endpoints , settings
3133from wlanpi_core .core .database import DatabaseError , DatabaseManager
3537from wlanpi_core .core .system import SystemManager
3638from wlanpi_core .core .token import TokenManager
3739from wlanpi_core .services .system_service import get_model
38- from wlanpi_core .utils .network_config import activate_config , get_current_config
40+ from wlanpi_core .utils .network_config import activate_config , get_current_config , interfaces_in_root
3941from wlanpi_core .views .api import router as views_router
4042
4143
@@ -330,12 +332,13 @@ async def initialize_components(self):
330332 self .log .info (f"Default config activated sucessfully" )
331333
332334
333- system_initialized = await self ._initialize_system_manager ("wlanpi" )
334- if not system_initialized :
335- self .log .error (
336- "System manager initialization failed - cannot proceed"
337- )
338- return False
335+ if CREATE_MONITOR_PAIRS_DEFAULT :
336+ system_initialized = await self ._initialize_system_manager ("wlanpi" , exclusions = [])
337+ if not system_initialized :
338+ self .log .error (
339+ "System manager initialization failed - cannot proceed"
340+ )
341+ return False
339342 else :
340343 model = get_model ()
341344 if model not in SUPPORTED_MODELS :
@@ -351,6 +354,14 @@ async def initialize_components(self):
351354
352355 else :
353356 self .log .info (f"Default config activated sucessfully" )
357+
358+ if CREATE_MONITOR_PAIRS_DEFAULT :
359+ system_initialized = await self ._initialize_system_manager ("wlanpi" , exclusions = [])
360+ if not system_initialized :
361+ self .log .error (
362+ "System manager initialization failed - cannot proceed"
363+ )
364+ return False
354365 else :
355366 self .log .info (
356367 f"Activating current network configuration: { current_config } "
@@ -363,6 +374,15 @@ async def initialize_components(self):
363374 )
364375 else :
365376 self .log .info (f"Config { current_config } activated sucessfully" )
377+
378+ if CREATE_MONITOR_PAIRS_UNINIT :
379+ exclusions = interfaces_in_root (current_config )
380+ system_initialized = await self ._initialize_system_manager ("wlanpi" , exclusions = [])
381+ if not system_initialized :
382+ self .log .error (
383+ "System manager initialization failed - cannot proceed"
384+ )
385+ return False
366386
367387 except FileNotFoundError :
368388 self .log .warning ("No current network configuration found" )
@@ -445,10 +465,10 @@ async def _initialize_token_manager(self):
445465 self .log .error (f"Token manager initialization failed: { e } " )
446466 return False
447467
448- async def _initialize_system_manager (self , iface_name : str ):
468+ async def _initialize_system_manager (self , iface_name : str , exclusions : list [ str ] = [] ):
449469 """Initialize the system manager"""
450470 try :
451- self .app .state .system_manager = SystemManager (iface_name )
471+ self .app .state .system_manager = SystemManager (iface_name , exclusions = exclusions )
452472 self .log .debug ("System manager initialized succcessfully" )
453473 return True
454474 except Exception as e :
0 commit comments