From e9d72ce78a85c6ff2f3f8591bcbf4115f97318d5 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Tue, 28 Sep 2021 19:11:49 -0400 Subject: Push cloud config content for generated files into userdata_raw Signed-off-by: Sawyer Bergeron Change-Id: Ieb8bd9b8b172b6bf11062f67f41fc78154cc7c89 --- src/resource_inventory/models.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/resource_inventory') 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): """ -- cgit 1.2.3-korg