Keep only one global RPC runner in Ganeti context
authorMichael Hanselmann <hansmi@google.com>
Mon, 26 Sep 2011 10:05:55 +0000 (12:05 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 27 Sep 2011 11:47:23 +0000 (13:47 +0200)
Instead of having one RPC runner per mcpu processor this will keep only
one instance as part of the masterd-wide Ganeti context. Upcoming
patches will change the RPC runner to report pending requests to the
lock manager.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/mcpu.py
lib/rpc.py
lib/server/masterd.py

index 89046c6..4f6fd1b 100644 (file)
@@ -35,7 +35,6 @@ import time
 from ganeti import opcodes
 from ganeti import constants
 from ganeti import errors
-from ganeti import rpc
 from ganeti import cmdlib
 from ganeti import locking
 from ganeti import utils
@@ -188,7 +187,7 @@ class Processor(object):
     self.context = context
     self._ec_id = ec_id
     self._cbs = None
-    self.rpc = rpc.RpcRunner(context.cfg)
+    self.rpc = context.rpc
     self.hmclass = HooksMaster
 
   def _AcquireLocks(self, level, names, shared, timeout, priority):
index 60a30ab..b717ec0 100644 (file)
@@ -414,17 +414,17 @@ def _EncodeImportExportIO(ieio, ieioargs):
 
 
 class RpcRunner(object):
-  """RPC runner class"""
+  """RPC runner class.
 
-  def __init__(self, cfg):
-    """Initialized the rpc runner.
+  """
+  def __init__(self, context):
+    """Initialized the RPC runner.
 
-    @type cfg:  C{config.ConfigWriter}
-    @param cfg: the configuration object that will be used to get data
-                about the cluster
+    @type context: C{masterd.GanetiContext}
+    @param context: Ganeti context
 
     """
-    self._cfg = cfg
+    self._cfg = context.cfg
     self.port = netutils.GetDaemonPort(constants.NODED)
 
   def _InstDict(self, instance, hvp=None, bep=None, osp=None):
index 27bf561..40c5abf 100644 (file)
@@ -399,6 +399,9 @@ class GanetiContext(object):
     # Job queue
     self.jobqueue = jqueue.JobQueue(self)
 
+    # RPC runner
+    self.rpc = rpc.RpcRunner(self)
+
     # setting this also locks the class against attribute modifications
     self.__class__._instance = self