aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/views.py')
-rw-r--r--src/api/views.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/api/views.py b/src/api/views.py
index 84d19cc..a10b3ec 100644
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -606,6 +606,25 @@ def all_users(request):
return JsonResponse(users, safe=False)
+def create_ci_file(request):
+ token = auth_and_log(request, 'booking/makeCloudConfig')
+
+ if isinstance(token, HttpResponse):
+ return token
+
+ try:
+ cconf = request.body
+ d = yaml.load(cconf)
+ if not (type(d) is dict):
+ raise Exception()
+
+ cconf = CloudInitFile.create(text=cconf, priority=CloudInitFile.objects.count())
+
+ return JsonResponse({"id": cconf.id})
+ except Exception:
+ return JsonResponse({"error": "Provided config file was not valid yaml or was not a dict at the top level"})
+
+
"""
Lab API Views
"""