diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-21 14:37:27 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-21 14:37:27 -0400 |
commit | c9ba92ef62376bbf01da1eac96cd5a2b5eb65a66 (patch) | |
tree | 19a61840175d2fb16ea51dedf49abd45d2417774 /src/lib/Bcfg2/Client/Tools/RcUpdate.py | |
parent | f36c89f5e78a3a2fcd9ad4b38b8670895883bd38 (diff) | |
parent | e88c029c6fdbedb038443c8cbe52206d9ca9c1a2 (diff) | |
download | bcfg2-c9ba92ef62376bbf01da1eac96cd5a2b5eb65a66.tar.gz bcfg2-c9ba92ef62376bbf01da1eac96cd5a2b5eb65a66.tar.bz2 bcfg2-c9ba92ef62376bbf01da1eac96cd5a2b5eb65a66.zip |
Merge branch 'maint'
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools/RcUpdate.py')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/RcUpdate.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/RcUpdate.py b/src/lib/Bcfg2/Client/Tools/RcUpdate.py index d5cef6e34..2e58f2564 100644 --- a/src/lib/Bcfg2/Client/Tools/RcUpdate.py +++ b/src/lib/Bcfg2/Client/Tools/RcUpdate.py @@ -23,8 +23,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): # check if service is enabled cmd = '/sbin/rc-update show default | grep %s' - rv = self.cmd.run(cmd % entry.get('name'))[0] - is_enabled = (rv == 0) + is_enabled = self.cmd.run(cmd % entry.get('name')).success # check if init script exists try: @@ -36,8 +35,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): # check if service is enabled cmd = '/etc/init.d/%s status | grep started' - rv = self.cmd.run(cmd % entry.attrib['name'])[0] - is_running = (rv == 0) + is_running = self.cmd.run(cmd % entry.attrib['name']).success if entry.get('status') == 'on' and not (is_enabled and is_running): entry.set('current_status', 'off') @@ -60,27 +58,25 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): self.start_service(entry) # make sure it's enabled cmd = '/sbin/rc-update add %s default' - rv = self.cmd.run(cmd % entry.get('name'))[0] - return (rv == 0) - + return self.cmd.run(cmd % entry.get('name')).success elif entry.get('status') == 'off': if entry.get('current_status') == 'on': self.stop_service(entry) # make sure it's disabled cmd = '/sbin/rc-update del %s default' - rv = self.cmd.run(cmd % entry.get('name'))[0] - return (rv == 0) + return self.cmd.run(cmd % entry.get('name')).success return False def FindExtra(self): """Locate extra rc-update services.""" - cmd = '/bin/rc-status -s | grep started' - allsrv = [line.split()[0] for line in self.cmd.run(cmd)[1]] + cmd = '/bin/rc-status -s' + allsrv = [line.split()[0] + for line in self.cmd.run(cmd).stdout.splitlines() + if 'started' in line] self.logger.debug('Found active services:') self.logger.debug(allsrv) specified = [srv.get('name') for srv in self.getSupportedEntries()] - return [Bcfg2.Client.XML.Element('Service', - type='rc-update', - name=name) \ + return [Bcfg2.Client.XML.Element('Service', type='rc-update', + name=name) for name in allsrv if name not in specified] |