@@ -47,7 +47,7 @@ def is_valid(self):
47
47
"""Test if service is valid
48
48
49
49
This method is only available in the systemd implementation,
50
- it will raise NotImplementedError in others implementation
50
+ it will raise `` NotImplementedError`` in others implementation
51
51
"""
52
52
raise NotImplementedError
53
53
@@ -56,7 +56,27 @@ def is_masked(self):
56
56
"""Test if service is masked
57
57
58
58
This method is only available in the systemd implementation,
59
- it will raise NotImplementedError in others implementations
59
+ it will raise ``NotImplementedError`` in others implementations
60
+ """
61
+ raise NotImplementedError
62
+
63
+ @cached_property
64
+ def systemd_properties (self ):
65
+ """Properties of the service (unit).
66
+
67
+ Return service properties as a `dict`,
68
+ empty properties are not returned.
69
+
70
+ >>> ntp = host.service("ntp")
71
+ >>> ntp.systemd_properties["FragmentPath"]
72
+ '/lib/systemd/system/ntp.service'
73
+
74
+ This method is only available in the systemd implementation,
75
+ it will raise ``NotImplementedError`` in others implementations
76
+
77
+ Note: based on `systemctl show`_
78
+
79
+ .. _systemctl show: https://man7.org/linux/man-pages/man1/systemctl.1.html
60
80
"""
61
81
raise NotImplementedError
62
82
@@ -159,6 +179,17 @@ def is_masked(self):
159
179
cmd = self .run_test ("systemctl is-enabled %s" , self .name )
160
180
return cmd .stdout .strip () == "masked"
161
181
182
+ @cached_property
183
+ def systemd_properties (self ):
184
+ out = self .check_output ("systemctl show %s" , self .name )
185
+ out_d = {}
186
+ if out :
187
+ # maxsplit is required because values can contain `=`
188
+ out_d = dict (
189
+ map (lambda pair : pair .split ("=" , maxsplit = 1 ), out .splitlines ())
190
+ )
191
+ return out_d
192
+
162
193
163
194
class UpstartService (SysvService ):
164
195
@property
0 commit comments