diff options
author | Nate House nathan.house@rackspace.com <> | 2014-02-03 15:58:43 -0600 |
---|---|---|
committer | Nate House nathan.house@rackspace.com <> | 2014-02-03 15:58:43 -0600 |
commit | 4a0e460f18d8cbf2651286565efec1f00cbb20cd (patch) | |
tree | 4ec27f92f3ca45da9b951b4bf501dcf49c0a21f4 | |
parent | b997a8cab8b3b10f9be7e915a5ab4c2cc91effb8 (diff) | |
download | vyos-cloud-init-4a0e460f18d8cbf2651286565efec1f00cbb20cd.tar.gz vyos-cloud-init-4a0e460f18d8cbf2651286565efec1f00cbb20cd.zip |
Update yum unittest
-rw-r--r-- | cloudinit/config/cc_set_passwords.py | 3 | ||||
-rw-r--r-- | cloudinit/util.py | 1 | ||||
-rw-r--r-- | tests/unittests/test_handler/test_handler_yum_add_repo.py | 7 |
3 files changed, 7 insertions, 4 deletions
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py index b9dc0cc0..ab0ed5ad 100644 --- a/cloudinit/config/cc_set_passwords.py +++ b/cloudinit/config/cc_set_passwords.py @@ -137,9 +137,10 @@ def handle(_name, cfg, cloud, log, args): util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines)) try: - cmd = cloud.distro.init_cmd + cmd = cloud.distro.init_cmd # Default service cmd.append(cloud.distro.get_option('ssh_svcname', 'ssh')) cmd.append('restart') + cmd = filter(None, cmd) # Remove empty arguments util.subp(cmd) log.debug("Restarted the ssh daemon") except: diff --git a/cloudinit/util.py b/cloudinit/util.py index 54fdad20..3ce54f28 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1483,7 +1483,6 @@ def subp(args, data=None, rcs=None, env=None, capture=True, shell=False, logstring=False): if rcs is None: rcs = [0] - args = filter(None, args) # Remove empty arguments try: if not logstring: diff --git a/tests/unittests/test_handler/test_handler_yum_add_repo.py b/tests/unittests/test_handler/test_handler_yum_add_repo.py index 8df592f9..ddf0ef9c 100644 --- a/tests/unittests/test_handler/test_handler_yum_add_repo.py +++ b/tests/unittests/test_handler/test_handler_yum_add_repo.py @@ -2,6 +2,7 @@ from cloudinit import helpers from cloudinit import util from cloudinit.config import cc_yum_add_repo +from cloudinit.distros import rhel from tests.unittests import helpers @@ -18,6 +19,8 @@ class TestConfig(helpers.FilesystemMockingTestCase): def setUp(self): super(TestConfig, self).setUp() self.tmp = self.makeDir(prefix="unittest_") + self.cloud = type('', (), {})() + self.cloud.distro = rhel.Distro('test', {}, None) def test_bad_config(self): cfg = { @@ -34,7 +37,7 @@ class TestConfig(helpers.FilesystemMockingTestCase): }, } self.patchUtils(self.tmp) - cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, []) + cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, []) self.assertRaises(IOError, util.load_file, "/etc/yum.repos.d/epel_testing.repo") @@ -52,7 +55,7 @@ class TestConfig(helpers.FilesystemMockingTestCase): }, } self.patchUtils(self.tmp) - cc_yum_add_repo.handle('yum_add_repo', cfg, None, LOG, []) + cc_yum_add_repo.handle('yum_add_repo', cfg, self.cloud, LOG, []) contents = util.load_file("/etc/yum.repos.d/epel_testing.repo") contents = configobj.ConfigObj(StringIO(contents)) expected = { |