diff --git a/pillar_tool/routers/hostgroup.py b/pillar_tool/routers/hostgroup.py index 81beee2..01486de 100644 --- a/pillar_tool/routers/hostgroup.py +++ b/pillar_tool/routers/hostgroup.py @@ -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)) - stmt = select(Host).where(and_(Host.name == bindparam('name'), Host.is_hostgroup == True, Host.parent_id == bindparam('last'))) last = None 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: # simply step down through the hierarchy