path: root/dashboard
diff options
authorParker Berberian <>2019-01-02 13:59:39 -0500
committerParker Berberian <>2019-01-02 13:59:39 -0500
commite1a9df21da17d34f2f9cff67e1ea965e57afd2c2 (patch)
tree26976e34cdb3e3fdc72038b8517232e37c93dfd3 /dashboard
parentb52a1950816ebafa3c461221bf824aff950b9e1f (diff)
Improve cleanup of hosts after booking
Previously, the database query was not reliably detecting hosts which were to be released and made available for new bookings. This should now take all bookings that are over and have been cleaned by the lab, and make the hosts available for reuse. Change-Id: I040c2e02ac48d7bfde3fc1cf6bac4e59a48c8933 Signed-off-by: Parker Berberian <>
Diffstat (limited to 'dashboard')
1 files changed, 5 insertions, 6 deletions
diff --git a/dashboard/src/dashboard/ b/dashboard/src/dashboard/
index b1d97b7..67a06fd 100644
--- a/dashboard/src/dashboard/
+++ b/dashboard/src/dashboard/
@@ -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(,