Skip to content

Commit 3a027cc

Browse files
dorianmphilpep
authored andcommitted
Service: Add is_masked method to systemd
Check the return of the systemctl is-enabled command. The command should returns "masked" if the service is masked
1 parent d0d02a5 commit 3a027cc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

testinfra/modules/service.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ def is_valid(self):
132132
assert (cmd.stdout, cmd.stderr) == ("", "")
133133
return True
134134

135+
@property
136+
def is_masked(self):
137+
cmd = self.run("systemctl is-enabled %s", self.name)
138+
return cmd.rc == 0 and cmd.stdout.strip() == "masked"
139+
135140

136141
class UpstartService(SysvService):
137142

0 commit comments

Comments
 (0)