diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Client/Tools/APT.py | 4 | ||||
-rw-r--r-- | src/lib/Client/Tools/Upstart.py | 63 | ||||
-rw-r--r-- | src/lib/Client/Tools/__init__.py | 23 | ||||
-rw-r--r-- | src/lib/SSLServer.py | 5 |
4 files changed, 91 insertions, 4 deletions
diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py index 9b7b6d72d..ed686e400 100644 --- a/src/lib/Client/Tools/APT.py +++ b/src/lib/Client/Tools/APT.py @@ -64,9 +64,11 @@ class APT(Bcfg2.Client.Tools.Tool): for item in output: if "checksum mismatch" in item: files.append(item.split()[-1]) + elif "changed file" in item: + files.append(item.split()[3]) elif "can't open" in item: files.append(item.split()[5]) - elif "is not installed" in item: + elif "is not installed" in item or "missing file" in item: self.logger.error("Package %s is not fully installed" \ % entry.get('name')) else: diff --git a/src/lib/Client/Tools/Upstart.py b/src/lib/Client/Tools/Upstart.py new file mode 100644 index 000000000..a3da5b514 --- /dev/null +++ b/src/lib/Client/Tools/Upstart.py @@ -0,0 +1,63 @@ +'''Upstart support for Bcfg2''' +__revision__ = '$Revision$' + +import glob +import re + +import Bcfg2.Client.Tools +import Bcfg2.Client.XML + + +class Upstart(Bcfg2.Client.Tools.SvcTool): + '''Upstart service support for Bcfg2''' + name = 'Upstart' + __execs__ = ['/lib/init/upstart-job', + '/sbin/initctl', + '/usr/sbin/service'] + __handles__ = [('Service', 'upstart')] + __req__ = {'Service': ['name', 'status']} + svcre = re.compile("/etc/init/(?P<name>.*).conf") + + def get_svc_command(self, service, action): + return "/usr/sbin/service %s %s" % (service.get('name'), action) + + def VerifyService(self, entry, _): + '''Verify Service status for entry + + Verifying whether or not the service is enabled can be done + at the file level with upstart using the contents of + /etc/init/servicename.conf. All we need to do is make sure + the service is running when it should be. + ''' + output = self.cmd.run('/usr/sbin/service %s status' % \ + entry.get('name'))[1][0] + if output.split(' ')[1].split('/')[1].startswith('running'): + status = True + if entry.get('status') == 'off': + entry.set('current_status', 'on') + else: + status = False + if entry.get('status') == 'on': + entry.set('current_status', 'off') + + return status + + def InstallService(self, entry): + '''Install Service for entry''' + if entry.get('mode', 'default') == 'supervised': + pstatus, pout = self.cmd.run('/usr/sbin/service %s status' % \ + entry.get('name')) + if pstatus: + self.cmd.run('/usr/sbin/service %s start' % (entry.get('name'))) + return True + + def FindExtra(self): + '''Locate extra Upstart services''' + specified = [entry.get('name') for entry in self.getSupportedEntries()] + extra = [] + for name in [self.svcre.match(fname).group('name') for fname in + glob.glob("/etc/init/*.conf") \ + if self.svcre.match(fname).group('name') not in specified]: + extra.append(name) + return [Bcfg2.Client.XML.Element('Service', type='upstart', name=name) \ + for name in extra] diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index d25219579..33a0e19c1 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -1,9 +1,26 @@ '''This contains all Bcfg2 Tool modules''' __revision__ = '$Revision$' -__all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap", "IPS", - "FreeBSDInit", "FreeBSDPackage", "launchd", "MacPorts", "Portage", - "POSIX", "RPMng", 'rpmtools', "RcUpdate", "SMF", "SYSV", "YUMng"] +__all__ = ["Action", + "APT", + "Blast", + "Chkconfig", + "DebInit", + "Encap", + "IPS", + "FreeBSDInit", + "FreeBSDPackage", + "launchd", + "MacPorts", + "Portage", + "POSIX", + "RPMng", + "rpmtools", + "RcUpdate", + "SMF", + "SYSV", + "Upstart", + "YUMng"] drivers = [item for item in __all__ if item not in ['rpmtools']] default = [item for item in drivers if item not in ['RPM', 'Yum']] diff --git a/src/lib/SSLServer.py b/src/lib/SSLServer.py index c3ecbdea5..fac332f14 100644 --- a/src/lib/SSLServer.py +++ b/src/lib/SSLServer.py @@ -203,6 +203,11 @@ class XMLRPCRequestHandler (SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: + try: + select.select([self.rfile.fileno()], [], [], 3) + except select.error: + print "got select timeout" + raise chunk_size = min(size_remaining, max_chunk_size) L.append(self.rfile.read(chunk_size)) size_remaining -= len(L[-1]) |