fixed adding hosts

This commit is contained in:
Linus Vogel 2026-05-12 21:55:16 +02:00
parent a4c9bf8e6f
commit 74ec95fd9f

View File

@ -130,12 +130,9 @@ async def host_add(request: Request, fqdn: str, params: HostCreateParams):
# Traverse the parent hierarchy to ensure all components exist # Traverse the parent hierarchy to ensure all components exist
parent_id = None parent_id = None
stmt_select_respecting_parent = select(Host).where(and_(Host.name == bindparam("label"), Host.parent_id == bindparam("parent_id")))
for label in parent_labels: for label in parent_labels:
result = db.execute(stmt_select_respecting_parent, { stmt_select_respecting_parent = select(Host).where(and_(Host.name == label, Host.parent_id == parent_id))
'label': label, result = db.execute(stmt_select_respecting_parent).fetchall()
'parent_id': parent_id
}).fetchall()
if len(result) == 0: if len(result) == 0:
raise HTTPException(status_code=400, detail="Parent does not exist") raise HTTPException(status_code=400, detail="Parent does not exist")