diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-06-08 11:15:56 -0400 |
---|---|---|
committer | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-06-14 11:22:47 -0400 |
commit | a908da441bf6efcdb289a46d0c2761840138b1a5 (patch) | |
tree | c4dfe2823275249309ead57696b976dffacebd9c /src/api/views.py | |
parent | 8086a7aa9aa95d5af341b67cba85b1377a168b98 (diff) |
Draft for cloud-init file generation
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Change-Id: I07f3a4a1ab67531cba2cc7e3de22e9bb860706e1
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src/api/views.py')
-rw-r--r-- | src/api/views.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/api/views.py b/src/api/views.py index 2e5f33f..3a3effa 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -25,7 +25,7 @@ from api.serializers.old_serializers import UserSerializer from api.forms import DowntimeForm from account.models import UserProfile from booking.models import Booking -from api.models import LabManagerTracker, get_task +from api.models import LabManagerTracker, get_task, CloudInitFile from notifier.manager import NotificationHandler from analytics.models import ActiveVPNUser import json @@ -166,6 +166,21 @@ def specific_job(request, lab_name="", job_id=""): return JsonResponse(lab_manager.update_job(job_id, request.POST), safe=False) return JsonResponse(lab_manager.get_job(job_id), safe=False) +@csrf_exempt +def resource_cidata(request, lab_name="", job_id="", resource_id=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + + job = lab_manager.get_job(job_id) + + cifile = None + try: + cifile = CloudInitFile.get(job.booking.id, resource_id) + except ObjectDoesNotExist: + return HttpResponseNotFound("Could not find a matching resource by id " + str(resource_id)) + + return HttpResponse(cifile.serialize(), status=200) + def new_jobs(request, lab_name=""): lab_token = request.META.get('HTTP_AUTH_TOKEN') |