diff --git a/lib/cmdlib.py b/lib/cmdlib.py index afebafce06f3de505131be581ae8cff14d6c6ccb..9859c8590e3c7a7e03228a3317232fc5ecc32c44 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -69,7 +69,7 @@ class LogicalUnit(object): REQ_WSSTORE = False REQ_BGL = True - def __init__(self, processor, op, cfg, sstore): + def __init__(self, processor, op, context, sstore): """Constructor for LogicalUnit. This needs to be overriden in derived classes in order to check op @@ -78,8 +78,9 @@ class LogicalUnit(object): """ self.proc = processor self.op = op - self.cfg = cfg + self.cfg = context.cfg self.sstore = sstore + self.context = context self.__ssh = None for attr_name in self._OP_REQP: diff --git a/lib/mcpu.py b/lib/mcpu.py index be9a3721e4a23751327d2fb1f3cfd696e2619411..fab8b627937ee0cf0e98d73af61f6c3fdd8f28d1 100644 --- a/lib/mcpu.py +++ b/lib/mcpu.py @@ -129,7 +129,7 @@ class Processor(object): shared=not lu_class.REQ_BGL) try: self.exclusive_BGL = lu_class.REQ_BGL - lu = lu_class(self, op, self.context.cfg, sstore) + lu = lu_class(self, op, self.context, sstore) lu.CheckPrereq() hm = HooksMaster(rpc.call_hooks_runner, self, lu) h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE) @@ -177,7 +177,7 @@ class Processor(object): sstore = ssconf.SimpleStore() #do_hooks = lu_class.HPATH is not None - lu = lu_class(self, op, self.context.cfg, sstore) + lu = lu_class(self, op, self.context, sstore) lu.CheckPrereq() #if do_hooks: # hm = HooksMaster(rpc.call_hooks_runner, self, lu) diff --git a/test/ganeti.hooks_unittest.py b/test/ganeti.hooks_unittest.py index 441119a3dc91bc95745447e02062e9cf6097c0bd..001810733cce8322bd76eacc6dad9eb5cb86e4ac 100755 --- a/test/ganeti.hooks_unittest.py +++ b/test/ganeti.hooks_unittest.py @@ -36,7 +36,7 @@ from ganeti import constants from ganeti import cmdlib from ganeti.constants import HKR_SUCCESS, HKR_FAIL, HKR_SKIP -from mocks import FakeConfig, FakeSStore, FakeProc +from mocks import FakeConfig, FakeSStore, FakeProc, FakeContext class FakeLU(cmdlib.LogicalUnit): HPATH = "test" @@ -226,10 +226,10 @@ class TestHooksMaster(unittest.TestCase): for node_name in node_list]) def setUp(self): - self.cfg = FakeConfig() self.sstore = FakeSStore() self.op = opcodes.OpCode() - self.lu = FakeLU(None, self.op, self.cfg, self.sstore) + self.context = FakeContext() + self.lu = FakeLU(None, self.op, self.context, self.sstore) def testTotalFalse(self): """Test complete rpc failure"""