fix(managed-ne): prevent ume-sync route conflicts and prefer host_name

Ensure fixed managed-ne paths are matched before /{ne_id} so deleting UME-synced NEs no longer triggers managed_ne_not_found, and use UME host_name as the synced display name to align managed NE naming with inventory host identity.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-07-02 14:24:19 +08:00
parent 3a35b54f0e
commit c5973eec69
3 changed files with 64 additions and 18 deletions

View file

@ -564,7 +564,7 @@ def sync_ume_inventory_to_managed_ne(db: Session) -> UmeManagedSyncResult:
if existing is None:
existing = db.query(ManagedNE).filter(ManagedNE.ip_address == ip).first()
device_type, vendor = _infer_managed_ne_type_vendor(str(inv.ne_type or ""), str(inv.vendor or ""))
display_name = str(inv.ne_name or "").strip() or ip
display_name = str(inv.host_name or "").strip() or str(inv.ne_name or "").strip() or ip
existing_tags = str(existing.tags or "").strip() if existing is not None else ""
if existing is None:
existing = ManagedNE(