summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Tools/Systemd.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools/Systemd.py')
-rw-r--r--src/lib/Bcfg2/Client/Tools/Systemd.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/Systemd.py b/src/lib/Bcfg2/Client/Tools/Systemd.py
index f7e5b1b0b..8919e777b 100644
--- a/src/lib/Bcfg2/Client/Tools/Systemd.py
+++ b/src/lib/Bcfg2/Client/Tools/Systemd.py
@@ -2,6 +2,8 @@
"""This is systemd support."""
+import glob
+import os
import Bcfg2.Client.Tools
import Bcfg2.Client.XML
@@ -72,22 +74,34 @@ class Systemd(Bcfg2.Client.Tools.SvcTool):
# Return failure immediately and do not start/stop the service.
return False
- # Start or stop the service, depending on the current servicemode
+ # Start or stop the service, depending on the current service_mode
cmd = None
- if Bcfg2.Options.setup.servicemode == 'disabled':
+ if Bcfg2.Options.setup.service_mode == 'disabled':
# 'disabled' means we don't attempt to modify running svcs
pass
- elif Bcfg2.Options.setup.servicemode == 'build':
+ elif Bcfg2.Options.setup.service_mode == 'build':
# 'build' means we attempt to stop all services started
if entry.get('current_status') == 'on':
cmd = self.get_svc_command(entry, 'stop')
else:
if entry.get('status') == 'on':
cmd = self.get_svc_command(entry, 'start')
- else:
+ elif entry.get('status') == 'off':
cmd = self.get_svc_command(entry, 'stop')
if cmd:
return self.cmd.run(cmd).success
else:
return True
+
+ def FindExtra(self):
+ """Find Extra Systemd Service entries."""
+ specified = [self.get_svc_name(entry)
+ for entry in self.getSupportedEntries()]
+ extra = set()
+ for fname in glob.glob("/etc/systemd/system/*.wants/*"):
+ name = os.path.basename(fname)
+ if name not in specified:
+ extra.add(name)
+ return [Bcfg2.Client.XML.Element('Service', name=name, type='systemd')
+ for name in list(extra)]