Remove “node_tcp_ping” RPC
[ganeti-local] / lib / rpc.py
index b405900..7d75a58 100644 (file)
@@ -124,34 +124,6 @@ def _ConfigRpcCurl(curl):
   curl.setopt(pycurl.CONNECTTIMEOUT, _RPC_CONNECT_TIMEOUT)
 
 
-# Aliasing this module avoids the following warning by epydoc: "Warning: No
-# information available for ganeti.rpc._RpcThreadLocal's base threading.local"
-_threading = threading
-
-
-class _RpcThreadLocal(_threading.local):
-  def GetHttpClientPool(self):
-    """Returns a per-thread HTTP client pool.
-
-    @rtype: L{http.client.HttpClientPool}
-
-    """
-    try:
-      pool = self.hcp
-    except AttributeError:
-      pool = http.client.HttpClientPool(_ConfigRpcCurl)
-      self.hcp = pool
-
-    return pool
-
-
-# Remove module alias (see above)
-del _threading
-
-
-_thread_local = _RpcThreadLocal()
-
-
 def _RpcTimeout(secs):
   """Timeout decorator.
 
@@ -402,7 +374,8 @@ class _RpcProcessor:
                                         headers=_RPC_CLIENT_HEADERS,
                                         post_data=body,
                                         read_timeout=read_timeout,
-                                        nicename="%s/%s" % (name, procedure))
+                                        nicename="%s/%s" % (name, procedure),
+                                        curl_config_fn=_ConfigRpcCurl)
 
     return (results, requests)
 
@@ -430,7 +403,8 @@ class _RpcProcessor:
 
     return results
 
-  def __call__(self, hosts, procedure, body, read_timeout=None, http_pool=None):
+  def __call__(self, hosts, procedure, body, read_timeout=None,
+               _req_process_fn=http.client.ProcessRequests):
     """Makes an RPC request to a number of nodes.
 
     @type hosts: sequence
@@ -445,9 +419,6 @@ class _RpcProcessor:
     """
     assert procedure in _TIMEOUTS, "RPC call not declared in the timeouts table"
 
-    if not http_pool:
-      http_pool = _thread_local.GetHttpClientPool()
-
     if read_timeout is None:
       read_timeout = _TIMEOUTS[procedure]
 
@@ -455,8 +426,7 @@ class _RpcProcessor:
       self._PrepareRequests(self._resolver(hosts), self._port, procedure,
                             str(body), read_timeout)
 
-    http_pool.ProcessRequests(requests.values(),
-                              lock_monitor_cb=self._lock_monitor_cb)
+    _req_process_fn(requests.values(), lock_monitor_cb=self._lock_monitor_cb)
 
     assert not frozenset(results).intersection(requests)
 
@@ -874,18 +844,6 @@ class RpcRunner(object):
     return self._MultiNodeCall(node_list, "instance_list", [hypervisor_list])
 
   @_RpcTimeout(_TMO_FAST)
-  def call_node_tcp_ping(self, node, source, target, port, timeout,
-                         live_port_needed):
-    """Do a TcpPing on the remote node
-
-    This is a single-node call.
-
-    """
-    return self._SingleNodeCall(node, "node_tcp_ping",
-                                [source, target, port, timeout,
-                                 live_port_needed])
-
-  @_RpcTimeout(_TMO_FAST)
   def call_node_has_ip_address(self, node, address):
     """Checks if a node has the given IP address.
 
@@ -944,24 +902,55 @@ class RpcRunner(object):
 
   @classmethod
   @_RpcTimeout(_TMO_FAST)
-  def call_node_start_master(cls, node, start_daemons, no_voting):
-    """Tells a node to activate itself as a master.
+  def call_node_start_master_daemons(cls, node, no_voting):
+    """Starts master daemons on a node.
+
+    This is a single-node call.
+
+    """
+    return cls._StaticSingleNodeCall(node, "node_start_master_daemons",
+                                     [no_voting])
+
+  @classmethod
+  @_RpcTimeout(_TMO_FAST)
+  def call_node_activate_master_ip(cls, node):
+    """Activates master IP on a node.
+
+    This is a single-node call.
+
+    """
+    return cls._StaticSingleNodeCall(node, "node_activate_master_ip", [])
+
+  @classmethod
+  @_RpcTimeout(_TMO_FAST)
+  def call_node_stop_master(cls, node):
+    """Deactivates master IP and stops master daemons on a node.
+
+    This is a single-node call.
+
+    """
+    return cls._StaticSingleNodeCall(node, "node_stop_master", [])
+
+  @classmethod
+  @_RpcTimeout(_TMO_FAST)
+  def call_node_deactivate_master_ip(cls, node):
+    """Deactivates master IP on a node.
 
     This is a single-node call.
 
     """
-    return cls._StaticSingleNodeCall(node, "node_start_master",
-                                     [start_daemons, no_voting])
+    return cls._StaticSingleNodeCall(node, "node_deactivate_master_ip", [])
 
   @classmethod
   @_RpcTimeout(_TMO_FAST)
-  def call_node_stop_master(cls, node, stop_daemons):
-    """Tells a node to demote itself from master status.
+  def call_node_change_master_netmask(cls, node, netmask):
+    """Change master IP netmask.
 
     This is a single-node call.
 
     """
-    return cls._StaticSingleNodeCall(node, "node_stop_master", [stop_daemons])
+    return cls._StaticSingleNodeCall(node, "node_change_master_netmask",
+                  [netmask])
 
   @classmethod
   @_RpcTimeout(_TMO_URGENT)