File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -118,3 +118,18 @@ def get_hostname(command):
118
118
except ExecutionError :
119
119
return None
120
120
return hostname_string [0 ]
121
+
122
+ def systemd_unit_properties (command , unit_properties , unit = '' ):
123
+ """Yields the values of the properties of a unit
124
+ Args:
125
+ command (CommandProtocol): An instance of a Driver implementing the CommandProtocol
126
+ unit_properties (iterable): Names of the properties of interest
127
+ unit (str, optional): The systemd unit of interest, defaults to empty (systemd manager itself)
128
+ Yields:
129
+ str: Property value of the unit
130
+ """
131
+ assert isinstance (command , CommandProtocol ), "command must be a CommandProtocol"
132
+
133
+ for unit_property in unit_properties :
134
+ yield command .run_check ('systemctl --property={property} --no-pager --value show {unit}' .format (
135
+ property = unit_property , unit = unit ))[0 ]
You can’t perform that action at this time.
0 commit comments