From 348de4189eb1f11bfb885c0d3f081c93d3b1e71c Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sat, 23 Jan 2021 04:53:53 -0500 Subject: [PATCH] Ignore VMs that have administrator set to a deactivated user, even though that causes them to have a non-empty machine acl --- invirt-deactivate | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/invirt-deactivate b/invirt-deactivate index 2bfcb79..529d081 100644 --- a/invirt-deactivate +++ b/invirt-deactivate @@ -69,7 +69,8 @@ def main(): database.session.commit() database.session.begin() - machines_no_access = database.session.query(database.Machine).filter(~database.Machine.acl.any()).all() + acl_locker_no_err = database.session.query(database.MachineAccess.machine_id).outerjoin(Locker, database.MachineAccess.user == Locker.name).filter((Locker.type == None) | (Locker.type != "ERR")).group_by(database.MachineAccess.machine_id).subquery() + machines_no_access = database.session.query(database.Machine).outerjoin(acl_locker_no_err).filter(acl_locker_no_err.c.machine_id == None).all() machines_no_locker = database.session.query(database.Machine).join(Locker, database.Machine.owner == Locker.name).filter(Locker.type == None).all() machines_err_locker = database.session.query(database.Machine, Locker.message).join(Locker, database.Machine.owner == Locker.name).filter(Locker.type == 'ERR').all() -- 1.7.9.5