diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-21 14:38:40 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-21 14:38:40 -0700 |
commit | 47d9df78264625207342e668a9120fa84b6ad355 (patch) | |
tree | 7aaaeff040dcebdb67616616f189709c78ac08cb | |
parent | 712d019cba5afb535033e8228ad365071661ceb2 (diff) | |
download | vyos-cloud-init-47d9df78264625207342e668a9120fa84b6ad355.tar.gz vyos-cloud-init-47d9df78264625207342e668a9120fa84b6ad355.zip |
Also allow the user list to come in as a comma
separated list so that its types match more of
what the group list can be.
-rw-r--r-- | cloudinit/distros/__init__.py | 2 | ||||
-rw-r--r-- | tests/unittests/test_distros/test_user_data_normalize.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 4fb1d8c2..361d2c05 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -338,6 +338,8 @@ class Distro(object): raise TypeError(("Unmappable user value type %s" " for key %s") % (util.obj_name(v), k)) u_cfg = ad_ucfg + elif isinstance(u_cfg, (str, basestring)): + u_cfg = u_cfg.strip().split(",") users = {} for user_config in u_cfg: diff --git a/tests/unittests/test_distros/test_user_data_normalize.py b/tests/unittests/test_distros/test_user_data_normalize.py index 6ff43a76..caf479cd 100644 --- a/tests/unittests/test_distros/test_user_data_normalize.py +++ b/tests/unittests/test_distros/test_user_data_normalize.py @@ -112,6 +112,17 @@ class TestUGNormalize(MockerTestCase): ((users, def_user), groups) = distro.normalize_users_groups(ug_cfg) self.assertEquals({}, def_user) + def test_users_simple_csv(self): + distro = self._make_distro('ubuntu') + ug_cfg = { + 'users': 'joe,bob', + } + ((users, def_user), groups) = distro.normalize_users_groups(ug_cfg) + self.assertIn('joe', users) + self.assertIn('bob', users) + self.assertEquals({}, users['joe']) + self.assertEquals({}, users['bob']) + def test_users_simple(self): distro = self._make_distro('ubuntu') ug_cfg = { |