Commit 77b657a3 authored by Guido Trotter's avatar Guido Trotter

Pass context to LUs

Rather than passing a ConfigWriter to the LUs we'll pass the whole
context, from which a ConfigWriter can be extracted, but we can also
access the GanetiLockManager. This also fixes the places where a FakeLU
is created.

Reviewed-by: iustinp
parent f4555db2
......@@ -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:
......
......@@ -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)
......
......@@ -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"""
......
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