diff --git a/avocado/utils/service.py b/avocado/utils/service.py index 5672b004ca4236d297e35a50d3b24194e49f4a30..11816f5b97609151c4915b6c6f3662bcd40de9c5 100644 --- a/avocado/utils/service.py +++ b/avocado/utils/service.py @@ -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) ) diff --git a/selftests/unit/test_utils_service.py b/selftests/unit/test_utils_service.py index b4a646241be4b98401c36dd10c5c803176be7a25..fcae7e78d9fae2947513821b36548d6b0a1b19da 100644 --- a/selftests/unit/test_utils_service.py +++ b/selftests/unit/test_utils_service.py @@ -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":