delete now delete the whole pillar subtree when deleting a non-leaf pillar name
This commit is contained in:
parent
29e18956da
commit
147d48d882
@ -4,7 +4,7 @@ from uuid import uuid4
|
|||||||
|
|
||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql
|
||||||
from sqlalchemy.dialects.postgresql import insert
|
from sqlalchemy.dialects.postgresql import insert
|
||||||
from sqlalchemy import select, delete, bindparam, and_
|
from sqlalchemy import select, delete, bindparam, and_, or_
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
@ -184,8 +184,7 @@ def pillar_delete(req: Request, name: str, params: PillarParams):
|
|||||||
'message': "Either Host or Hostgroup needs to be set!"
|
'message': "Either Host or Hostgroup needs to be set!"
|
||||||
})
|
})
|
||||||
|
|
||||||
# TODO: make this delete recursive
|
delete_stmt = delete(Pillar).where(and_(Pillar.host_id == target.id, or_(Pillar.pillar_name == name, Pillar.pillar_name.like(f"{name}:%"))))
|
||||||
delete_stmt = delete(Pillar).where(and_(Pillar.host_id == target.id, Pillar.pillar_name == name))
|
|
||||||
result = db.execute(delete_stmt)
|
result = db.execute(delete_stmt)
|
||||||
|
|
||||||
return JSONResponse(status_code=200, content={'message': 'ok'})
|
return JSONResponse(status_code=200, content={'message': 'ok'})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user