提交 abadecb2 编写于 作者: R Radek Duda 提交者: Lukáš Doktor

service.py: add mask, unmask and reset-failed to systemd

reset-failed, mask, unmask options are added to service management
((majority of which are transerred from
https://github.com/avocado-framework/avocado-vt/blob/master/virttest/staging/service.py)
- see avocado-framework/avocado-vt#1565)
Signed-off-by: NRadek Duda <rduda@redhat.com>
上级 8d6ad5c5
......@@ -277,6 +277,11 @@ def sys_v_init_command_generator(command):
target = convert_systemd_target_to_runlevel(target)
return ["telinit", target]
return set_target_command
# Do not need reset failed, mask and unmask in sys_v style system.
elif command in ["reset_failed", "mask", "unmask"]:
def true_command(service_name):
return ["true"]
return true_command
def method(service_name):
return [command_name, service_name, command]
......@@ -316,6 +321,8 @@ def systemd_command_generator(command):
def set_target_command(target):
return [command_name, "isolate", target]
return set_target_command
elif command == "reset_failed":
command = "reset-failed"
def method(service_name):
return [command_name, command, "%s.service" % service_name]
......@@ -335,6 +342,9 @@ COMMANDS = (
("is_enabled", False),
("list", False),
("set_target", True),
("reset_failed", True),
("mask", True),
("unmask", True)
)
......
......@@ -67,6 +67,8 @@ class TestSystemd(unittest.TestCase):
self.service_command_generator, cmd)(self.service_name)
if cmd == "is_enabled":
cmd = "is-enabled"
if cmd == "reset_failed":
cmd = "reset-failed"
self.assertEqual(ret, ["systemctl", cmd, "%s.service" % self.service_name])
def test_set_target(self):
......@@ -88,7 +90,8 @@ class TestSysVInit(unittest.TestCase):
command_name = "service"
for cmd, _ in ((c, r) for (c, r) in
self.service_command_generator.commands if
c not in ["list", "set_target"]):
c not in ["list", "set_target", "reset_failed", "mask",
"unmask"]):
ret = getattr(
self.service_command_generator, cmd)(self.service_name)
if cmd == "is_enabled":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册