aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/models.py45
-rw-r--r--src/api/views.py12
-rw-r--r--src/booking/quick_deployer.py1
-rw-r--r--src/templates/base/dashboard/searchable_select_multiple.html2
-rw-r--r--src/templates/lfedge/booking/quick_deploy.html8
5 files changed, 52 insertions, 16 deletions
diff --git a/src/api/models.py b/src/api/models.py
index 1f03deb..3b36b68 100644
--- a/src/api/models.py
+++ b/src/api/models.py
@@ -376,7 +376,9 @@ class GeneratedCloudConfig(models.Model):
"""
returns the dictionary to be placed behind the `users` field of the toplevel c-i dict
"""
+ # conserves distro default user
user_array = ["default"]
+
users = list(self.booking.collaborators.all())
users.append(self.booking.owner)
for collaborator in users:
@@ -392,16 +394,39 @@ class GeneratedCloudConfig(models.Model):
user_array.append(userdict)
- user_array.append({
- "name": "opnfv",
- "plain_text_passwd": "OPNFV_HOST",
- "ssh_redirect_user": True,
- "sudo": "ALL=(ALL) NOPASSWD:ALL",
- "groups": "sudo",
- })
+ #user_array.append({
+ # "name": "opnfv",
+ # "passwd": "$6$k54L.vim1cLaEc4$5AyUIrufGlbtVBzuCWOlA1yV6QdD7Gr2MzwIs/WhuYR9ebSfh3Qlb7djkqzjwjxpnSAonK1YOabPP6NxUDccu.",
+ # "ssh_redirect_user": True,
+ # "sudo": "ALL=(ALL) NOPASSWD:ALL",
+ # "groups": "sudo",
+ # })
return user_array
+ # TODO: make this configurable
+ def _serialize_sysinfo(self):
+ defuser = {}
+ defuser['name'] = 'opnfv'
+ defuser['plain_text_passwd'] = 'OPNFV_HOST'
+ defuser['home'] = '/home/opnfv'
+ defuser['shell'] = '/bin/bash'
+ defuser['lock_passwd'] = True
+ defuser['gecos'] = 'Lab Manager User'
+ defuser['groups'] = 'sudo'
+
+ return { 'default_user': defuser }
+
+ # TODO: make this configurable
+ def _serialize_runcmds(self):
+ cmdlist = [ ]
+
+ # have hosts run dhcp on boot
+ cmdlist.append(['sudo', 'dhclient', '-r'])
+ cmdlist.append(['sudo', 'dhclient'])
+
+ return cmdlist
+
def _serialize_netconf_v1(self):
interfaces = {} # map from iface_name => dhcp_config
#vlans = {} # map from vlan_id => dhcp_config
@@ -468,6 +493,12 @@ class GeneratedCloudConfig(models.Model):
main_dict['network'] = self._serialize_netconf_v1()
main_dict['hostname'] = self.rconfig.name
+ # add first startup commands
+ main_dict['runcmd'] = self._serialize_runcmds()
+
+ # configure distro default user
+ main_dict['system_info'] = self._serialize_sysinfo()
+
return main_dict
def serialize(self) -> str:
diff --git a/src/api/views.py b/src/api/views.py
index 5af3d69..13bf1dd 100644
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -37,6 +37,8 @@ from resource_inventory.models import (
)
import json
+import yaml
+import uuid
from deepmerge import Merger
"""
@@ -309,19 +311,19 @@ def resource_ci_userdata_directory(request, lab_name="", job_id="", resource_id=
["override"], # if types conflict (shouldn't happen in CI, but handle case)
)
- for file in files.order_by("priority").all():
+ for f in resource.config.cloud_init_files.order_by("priority").all():
try:
- other_dict = yaml.load(file.text)
+ other_dict = yaml.load(f.text)
if not (type(d) is dict):
raise Exception("CI file was valid yaml but was not a dict")
merger.merge(d, other_dict)
except Exception as e:
# if fail to merge, then just skip
- print("Failed to merge file in, as it had invalid content:", file.id)
+ print("Failed to merge file in, as it had invalid content:", f.id)
print("File text was:")
- print(file.text)
- d['merge_failures'].append({file.id: str(e)})
+ print(f.text)
+ d['merge_failures'].append({f.id: str(e)})
file = CloudInitFile.create(text=yaml.dump(d), priority=0)
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index 261b095..2eb9fba 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -9,6 +9,7 @@
import json
+import yaml
from django.db.models import Q
from datetime import timedelta
from django.utils import timezone
diff --git a/src/templates/base/dashboard/searchable_select_multiple.html b/src/templates/base/dashboard/searchable_select_multiple.html
index 4d996e5..2b77fa3 100644
--- a/src/templates/base/dashboard/searchable_select_multiple.html
+++ b/src/templates/base/dashboard/searchable_select_multiple.html
@@ -40,7 +40,9 @@
let field_initial = {{ initial|safe }};
//global
+ console.log("makes search widget");
searchable_select_multiple_widget = new SearchableSelectMultipleWidget(format_vars, field_dataset, field_initial);
+ console.log("made search widget");
}
searchableSelectMultipleWidgetEntry();
diff --git a/src/templates/lfedge/booking/quick_deploy.html b/src/templates/lfedge/booking/quick_deploy.html
index dac3815..ccafd90 100644
--- a/src/templates/lfedge/booking/quick_deploy.html
+++ b/src/templates/lfedge/booking/quick_deploy.html
@@ -11,7 +11,7 @@
</p>
{% endblock form-text %}
{% block collab %}
-<div class="col-12 col-lg-4 my-2">
+<div class="col-12 col-lg-6 my-2">
<div class="col border rounded py-2 h-100">
<label>Collaborators</label>
{{ form.users }}
@@ -21,8 +21,8 @@
{% block image_script %}
<script type="text/javascript">
- document.getElementById("id_image").disabled = true;
- document.getElementById("id_image").style.display = 'none';
- document.getElementById("id_image").previousElementSibling.style.display = 'none';
+// document.getElementById("id_image").disabled = true;
+// document.getElementById("id_image").style.display = 'none';
+// document.getElementById("id_image").previousElementSibling.style.display = 'none';
</script>
{% endblock image_script %}