Compare commits

...

5 Commits
v0.2 ... main

3 changed files with 10 additions and 10 deletions

View File

@ -13,12 +13,12 @@ def get_pillar_name_sequence(name: str) -> list[str]:
def decode_pillar_value(pillar: Pillar) -> str | int | float | bool | list | dict: def decode_pillar_value(pillar: Pillar) -> str | int | float | bool | list | dict:
match pillar.parameter_type: match pillar.parameter_type:
case 'string': return str(pillar.value) case 'string': return str(json.loads(pillar.value))
case 'integer': return int(pillar.value) case 'integer': return int(json.loads(pillar.value))
case 'float': return float(pillar.value) case 'float': return float(json.loads(pillar.value))
case 'boolean': return bool(pillar.value) case 'boolean': return bool(json.loads(pillar.value))
case 'array': return json.loads(pillar.value) case 'list': return list(json.loads(pillar.value))
case 'dict': return json.loads(pillar.value) case 'dict': return dict(json.loads(pillar.value))
raise RuntimeError(f"Failed to decode pillar value: Invalid type '{pillar.parameter_type}'") raise RuntimeError(f"Failed to decode pillar value: Invalid type '{pillar.parameter_type}'")
@ -43,6 +43,6 @@ def get_pillar_for_target(db: Session, target: UUID) -> dict:
current[label] = {} current[label] = {}
current = current[label] current = current[label]
else: else:
current[label] = json.loads(str(value)) current[label] = value
return out return out

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

View File

@ -1,6 +1,6 @@
[project] [project]
name = "pillartool" name = "pillartool"
version = "0.1.0" version = "0.6.0"
description = "Add your description here" description = "Add your description here"
requires-python = ">=3.13" requires-python = ">=3.13"
dependencies = [ dependencies = [