Commit 1c901d13 authored by Guido Trotter's avatar Guido Trotter
Browse files

Processor: pass context in and use it.

The processor used to create a new ConfigWriter when it was initialized.
We now have one in the context, so we'll just recycle it. First of all
we'll pass the context in when creating a new Processor object, then
we'll just use context.cfg, which is granted to be initialized, wherever
we used self.cfg, and stop checking whether the config is already
initialized or not.

In the future the Processor will be able to use the context also to
acquire the BGL for LUs that require it, and to push the context down to
LUs that don't in order for them to manage their own locking.

Reviewed-by: iustinp
parent 7e55040e
......@@ -289,7 +289,7 @@ def PoolWorker(worker_id, incoming_queue, context):
print "worker %s processing job %s" % (worker_id, item.data.job_id)
#utils.Lock('cmd')
try:
proc = mcpu.Processor(feedback=lambda x: None)
proc = mcpu.Processor(context, feedback=lambda x: None)
try:
JobRunner(proc, item, context)
except errors.GenericError, err:
......
......@@ -89,14 +89,14 @@ class Processor(object):
opcodes.OpTestAllocator: cmdlib.LUTestAllocator,
}
def __init__(self, feedback=None):
def __init__(self, context, 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.context = context
self._feedback_fn = feedback
def ExecOpCode(self, op):
......@@ -119,13 +119,8 @@ class Processor(object):
else:
sstore = ssconf.SimpleStore()
if self.cfg is None:
self.cfg = config.ConfigWriter()
if self.cfg is not None:
write_count = self.cfg.write_count
else:
write_count = 0
lu = lu_class(self, op, self.cfg, sstore)
write_count = self.context.cfg.write_count
lu = lu_class(self, op, self.context.cfg, sstore)
lu.CheckPrereq()
hm = HooksMaster(rpc.call_hooks_runner, self, lu)
h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
......@@ -168,10 +163,8 @@ class Processor(object):
else:
sstore = ssconf.SimpleStore()
if self.cfg is None:
self.cfg = config.ConfigWriter()
#do_hooks = lu_class.HPATH is not None
lu = lu_class(self, op, self.cfg, sstore)
lu = lu_class(self, op, self.context.cfg, sstore)
lu.CheckPrereq()
#if do_hooks:
# hm = HooksMaster(rpc.call_hooks_runner, self, lu)
......
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