ganeti.rpc: Read SSL certificate and key only once per request
authorMichael Hanselmann <hansmi@google.com>
Mon, 24 Nov 2008 13:38:06 +0000 (13:38 +0000)
committerMichael Hanselmann <hansmi@google.com>
Mon, 24 Nov 2008 13:38:06 +0000 (13:38 +0000)
There's no need to read the SSL certificate and key for every node
in a request. Also add a TODO for better error reporting.

Reviewed-by: amishchenko

lib/rpc.py

index cb4f4b7..f82a90c 100644 (file)
@@ -92,6 +92,10 @@ class Client:
     self.port = utils.GetNodeDaemonPort()
     self.nc = {}
 
+    self._ssl_params = \
+      http.HttpSslParams(ssl_key_path=constants.SSL_CERT_FILE,
+                         ssl_cert_path=constants.SSL_CERT_FILE)
+
   def ConnectList(self, node_list, address_list=None):
     """Add a list of nodes to the target nodes.
 
@@ -122,14 +126,10 @@ class Client:
     if address is None:
       address = name
 
-    # TODO: Cache key and certificate for different requests
-    ssl_params = http.HttpSslParams(ssl_key_path=constants.SSL_CERT_FILE,
-                                    ssl_cert_path=constants.SSL_CERT_FILE)
-
     self.nc[name] = http.HttpClientRequest(address, self.port, http.HTTP_PUT,
                                            "/%s" % self.procedure,
                                            post_data=self.body,
-                                           ssl_params=ssl_params,
+                                           ssl_params=self._ssl_params,
                                            ssl_verify_peer=True)
 
   def GetResults(self):
@@ -150,6 +150,7 @@ class Client:
         results[name] = serializer.LoadJson(req.resp_body)
         continue
 
+      # TODO: Better error reporting
       if req.error:
         msg = req.error
       else: