diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-10-11 22:02:16 +0000 |
---|---|---|
committer | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2021-10-11 22:02:16 +0000 |
commit | afcee3cad5c091e78e909b83f8df49accf1af5b6 (patch) | |
tree | f0e57c648e1688a977a7456554886772c6531e93 /src/api/models.py | |
parent | 5ce0a52b17e530436c298e1b581d37bac853f5a7 (diff) |
Prod cobbler hotfixes
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Change-Id: I092bc6d85a3b2c77bfbe24f3af0d2b7a5f75a8c3
Diffstat (limited to 'src/api/models.py')
-rw-r--r-- | src/api/models.py | 45 |
1 files changed, 38 insertions, 7 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: |