diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2019-01-03 19:23:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-01-03 19:23:29 +0000 |
commit | 5d24f164eb263239e66b3fb99782ec555523182d (patch) | |
tree | 9d44347ca8a48a2c456f4e45667f165b7f5cdd92 /dashboard | |
parent | 59a5a6e97ad86916eef9d865abccede6c5cb075e (diff) | |
parent | e1a9df21da17d34f2f9cff67e1ea965e57afd2c2 (diff) |
Merge "Improve cleanup of hosts after booking"
Diffstat (limited to 'dashboard')
-rw-r--r-- | dashboard/src/dashboard/tasks.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/dashboard/src/dashboard/tasks.py b/dashboard/src/dashboard/tasks.py index b1d97b7..67a06fd 100644 --- a/dashboard/src/dashboard/tasks.py +++ b/dashboard/src/dashboard/tasks.py @@ -14,7 +14,7 @@ from django.utils import timezone from django.db.models import Q from booking.models import Booking from notifier.manager import NotificationHandler -from api.models import JobStatus, SoftwareRelation, HostHardwareRelation, HostNetworkRelation, AccessRelation +from api.models import Job, JobStatus, SoftwareRelation, HostHardwareRelation, HostNetworkRelation, AccessRelation from resource_inventory.resource_manager import ResourceManager @@ -92,12 +92,11 @@ def free_hosts(): """ gets all hosts from the database that need to be freed and frees them """ - networks = ~Q(~Q(job__hostnetworkrelation__status=200)) - hardware = ~Q(~Q(job__hosthardwarerelation__status=200)) + undone_jobs = Job.objects.filter(hostnetworkrelation__status__ne=200, hosthardwarerelation__status__ne=200) - bookings = Booking.objects.filter( - networks, - hardware, + bookings = Booking.objects.exclude( + job_in=undone_jobs + ).filter( end__lt=timezone.now(), job__complete=True, resource__isnull=False |