diff options
Diffstat (limited to 'src/dashboard/admin_utils.py')
-rw-r--r-- | src/dashboard/admin_utils.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/dashboard/admin_utils.py b/src/dashboard/admin_utils.py index b105e96..045caeb 100644 --- a/src/dashboard/admin_utils.py +++ b/src/dashboard/admin_utils.py @@ -22,7 +22,8 @@ from resource_inventory.models import ( DiskProfile, CpuProfile, RamProfile, - Interface + Interface, + CloudInitFile, ) import json @@ -50,7 +51,7 @@ from booking.models import Booking from notifier.manager import NotificationHandler from api.models import JobFactory -from api.models import JobStatus +from api.models import JobStatus, Job, GeneratedCloudConfig def print_div(): @@ -528,6 +529,30 @@ def extend_booking(booking_id, days=0, hours=0, minutes=0, weeks=0): booking.save() +def regenerate_cloud_configs(booking_id): + b = Booking.objects.get(id=booking_id) + for res in b.resource.get_resources(): + res.config.cloud_init_files.set(res.config.cloud_init_files.filter(generated=False)) # careful! + res.config.save() + cif = GeneratedCloudConfig.objects.create(resource_id=res.labid, booking=b, rconfig=res.config) + cif.save() + cif = CloudInitFile.create(priority=0, text=cif.serialize()) + cif.save() + res.config.cloud_init_files.add(cif) + res.config.save() + + +def set_job_new(job_id): + j = Job.objects.get(id=job_id) + b = j.booking + regenerate_cloud_configs(b.id) + for task in j.get_tasklist(): + task.status = JobStatus.NEW + task.save() + j.status = JobStatus.NEW + j.save() + + def docs(function=None, fulltext=False): """ Print documentation for a given function in admin_utils. |