fixed hostgroup create error

This commit is contained in:
Linus Vogel 2026-06-04 21:35:45 +02:00
parent cda9df9e13
commit 3109229061

View File

@ -140,10 +140,10 @@ def hostgroup_create(req: Request, name: str, params: HostgroupParams):
print("[DEBUG] hostgroup_create: creating hostgroup hierarchy with {} label(s): {}".format(len(labels), labels)) print("[DEBUG] hostgroup_create: creating hostgroup hierarchy with {} label(s): {}".format(len(labels), labels))
stmt = select(Host).where(and_(Host.name == bindparam('name'), Host.is_hostgroup == True, Host.parent_id == bindparam('last')))
last = None last = None
for label in labels: for label in labels:
result = db.execute(stmt, {'name': label, 'last': last}).fetchall() stmt = select(Host).where(and_(Host.name == label, Host.is_hostgroup == True, Host.parent_id == last))
result = db.execute(stmt).fetchall()
if len(result) == 1: if len(result) == 1:
# simply step down through the hierarchy # simply step down through the hierarchy