mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 15:33:18 +08:00
Allow promoting LLDP/WebCRT placeholder NEs to real device types.
Accept generic/linux on update, expose them in the device-type meta list, and auto-pick zte_zxros when vendor changes from a placeholder type. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
14251f4698
commit
48cc381afd
3 changed files with 34 additions and 6 deletions
|
|
@ -59,7 +59,10 @@ def api_list_managed_ne(
|
|||
|
||||
@router.get("/meta/device-types")
|
||||
def api_device_types():
|
||||
return {"device_types": list(SUPPORTED_DEVICE_TYPES), "vendors": list(SUPPORTED_VENDORS)}
|
||||
# Include generic/linux so LLDP/WebCRT placeholders can be edited without a bogus select value.
|
||||
from .device_types import WEBCRT_DEVICE_TYPES
|
||||
|
||||
return {"device_types": list(WEBCRT_DEVICE_TYPES), "vendors": list(SUPPORTED_VENDORS)}
|
||||
|
||||
|
||||
@router.get("/meta/credentials-configured")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from fastapi import HTTPException
|
|||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .device_types import LLDP_DISCOVERED_NE_SOURCE, SUPPORTED_DEVICE_TYPES, SUPPORTED_VENDORS
|
||||
from .device_types import LLDP_DISCOVERED_NE_SOURCE, SUPPORTED_DEVICE_TYPES, SUPPORTED_VENDORS, WEBCRT_DEVICE_TYPES
|
||||
from .models import ManagedNE
|
||||
from .ne_crypto import encrypt_secret
|
||||
from .ne_hop_templates import default_bastion_username_template, default_hop_command_template
|
||||
|
|
@ -33,6 +33,10 @@ from .ne_service_common import (
|
|||
row_to_out,
|
||||
)
|
||||
|
||||
# Inventory create stays strict; updates must also accept WebCRT/LLDP placeholder types
|
||||
# (generic/linux) so operators can open the form and promote them to zte_zxros etc.
|
||||
_ALLOWED_UPDATE_DEVICE_TYPES = frozenset(WEBCRT_DEVICE_TYPES)
|
||||
|
||||
def list_managed_ne(
|
||||
db: Session,
|
||||
*,
|
||||
|
|
@ -135,9 +139,10 @@ def update_managed_ne(db: Session, ne_id: str, body: ManagedNeUpdate) -> Managed
|
|||
raise HTTPException(status_code=400, detail="ip_address_exists")
|
||||
row.ip_address = ip
|
||||
if "device_type" in data:
|
||||
if data["device_type"] not in SUPPORTED_DEVICE_TYPES:
|
||||
dt = str(data["device_type"] or "").strip()
|
||||
if dt not in _ALLOWED_UPDATE_DEVICE_TYPES:
|
||||
raise HTTPException(status_code=400, detail="unsupported_device_type")
|
||||
row.device_type = data["device_type"]
|
||||
row.device_type = dt
|
||||
if "vendor" in data:
|
||||
v = str(data["vendor"] or "").strip()
|
||||
row.vendor = v if v in SUPPORTED_VENDORS else "Other"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue