Fix host saving for admin utils 58/71258/1
authorSawyer Bergeron <sbergeron@iol.unh.edu>
Thu, 15 Oct 2020 18:32:39 +0000 (14:32 -0400)
committerSawyer Bergeron <sbergeron@iol.unh.edu>
Thu, 15 Oct 2020 18:32:39 +0000 (14:32 -0400)
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Change-Id: Iff555d88b3e5489c5190e9295bef4b0e1da92b5a

src/dashboard/admin_utils.py

index 050f246..367c613 100644 (file)
@@ -58,11 +58,15 @@ def book_host(owner_username, host_labid, lab_username, hostname, image_id, temp
             host.bundle = resource_bundle
             host.config = config
             rmanager.configureNetworking(resource_bundle, host, vlan_map)
+            host.save()
         except Exception:
             host.booked = False
+            host.save()
             print("Failed to book host due to error configuring it")
             return
 
+    new_template.save()
+
     booking = Booking.objects.create(
         purpose=purpose,
         project=project,
@@ -76,6 +80,8 @@ def book_host(owner_username, host_labid, lab_username, hostname, image_id, temp
 
     booking.pdf = PDFTemplater.makePDF(booking)
 
+    booking.save()
+
     for collaborator_username in collaborator_usernames:
         try:
             user = User.objects.get(username=collaborator_username)