diff options
-rw-r--r-- | cloudinit/config/cc_set_passwords.py | 10 | ||||
-rw-r--r-- | cloudinit/distros/ubuntu.py | 2 | ||||
-rw-r--r-- | cloudinit/filters/launch_index.py | 2 | ||||
-rw-r--r-- | tests/unittests/test_filters/test_launch_index.py | 25 |
4 files changed, 21 insertions, 18 deletions
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py index 7d0fbd9f..a017e6b6 100644 --- a/cloudinit/config/cc_set_passwords.py +++ b/cloudinit/config/cc_set_passwords.py @@ -53,14 +53,18 @@ def handle(_name, cfg, cloud, log, args): user = cloud.distro.get_default_user() if 'users' in cfg: - user_zero = cfg['users'].keys()[0] - if user_zero != "default": - user = user_zero + user_zero = cfg['users'][0] + + if isinstance(user_zero, dict) and 'name' in user_zero: + user = user_zero['name'] if user: plist = "%s:%s" % (user, password) + else: + log.warn("No default or defined user to change password for.") + errors = [] if plist: plist_in = [] diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py index 5444cbc0..22f8c2c5 100644 --- a/cloudinit/distros/ubuntu.py +++ b/cloudinit/distros/ubuntu.py @@ -31,5 +31,5 @@ class Distro(debian.Distro): distro_name = 'ubuntu' default_user = 'ubuntu' - default_user_groups = ("adm,admin,audio,cdrom,dialout,floppy,video," + default_user_groups = ("adm,audio,cdrom,dialout,floppy,video," "plugdev,dip,netdev,sudo") diff --git a/cloudinit/filters/launch_index.py b/cloudinit/filters/launch_index.py index 4299fb46..5bebd318 100644 --- a/cloudinit/filters/launch_index.py +++ b/cloudinit/filters/launch_index.py @@ -44,7 +44,7 @@ class Filter(object): return True def _do_filter(self, message): - # Don't use walk() here since we want to do the reforming of the + # Don't use walk() here since we want to do the reforming of the # messages ourselves and not flatten the message listings... if not self._select(message): return None diff --git a/tests/unittests/test_filters/test_launch_index.py b/tests/unittests/test_filters/test_launch_index.py index 0c75bf56..7ca7cbb6 100644 --- a/tests/unittests/test_filters/test_launch_index.py +++ b/tests/unittests/test_filters/test_launch_index.py @@ -4,9 +4,9 @@ import helpers as th import itertools +from cloudinit.filters import launch_index from cloudinit import user_data as ud from cloudinit import util -from cloudinit.filters import launch_index def count_messages(root): @@ -18,7 +18,6 @@ def count_messages(root): return am - class TestLaunchFilter(th.ResourceUsingTestCase): def assertCounts(self, message, expected_counts): @@ -84,7 +83,7 @@ class TestLaunchFilter(th.ResourceUsingTestCase): None: 1, } self.assertCounts(message, expected_counts) - + def testConfigEmailIndex(self): test_data = self.readResource('filter_cloud_multipart_1.email') ud_proc = ud.UserDataProcessor(self.getCloudPaths()) @@ -98,7 +97,7 @@ class TestLaunchFilter(th.ResourceUsingTestCase): None: 1, } self.assertCounts(message, expected_counts) - + def testNoneIndex(self): test_data = self.readResource('filter_cloud_multipart.yaml') ud_proc = ud.UserDataProcessor(self.getCloudPaths()) @@ -107,7 +106,7 @@ class TestLaunchFilter(th.ResourceUsingTestCase): self.assertTrue(start_count > 0) filtered_message = launch_index.Filter(None).apply(message) self.assertTrue(self.equivalentMessage(message, filtered_message)) - + def testIndexes(self): test_data = self.readResource('filter_cloud_multipart.yaml') ud_proc = ud.UserDataProcessor(self.getCloudPaths()) @@ -117,14 +116,14 @@ class TestLaunchFilter(th.ResourceUsingTestCase): # This file should have the following # indexes -> amount mapping in it expected_counts = { - 2:2, - 3:2, - 1:2, - 0:1, - 4:1, - 7:0, - -1:0, - 100:0, + 2: 2, + 3: 2, + 1: 2, + 0: 1, + 4: 1, + 7: 0, + -1: 0, + 100: 0, # None should just give all back None: start_count, # Non ints should be ignored |