Change the signature of some methods of mcpu.Processor
[ganeti-local] / lib / mcpu.py
index 2f89842..139a3bd 100644 (file)
@@ -84,22 +84,23 @@ class Processor(object):
     opcodes.OpDelTags: cmdlib.LUDelTags,
     }
 
-
-  def __init__(self):
+  def __init__(self, feedback=None):
     """Constructor for Processor
 
+    Args:
+     - feedback_fn: the feedback function (taking one string) to be run when
+                    interesting events are happening
     """
     self.cfg = None
     self.sstore = None
+    self._feedback_fn = feedback
 
-  def ExecOpCode(self, op, feedback_fn):
+  def ExecOpCode(self, op):
     """Execute an opcode.
 
     Args:
      - cfg: the configuration in which we execute this opcode
      - opcode: the opcode to be executed
-     - feedback_fn: the feedback function (taking one string) to be run when
-                    interesting events are happening
 
     """
     if not isinstance(op, opcodes.OpCode):
@@ -121,7 +122,7 @@ class Processor(object):
     lu.CheckPrereq()
     hm = HooksMaster(rpc.call_hooks_runner, lu)
     hm.RunPhase(constants.HOOKS_PHASE_PRE)
-    result = lu.Exec(feedback_fn)
+    result = lu.Exec(self._feedback_fn)
     hm.RunPhase(constants.HOOKS_PHASE_POST)
     if lu.cfg is not None:
       # we use lu.cfg and not self.cfg as for init cluster, self.cfg
@@ -132,15 +133,13 @@ class Processor(object):
 
     return result
 
-  def ChainOpCode(self, op, feedback_fn):
+  def ChainOpCode(self, op):
     """Chain and execute an opcode.
 
     This is used by LUs when they need to execute a child LU.
 
     Args:
      - opcode: the opcode to be executed
-     - feedback_fn: the feedback function (taking one string) to be run when
-                    interesting events are happening
 
     """
     if not isinstance(op, opcodes.OpCode):
@@ -160,7 +159,7 @@ class Processor(object):
     #if do_hooks:
     #  hm = HooksMaster(rpc.call_hooks_runner, lu)
     #  hm.RunPhase(constants.HOOKS_PHASE_PRE)
-    result = lu.Exec(feedback_fn)
+    result = lu.Exec(self._feedback_fn)
     #if do_hooks:
     #  hm.RunPhase(constants.HOOKS_PHASE_POST)
     return result