]> git.ipfire.org Git - pakfire.git/commitdiff
Send configured host key to hub.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Apr 2012 13:54:46 +0000 (15:54 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Apr 2012 13:54:46 +0000 (15:54 +0200)
python/pakfire/cli.py
python/pakfire/client/base.py
python/pakfire/client/builder.py
python/pakfire/client/transport.py

index 31d5b6d8b347924b03433fa509a8231ff72239a2..05a8c6edf919c9c3f31d32fe3a3562bdcf60a68a 100644 (file)
@@ -1141,12 +1141,7 @@ class CliDaemon(Cli):
                conf = config.ConfigDaemon()
 
                # Create daemon instance.
-               d = pakfire.client.PakfireDaemon(
-                       server   = conf.get("daemon", "server"),
-                       hostname = conf.get("daemon", "hostname"),
-                       secret   = conf.get("daemon", "secret"),
-               )
-
+               d = pakfire.client.PakfireDaemon()
                try:
                        d.run()
 
index ab9ecd9747c502cc93ac24788a4650c560a65500..dc08f674c38bfcab672a2cdc83a760b2948e231b 100644 (file)
@@ -213,6 +213,8 @@ class PakfireBuilderClient(BuildMixin, PakfireClient):
        def send_update(self):
                log.info("Sending host information update to hub...")
 
+               config = pakfire.config.ConfigDaemon()
+
                self.conn.send_update(
                        # Supported architectures.
                        system.supported_arches,
@@ -226,4 +228,7 @@ class PakfireBuilderClient(BuildMixin, PakfireClient):
 
                        # Send the currently running version of Pakfire.
                        PAKFIRE_VERSION,
+
+                       # Send the host key.
+                       config.get("signatures", "host_key", None),
                )
index 35820e409050ffde6be971631e5112787d1becce..4bdaf45e9f5220043dfec3eabc43a1c96f77cc91 100644 (file)
@@ -48,7 +48,13 @@ class PakfireDaemon(object):
                        The PakfireDaemon class that creates a a new process per build
                        job and also handles the keepalive/abort stuff.
                """
-               def __init__(self, server, hostname, secret):
+               def __init__(self):
+                       self.config = pakfire.config.ConfigDaemon()
+
+                       server   = self.config.get("daemon", "server")
+                       hostname = self.config.get("daemon", "hostname")
+                       secret   = self.config.get("daemon", "secret")
+
                        self.client = base.PakfireBuilderClient(server, hostname, secret)
                        self.conn   = self.client.conn
 
@@ -207,12 +213,12 @@ class PakfireDaemon(object):
                        if time.time() - self._last_keepalive < 30:
                                return
 
-                       free_space = self.free_space / 1024**2
+                       kwargs = {
+                               "overload"   : self.has_overload(),
+                               "free_space" : self.free_space / 1024**2,
+                       }
 
-                       self.client.send_keepalive(
-                               overload=self.has_overload(),
-                               free_space=free_space,
-                       )
+                       self.client.send_keepalive(**kwargs)
                        self._last_keepalive = time.time()
 
                def remove_finished_builders(self):
@@ -405,7 +411,7 @@ class ClientBuilder(object):
                                                raise DownloadError, "Hash check did not succeed."
 
                                # Build configuration.
-                               config = pakfire.config.Config(files=["general.conf"])
+                               config = pakfire.config.ConfigDaemon()
 
                                # Parse the configuration received from the build service.
                                config.parse(self.build_config)
index c5036ce99fa2a2c41b66debbaa1c03b0ca2849af..4fb8a8f2771c7c9bde7516a9f0ae0579dc29c3e5 100644 (file)
@@ -31,6 +31,9 @@ log = logging.getLogger("pakfire.client")
 from pakfire.constants import *
 from pakfire.i18n import _
 
+# Set the default socket timeout to 30 seconds.
+socket.setdefaulttimeout(30)
+
 class XMLRPCMixin:
        user_agent = "pakfire/%s" % PAKFIRE_VERSION
 
@@ -46,16 +49,17 @@ class XMLRPCMixin:
                                ret = xmlrpclib.Transport.single_request(self, *args, **kwargs)
 
                        # Catch errors related to the connection. Just try again.
-                       except (socket.error, ssl.SSLError):
-                               pass
+                       except (socket.error, ssl.SSLError), e:
+                               log.warning("Exception: %s: %s" % (e.__class__.__name__, e))
 
                        # Presumably, the server closed the connection before sending anything.
                        except httplib.BadStatusLine:
-                               pass
+                               # Try again immediately.
+                               continue
 
                        # The XML reponse could not be parsed.
-                       except xmlrpclib.ResponseError:
-                               pass
+                       except xmlrpclib.ResponseError, e:
+                               log.warning("Exception: %s: %s" % (e.__class__.__name__, e))
 
                        except xmlrpclib.ProtocolError, e:
                                if e.errcode == 403: