diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-24 20:33:13 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-24 20:33:13 -0700 |
commit | a2c6279d303a3b85625404653c7ab8081281ee18 (patch) | |
tree | 5093c33ffff091cc3e08d1b522d3de3a58cc6c60 /cloudinit/distros/__init__.py | |
parent | 90b6cfd005f5af90991fe93e5a08c8a8849e2a6d (diff) | |
download | vyos-cloud-init-a2c6279d303a3b85625404653c7ab8081281ee18.tar.gz vyos-cloud-init-a2c6279d303a3b85625404653c7ab8081281ee18.zip |
Handle the case where 'user' is defined but 'users' isn't.
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r-- | cloudinit/distros/__init__.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 13e4fd44..4cf8f745 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -507,13 +507,20 @@ def _normalize_users(u_cfg, def_user_cfg=None): def normalize_users_groups(cfg, distro): + if not cfg: + cfg = {} users = {} groups = {} if 'groups' in cfg: groups = _normalize_groups(cfg['groups']) + + # Handle the previous style of doing this... old_user = None - if 'user' in cfg: + if 'user' in cfg and cfg['user']: old_user = str(cfg['user']) + if not 'users' in cfg: + cfg['users'] = old_user + old_user = None if 'users' in cfg: default_user_config = None try: @@ -527,7 +534,7 @@ def normalize_users_groups(cfg, distro): # The old user replaces user[0] base_users[0] = {'name': old_user} elif not base_users and old_user: - base.append({'name': old_user}) + base_users.append({'name': old_user}) elif isinstance(base_users, (dict)): # Sorry order not possible if old_user and old_user not in base_users: |