Commit 4b5e8271 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 4dce1a83
...@@ -117,7 +117,7 @@ class Processor(object): ...@@ -117,7 +117,7 @@ class Processor(object):
""" """
write_count = self.context.cfg.write_count write_count = self.context.cfg.write_count
lu.CheckPrereq() 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) h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
lu.HooksCallBack(constants.HOOKS_PHASE_PRE, h_results, lu.HooksCallBack(constants.HOOKS_PHASE_PRE, h_results,
self._feedback_fn, None) self._feedback_fn, None)
...@@ -282,9 +282,8 @@ class HooksMaster(object): ...@@ -282,9 +282,8 @@ class HooksMaster(object):
which behaves the same works. which behaves the same works.
""" """
def __init__(self, callfn, proc, lu): def __init__(self, callfn, lu):
self.callfn = callfn self.callfn = callfn
self.proc = proc
self.lu = lu self.lu = lu
self.op = lu.op self.op = lu.op
self.env, node_list_pre, node_list_post = self._BuildEnv() self.env, node_list_pre, node_list_post = self._BuildEnv()
...@@ -361,8 +360,8 @@ class HooksMaster(object): ...@@ -361,8 +360,8 @@ class HooksMaster(object):
continue continue
msg = res.RemoteFailMsg() msg = res.RemoteFailMsg()
if msg: if msg:
self.proc.LogWarning("Communication failure to node %s: %s", self.lu.LogWarning("Communication failure to node %s: %s",
node_name, msg) node_name, msg)
continue continue
for script, hkr, output in res.payload: for script, hkr, output in res.payload:
if hkr == constants.HKR_FAIL: if hkr == constants.HKR_FAIL:
......
...@@ -240,14 +240,14 @@ class TestHooksMaster(unittest.TestCase): ...@@ -240,14 +240,14 @@ class TestHooksMaster(unittest.TestCase):
def testTotalFalse(self): def testTotalFalse(self):
"""Test complete rpc failure""" """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, self.failUnlessRaises(errors.HooksFailure,
hm.RunPhase, constants.HOOKS_PHASE_PRE) hm.RunPhase, constants.HOOKS_PHASE_PRE)
hm.RunPhase(constants.HOOKS_PHASE_POST) hm.RunPhase(constants.HOOKS_PHASE_POST)
def testIndividualFalse(self): def testIndividualFalse(self):
"""Test individual node failure""" """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) hm.RunPhase(constants.HOOKS_PHASE_PRE)
#self.failUnlessRaises(errors.HooksFailure, #self.failUnlessRaises(errors.HooksFailure,
# hm.RunPhase, constants.HOOKS_PHASE_PRE) # hm.RunPhase, constants.HOOKS_PHASE_PRE)
...@@ -255,14 +255,14 @@ class TestHooksMaster(unittest.TestCase): ...@@ -255,14 +255,14 @@ class TestHooksMaster(unittest.TestCase):
def testScriptFalse(self): def testScriptFalse(self):
"""Test individual rpc failure""" """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, self.failUnlessRaises(errors.HooksAbort,
hm.RunPhase, constants.HOOKS_PHASE_PRE) hm.RunPhase, constants.HOOKS_PHASE_PRE)
hm.RunPhase(constants.HOOKS_PHASE_POST) hm.RunPhase(constants.HOOKS_PHASE_POST)
def testScriptSucceed(self): def testScriptSucceed(self):
"""Test individual rpc failure""" """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): for phase in (constants.HOOKS_PHASE_PRE, constants.HOOKS_PHASE_POST):
hm.RunPhase(phase) hm.RunPhase(phase)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment