aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2021-09-28 19:11:49 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2021-09-28 19:11:49 -0400
commite9d72ce78a85c6ff2f3f8591bcbf4115f97318d5 (patch)
tree7d3ee1084b86a102d74af4e5eb494606da5df1bc /src/resource_inventory
parent95d39c60f7e8062cabc8c1665080a2d2c8904234 (diff)
Push cloud config content for generated files into userdata_raw
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu> Change-Id: Ieb8bd9b8b172b6bf11062f67f41fc78154cc7c89
Diffstat (limited to 'src/resource_inventory')
-rw-r--r--src/resource_inventory/models.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index 1505f02..941c38f 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -18,6 +18,7 @@ import json
import yaml
import re
+import uuid
from collections import Counter
from account.models import Lab
@@ -171,7 +172,19 @@ class CloudInitFile(models.Model):
prepended_text = "#cloud-config\n"
prepended_text = prepended_text + yaml.dump(CloudInitFile.merge_strategy()) + "\n"
print("in cloudinitfile create")
- return CloudInitFile.objects.create(priority=priority, text=(prepended_text + text))
+ text = prepended_text + text
+ cloud_dict = {
+ "datasource": {
+ "None": {
+ "metadata": {
+ "instance-id": str(uuid.uuid4())
+ },
+ "userdata_raw": text,
+ },
+ },
+ "datasource_list": ["None"],
+ }
+ return CloudInitFile.objects.create(priority=priority, text=json.dumps(cloud_dict))
class ResourceTemplate(models.Model):
"""