Revision 4167825b lib/mcpu.py
b/lib/mcpu.py | ||
---|---|---|
170 | 170 |
self.callfn = callfn |
171 | 171 |
self.lu = lu |
172 | 172 |
self.op = lu.op |
173 |
self.hpath = self.lu.HPATH |
|
174 | 173 |
self.env, node_list_pre, node_list_post = self._BuildEnv() |
175 |
|
|
176 | 174 |
self.node_list = {constants.HOOKS_PHASE_PRE: node_list_pre, |
177 | 175 |
constants.HOOKS_PHASE_POST: node_list_post} |
178 | 176 |
|
... | ... | |
198 | 196 |
else: |
199 | 197 |
lu_nodes_pre = lu_nodes_post = [] |
200 | 198 |
|
199 |
return env, frozenset(lu_nodes_pre), frozenset(lu_nodes_post) |
|
200 |
|
|
201 |
def _RunWrapper(self, node_list, hpath, phase): |
|
202 |
"""Simple wrapper over self.callfn. |
|
203 |
|
|
204 |
This method fixes the environment before doing the rpc call. |
|
205 |
|
|
206 |
""" |
|
207 |
env = self.env.copy() |
|
208 |
env["GANETI_HOOKS_PHASE"] = phase |
|
209 |
env["GANETI_HOOKS_PATH"] = hpath |
|
201 | 210 |
if self.lu.sstore is not None: |
202 | 211 |
env["GANETI_CLUSTER"] = self.lu.sstore.GetClusterName() |
203 | 212 |
env["GANETI_MASTER"] = self.lu.sstore.GetMasterNode() |
204 | 213 |
|
205 |
for key in env: |
|
206 |
if not isinstance(env[key], str): |
|
207 |
env[key] = str(env[key]) |
|
214 |
env = dict([(str(key), str(val)) for key, val in env.iteritems()]) |
|
208 | 215 |
|
209 |
return env, frozenset(lu_nodes_pre), frozenset(lu_nodes_post)
|
|
216 |
return self.callfn(node_list, hpath, phase, env)
|
|
210 | 217 |
|
211 | 218 |
def RunPhase(self, phase): |
212 | 219 |
"""Run all the scripts for a phase. |
... | ... | |
219 | 226 |
# we're in the cluster init phase and the rpc client part can't |
220 | 227 |
# even attempt to run, or this LU doesn't do hooks at all |
221 | 228 |
return |
222 |
self.env["GANETI_HOOKS_PHASE"] = str(phase)
|
|
223 |
results = self.callfn(self.node_list[phase], self.hpath, phase, self.env)
|
|
229 |
hpath = self.lu.HPATH
|
|
230 |
results = self._RunWrapper(self.node_list[phase], hpath, phase)
|
|
224 | 231 |
if phase == constants.HOOKS_PHASE_PRE: |
225 | 232 |
errs = [] |
226 | 233 |
if not results: |
Also available in: Unified diff