diff options
Diffstat (limited to 'src/lib/Client/Tools/RcUpdate.py')
-rw-r--r-- | src/lib/Client/Tools/RcUpdate.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/lib/Client/Tools/RcUpdate.py b/src/lib/Client/Tools/RcUpdate.py index d4fd75168..717099954 100644 --- a/src/lib/Client/Tools/RcUpdate.py +++ b/src/lib/Client/Tools/RcUpdate.py @@ -11,22 +11,29 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): __req__ = {'Service': ['name', 'status']} def VerifyService(self, entry, _): - '''Verify Service status for entry. Assumes we run in the "default" runlevel.''' - # mrj - i think this should be: - # rc = self.cmd.run('/bin/rc-status | grep %s | grep started"' % entry.attrib['name']) - # ...but as i can't figure out a way to test that right now, i'll do the one - # that works in python's interactive interpreter. + ''' + Verify Service status for entry. + Assumes we run in the "default" runlevel. + ''' + # mrj - i think this should be: + # rc = self.cmd.run('/bin/rc-status | \ + # grep %s | \ + # grep started"' % entry.attrib['name']) + # + # ...but as i can't figure out a way to + # test that right now, i'll do the one + # that works in python's interactive interpreter. rc = commands.getoutput('/bin/rc-status | grep %s | grep started' % \ entry.get('name')) status = len(rc) > 0 - + if not status: - # service is off + # service is off if entry.get('status') == 'on': - # we want it on, it's not + # we want it on, it's not entry.set('current_status', 'off') else: - # we want it off, it's not + # we want it off, it's not entry.set('current_status', 'on') return status @@ -36,14 +43,17 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): try: os.stat('/etc/init.d/%s' % entry.get('name')) except OSError: - self.logger.debug("Init script for service %s does not exist" % entry.get('name')) + self.logger.debug("Init script for service %s does not exist" % + entry.get('name')) return False - + if entry.get('status') == 'off': self.cmd.run("/etc/init.d/%s stop" % (entry.get('name'))) - cmdrc = self.cmd.run("/sbin/rc-update del %s default" % (entry.get('name'))) + cmdrc = self.cmd.run("/sbin/rc-update del %s default" % + (entry.get('name'))) else: - cmdrc = self.cmd.run("/sbin/rc-update add %s default" % entry.get('name'))[0] + cmdrc = self.cmd.run("/sbin/rc-update add %s default" % + entry.get('name'))[0] return cmdrc == 0 def FindExtra(self): |