From 4b5e82711fccb3b961d9fa86b36abcf67ea7e44e Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Mon, 24 Aug 2009 13:56:19 +0200 Subject: [PATCH] Remove extra argument from HooksMaster class The mcpu.py:HooksMaster class needs to have a proc attribute/argument to init in ordet to call its LogWarning method. However, this is available from the 'lu' attribute, so we can remove this dependency. Signed-off-by: Iustin Pop Reviewed-by: Michael Hanselmann --- lib/mcpu.py | 9 ++++----- test/ganeti.hooks_unittest.py | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/mcpu.py b/lib/mcpu.py index ff5f5c3..50aaabf 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -117,7 +117,7 @@ class Processor(object): """ write_count = self.context.cfg.write_count lu.CheckPrereq() - hm = HooksMaster(self.rpc.call_hooks_runner, self, lu) + hm = HooksMaster(self.rpc.call_hooks_runner, lu) h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE) lu.HooksCallBack(constants.HOOKS_PHASE_PRE, h_results, self._feedback_fn, None) @@ -282,9 +282,8 @@ class HooksMaster(object): which behaves the same works. """ - def __init__(self, callfn, proc, lu): + def __init__(self, callfn, lu): self.callfn = callfn - self.proc = proc self.lu = lu self.op = lu.op self.env, node_list_pre, node_list_post = self._BuildEnv() @@ -361,8 +360,8 @@ class HooksMaster(object): continue msg = res.RemoteFailMsg() if msg: - self.proc.LogWarning("Communication failure to node %s: %s", - node_name, msg) + self.lu.LogWarning("Communication failure to node %s: %s", + node_name, msg) continue for script, hkr, output in res.payload: if hkr == constants.HKR_FAIL: diff --git a/test/ganeti.hooks_unittest.py b/test/ganeti.hooks_unittest.py index 5826f9b..55fa721 100755 --- a/test/ganeti.hooks_unittest.py +++ b/test/ganeti.hooks_unittest.py @@ -240,14 +240,14 @@ class TestHooksMaster(unittest.TestCase): def testTotalFalse(self): """Test complete rpc failure""" - hm = mcpu.HooksMaster(self._call_false, FakeProc(), self.lu) + hm = mcpu.HooksMaster(self._call_false, self.lu) self.failUnlessRaises(errors.HooksFailure, hm.RunPhase, constants.HOOKS_PHASE_PRE) hm.RunPhase(constants.HOOKS_PHASE_POST) def testIndividualFalse(self): """Test individual node failure""" - hm = mcpu.HooksMaster(self._call_nodes_false, FakeProc(), self.lu) + hm = mcpu.HooksMaster(self._call_nodes_false, self.lu) hm.RunPhase(constants.HOOKS_PHASE_PRE) #self.failUnlessRaises(errors.HooksFailure, # hm.RunPhase, constants.HOOKS_PHASE_PRE) @@ -255,14 +255,14 @@ class TestHooksMaster(unittest.TestCase): def testScriptFalse(self): """Test individual rpc failure""" - hm = mcpu.HooksMaster(self._call_script_fail, FakeProc(), self.lu) + hm = mcpu.HooksMaster(self._call_script_fail, self.lu) self.failUnlessRaises(errors.HooksAbort, hm.RunPhase, constants.HOOKS_PHASE_PRE) hm.RunPhase(constants.HOOKS_PHASE_POST) def testScriptSucceed(self): """Test individual rpc failure""" - hm = mcpu.HooksMaster(self._call_script_succeed, FakeProc(), self.lu) + hm = mcpu.HooksMaster(self._call_script_succeed, self.lu) for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST): hm.RunPhase(phase) -- 1.7.10.4