diff options
-rw-r--r-- | cloudinit/distros/__init__.py | 2 | ||||
-rw-r--r-- | cloudinit/distros/freebsd.py | 1 | ||||
-rw-r--r-- | cloudinit/distros/openbsd.py | 1 | ||||
-rw-r--r-- | tests/unittests/distros/test_manage_service.py | 10 |
4 files changed, 12 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 6fee7328..5ba61b1e 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -920,6 +920,7 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta): "stop": ["stop", service], "start": ["start", service], "enable": ["enable", service], + "disable": ["disable", service], "restart": ["restart", service], "reload": ["reload-or-restart", service], "try-reload": ["reload-or-try-restart", service], @@ -930,6 +931,7 @@ class Distro(persistence.CloudInitPickleMixin, metaclass=abc.ABCMeta): "stop": [service, "stop"], "start": [service, "start"], "enable": [service, "start"], + "disable": [service, "stop"], "restart": [service, "restart"], "reload": [service, "restart"], "try-reload": [service, "restart"], diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py index 68a9f300..b9fd37b8 100644 --- a/cloudinit/distros/freebsd.py +++ b/cloudinit/distros/freebsd.py @@ -49,6 +49,7 @@ class Distro(cloudinit.distros.bsd.BSD): "stop": [service, "stop"], "start": [service, "start"], "enable": [service, "enable"], + "disable": [service, "disable"], "restart": [service, "restart"], "reload": [service, "restart"], "try-reload": [service, "restart"], diff --git a/cloudinit/distros/openbsd.py b/cloudinit/distros/openbsd.py index 9ef33bf2..72e9bc45 100644 --- a/cloudinit/distros/openbsd.py +++ b/cloudinit/distros/openbsd.py @@ -36,6 +36,7 @@ class Distro(cloudinit.distros.netbsd.NetBSD): "stop": ["stop", service], "start": ["start", service], "enable": ["enable", service], + "disable": ["disable", service], "restart": ["restart", service], "reload": ["restart", service], "try-reload": ["restart", service], diff --git a/tests/unittests/distros/test_manage_service.py b/tests/unittests/distros/test_manage_service.py index e53baf9a..a6b8a3dc 100644 --- a/tests/unittests/distros/test_manage_service.py +++ b/tests/unittests/distros/test_manage_service.py @@ -52,5 +52,11 @@ class TestManageService(CiTestCase): ["systemctl", "start", "myssh"], capture=True ) - -# vi: ts=4 sw=4 expandtab + @mock.patch.object(MockDistro, "uses_systemd", return_value=True) + @mock.patch("cloudinit.distros.subp.subp") + def test_manage_service_disable_systemctl(self, m_subp, m_sysd): + self.dist.init_cmd = ["ignore"] + self.dist.manage_service("disable", "myssh") + m_subp.assert_called_with( + ["systemctl", "disable", "myssh"], capture=True + ) |