mirror of
https://github.com/hansjone/netx.git
synced 2026-10-17 17:03:27 +08:00
Add biz_state monitoring with shared LLDP parse and batch collect.
Introduce ParseProfile-based business state tasks that reuse LLDP parsing for snapshot batches (separate from topology Fabric writes), with scheduler, export, and a Phase1 UI under network tasks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
066158d2f7
commit
4fa1b9b4dc
27 changed files with 2487 additions and 1 deletions
27
netx_api/biz_state/schema_ensure.py
Normal file
27
netx_api/biz_state/schema_ensure.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Idempotent DDL safety-net for biz_state tables (create_all + ADD COLUMN)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy.engine import Connection
|
||||
|
||||
from ..schema_patches import _run_sql
|
||||
|
||||
_log = logging.getLogger("netx.biz_state.schema")
|
||||
|
||||
|
||||
def apply_biz_state_schema(conn: Connection) -> None:
|
||||
"""Ensure core tables exist; create_all usually handles this — safety net for brownfield."""
|
||||
# Tables are defined on ORM Base; create_all covers new installs.
|
||||
# Keep lightweight indexes that older DBs might miss.
|
||||
for sql in (
|
||||
"CREATE INDEX IF NOT EXISTS ix_biz_state_task_status ON biz_state_task (status)",
|
||||
"CREATE INDEX IF NOT EXISTS ix_biz_state_batch_task_id ON biz_state_batch (task_id)",
|
||||
"CREATE INDEX IF NOT EXISTS ix_biz_state_batch_command_batch_id ON biz_state_batch_command (batch_id)",
|
||||
"CREATE INDEX IF NOT EXISTS ix_biz_state_lldp_neighbor_batch_id ON biz_state_lldp_neighbor (batch_id)",
|
||||
):
|
||||
try:
|
||||
_run_sql(conn, sql)
|
||||
except Exception:
|
||||
_log.debug("biz_state schema patch skipped: %s", sql[:80], exc_info=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue