"""
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:
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
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:
)
import json
+import yaml
+import uuid
from deepmerge import Merger
"""
["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)
</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 }}
{% 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 %}