Revision 1a8c0ce1 lib/mcpu.py
b/lib/mcpu.py | ||
---|---|---|
84 | 84 |
opcodes.OpDelTags: cmdlib.LUDelTags, |
85 | 85 |
} |
86 | 86 |
|
87 |
|
|
88 |
def __init__(self): |
|
87 |
def __init__(self, feedback=None): |
|
89 | 88 |
"""Constructor for Processor |
90 | 89 |
|
90 |
Args: |
|
91 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
92 |
interesting events are happening |
|
91 | 93 |
""" |
92 | 94 |
self.cfg = None |
93 | 95 |
self.sstore = None |
96 |
self._feedback_fn = feedback |
|
94 | 97 |
|
95 |
def ExecOpCode(self, op, feedback_fn):
|
|
98 |
def ExecOpCode(self, op): |
|
96 | 99 |
"""Execute an opcode. |
97 | 100 |
|
98 | 101 |
Args: |
99 | 102 |
- cfg: the configuration in which we execute this opcode |
100 | 103 |
- opcode: the opcode to be executed |
101 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
102 |
interesting events are happening |
|
103 | 104 |
|
104 | 105 |
""" |
105 | 106 |
if not isinstance(op, opcodes.OpCode): |
... | ... | |
121 | 122 |
lu.CheckPrereq() |
122 | 123 |
hm = HooksMaster(rpc.call_hooks_runner, lu) |
123 | 124 |
hm.RunPhase(constants.HOOKS_PHASE_PRE) |
124 |
result = lu.Exec(feedback_fn) |
|
125 |
result = lu.Exec(self._feedback_fn)
|
|
125 | 126 |
hm.RunPhase(constants.HOOKS_PHASE_POST) |
126 | 127 |
if lu.cfg is not None: |
127 | 128 |
# we use lu.cfg and not self.cfg as for init cluster, self.cfg |
... | ... | |
132 | 133 |
|
133 | 134 |
return result |
134 | 135 |
|
135 |
def ChainOpCode(self, op, feedback_fn):
|
|
136 |
def ChainOpCode(self, op): |
|
136 | 137 |
"""Chain and execute an opcode. |
137 | 138 |
|
138 | 139 |
This is used by LUs when they need to execute a child LU. |
139 | 140 |
|
140 | 141 |
Args: |
141 | 142 |
- opcode: the opcode to be executed |
142 |
- feedback_fn: the feedback function (taking one string) to be run when |
|
143 |
interesting events are happening |
|
144 | 143 |
|
145 | 144 |
""" |
146 | 145 |
if not isinstance(op, opcodes.OpCode): |
... | ... | |
160 | 159 |
#if do_hooks: |
161 | 160 |
# hm = HooksMaster(rpc.call_hooks_runner, lu) |
162 | 161 |
# hm.RunPhase(constants.HOOKS_PHASE_PRE) |
163 |
result = lu.Exec(feedback_fn) |
|
162 |
result = lu.Exec(self._feedback_fn)
|
|
164 | 163 |
#if do_hooks: |
165 | 164 |
# hm.RunPhase(constants.HOOKS_PHASE_POST) |
166 | 165 |
return result |
Also available in: Unified diff