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.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/api/views.py b/src/api/views.py
index a10b3ec..1516374 100644
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -295,7 +295,7 @@ def resource_ci_userdata(request, lab_name="", job_id="", resource_id="", file_i
"datasource_list": ["None"],
}
- return HttpResponse(yaml.dump(cloud_dict), status=200)
+ return HttpResponse(yaml.dump(cloud_dict, width=float("inf")), status=200)
@csrf_exempt
@@ -310,9 +310,9 @@ def resource_ci_userdata_directory(request, lab_name="", job_id="", resource_id=
files = resource.config.cloud_init_files
files = [{"id": file.id, "priority": file.priority} for file in files.order_by("priority").all()]
- d = {
- 'merge_failures': []
- }
+ d = {}
+
+ merge_failures = []
merger = Merger(
[
@@ -325,7 +325,7 @@ def resource_ci_userdata_directory(request, lab_name="", job_id="", resource_id=
for f in resource.config.cloud_init_files.order_by("priority").all():
try:
- other_dict = yaml.load(f.text)
+ other_dict = yaml.safe_load(f.text)
if not (type(d) is dict):
raise Exception("CI file was valid yaml but was not a dict")
@@ -335,9 +335,12 @@ def resource_ci_userdata_directory(request, lab_name="", job_id="", resource_id=
print("Failed to merge file in, as it had invalid content:", f.id)
print("File text was:")
print(f.text)
- d['merge_failures'].append({f.id: str(e)})
+ merge_failures.append({f.id: str(e)})
+
+ if len(merge_failures) > 0:
+ d['merge_failures'] = merge_failures
- file = CloudInitFile.create(text=yaml.dump(d), priority=0)
+ file = CloudInitFile.create(text=yaml.dump(d, width=float("inf")), priority=0)
return HttpResponse(json.dumps([{"id": file.id, "priority": file.priority}]), status=200)