From e356dffc86f67ad1cd947274d38b699cd04856a7 Mon Sep 17 00:00:00 2001 From: oliver Date: Thu, 6 Aug 2026 15:29:36 +0800 Subject: [PATCH] Fix missing imports after UME router split. Restore sqlalchemy.func and runtime helpers so alarms_current upsert and pause/resume no longer raise NameError 500s. Co-authored-by: Cursor --- netx_api/ume_alarm_apply.py | 1 + netx_api/ume_alarms_router.py | 3 ++ netx_api/ume_inventory_router.py | 2 +- netx_api/ume_key_alert_router.py | 2 +- netx_api/ume_sync_router.py | 51 +++++++------------------------- netx_api/ume_token_router.py | 1 + 6 files changed, 18 insertions(+), 42 deletions(-) diff --git a/netx_api/ume_alarm_apply.py b/netx_api/ume_alarm_apply.py index 16da957..2dcd25b 100644 --- a/netx_api/ume_alarm_apply.py +++ b/netx_api/ume_alarm_apply.py @@ -9,6 +9,7 @@ import time from datetime import datetime from typing import Any +from sqlalchemy import func from sqlalchemy.dialects.postgresql import insert as pg_insert from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import Session diff --git a/netx_api/ume_alarms_router.py b/netx_api/ume_alarms_router.py index f94e93c..28583eb 100644 --- a/netx_api/ume_alarms_router.py +++ b/netx_api/ume_alarms_router.py @@ -53,6 +53,9 @@ from .ume_support import ( _aggregate_rows, _ensure_utc, _list_runtime_tasks, + _normalize_netx_lang, + _parse_time, + _protocol_bucket_label, _request_force_sync_after_resume, _runtime_pause_task, _runtime_resume_task, diff --git a/netx_api/ume_inventory_router.py b/netx_api/ume_inventory_router.py index bd67b81..b98c113 100644 --- a/netx_api/ume_inventory_router.py +++ b/netx_api/ume_inventory_router.py @@ -6,7 +6,7 @@ from datetime import datetime, timezone from typing import Any from fastapi import APIRouter, Depends, HTTPException, Query -from sqlalchemy import or_ +from sqlalchemy import func, or_ from sqlalchemy.orm import Session from .config import settings diff --git a/netx_api/ume_key_alert_router.py b/netx_api/ume_key_alert_router.py index 20d33c7..6e2da2f 100644 --- a/netx_api/ume_key_alert_router.py +++ b/netx_api/ume_key_alert_router.py @@ -6,7 +6,7 @@ from datetime import datetime, timezone from typing import Any from fastapi import APIRouter, Depends, HTTPException, Query -from sqlalchemy import or_ +from sqlalchemy import func, or_ from sqlalchemy.orm import Session from .config import settings diff --git a/netx_api/ume_sync_router.py b/netx_api/ume_sync_router.py index 3c19641..dc8d189 100644 --- a/netx_api/ume_sync_router.py +++ b/netx_api/ume_sync_router.py @@ -1,69 +1,40 @@ """UME sync jobs and runtime pause/resume.""" from __future__ import annotations +import json import logging from datetime import datetime, timezone from typing import Any from fastapi import APIRouter, Depends, HTTPException, Query -from sqlalchemy import or_ from sqlalchemy.orm import Session -from .config import settings from .db import get_db -from .key_alert_config import ( - get_key_alert_monitor_config, - invalidate_key_alert_config_cache, - set_key_alert_monitor_config, -) -from .key_alert_matcher import ( - invalidate_key_alert_rule_cache, - normalize_match_type, - parse_rule_ne_types_payload, - rule_match_type, - rule_match_value, - rule_ne_types, - rule_storage_key, - serialize_rule_ne_types, -) -from .models import ( - UmeAlarmCurrent, - UmeAlarmHistory, - UmeInventoryNE, - UmeKeyAlertForwardLog, - UmeKeyAlertRule, - UmeSyncJob, -) -from .oclaw_alarm_forwarder import ( - forwarder_status, - request_forwarder_reconnect, +from .models import UmeSyncJob +from .oclaw_alarm_forwarder import request_forwarder_reconnect +from .runtime_task_messages import ( + RT_RESUMED, + RT_RESUMED_OCLAW_WSS_RECONNECT, + RT_RESUMED_SYNC_SOON, + RT_RESUMED_WSS_RECONNECT, ) from .ume_alarm_ws import ( - cancel_alarm_subscription_manual, - clear_local_alarm_subscription_manual, - establish_alarm_subscription_manual, - get_alarms_coordination_status, get_subscription_status, - get_ws_connection_status, - get_ws_logs, + is_wss_active_for_current_alarms, request_ws_reconnect, ) from .ume_support import ( UME_KNOWN_RUNTIME_TASKS, - _aggregate_rows, + _clear_force_resume_hints, _ensure_utc, _list_runtime_tasks, _request_force_sync_after_resume, _runtime_pause_task, _runtime_resume_task, - _ume_alarm_host_name, - _ume_alarm_ne_group_key, + _set_runtime_task, _ume_client, - _ume_error_kind, - _clear_force_resume_hints, ) from .ume_sync_service import sync_alarms_current, sync_alarms_history_full, sync_inventory_full -from .ume_token_store import clear_shared_token _log = logging.getLogger("netx.ume.router") router = APIRouter(tags=["ume"]) diff --git a/netx_api/ume_token_router.py b/netx_api/ume_token_router.py index e3f7821..b3daec8 100644 --- a/netx_api/ume_token_router.py +++ b/netx_api/ume_token_router.py @@ -50,6 +50,7 @@ from .ume_alarm_ws import ( ) from .ume_support import ( UME_KNOWN_RUNTIME_TASKS, + _UME_RUNTIME_TASKS, _aggregate_rows, _ensure_utc, _list_runtime_tasks,