Revision 0306ff62 lib/mcpu.py
b/lib/mcpu.py | ||
---|---|---|
427 | 427 |
self.lu = lu |
428 | 428 |
self.op = lu.op |
429 | 429 |
self.env, node_list_pre, node_list_post = self._BuildEnv() |
430 |
self.node_list = {constants.HOOKS_PHASE_PRE: node_list_pre, |
|
431 |
constants.HOOKS_PHASE_POST: node_list_post} |
|
430 |
self.node_list = { |
|
431 |
constants.HOOKS_PHASE_PRE: node_list_pre, |
|
432 |
constants.HOOKS_PHASE_POST: node_list_post, |
|
433 |
} |
|
432 | 434 |
|
433 | 435 |
def _BuildEnv(self): |
434 | 436 |
"""Compute the environment and the target nodes. |
... | ... | |
485 | 487 |
@raise errors.HooksAbort: on failure of one of the hooks |
486 | 488 |
|
487 | 489 |
""" |
488 |
if not self.node_list[phase] and not nodes: |
|
490 |
if nodes is None: |
|
491 |
nodes = self.node_list[phase] |
|
492 |
|
|
493 |
if not nodes: |
|
489 | 494 |
# empty node list, we should not attempt to run this as either |
490 | 495 |
# we're in the cluster init phase and the rpc client part can't |
491 | 496 |
# even attempt to run, or this LU doesn't do hooks at all |
492 | 497 |
return |
493 |
hpath = self.lu.HPATH |
|
494 |
if nodes is not None: |
|
495 |
results = self._RunWrapper(nodes, hpath, phase) |
|
496 |
else: |
|
497 |
results = self._RunWrapper(self.node_list[phase], hpath, phase) |
|
498 |
errs = [] |
|
498 |
|
|
499 |
results = self._RunWrapper(nodes, self.lu.HPATH, phase) |
|
499 | 500 |
if not results: |
500 | 501 |
msg = "Communication Failure" |
501 | 502 |
if phase == constants.HOOKS_PHASE_PRE: |
... | ... | |
503 | 504 |
else: |
504 | 505 |
self.lu.LogWarning(msg) |
505 | 506 |
return results |
507 |
|
|
508 |
errs = [] |
|
506 | 509 |
for node_name in results: |
507 | 510 |
res = results[node_name] |
508 | 511 |
if res.offline: |
509 | 512 |
continue |
513 |
|
|
510 | 514 |
msg = res.fail_msg |
511 | 515 |
if msg: |
512 | 516 |
self.lu.LogWarning("Communication failure to node %s: %s", |
513 | 517 |
node_name, msg) |
514 | 518 |
continue |
519 |
|
|
515 | 520 |
for script, hkr, output in res.payload: |
516 | 521 |
if hkr == constants.HKR_FAIL: |
517 | 522 |
if phase == constants.HOOKS_PHASE_PRE: |
... | ... | |
521 | 526 |
output = "(no output)" |
522 | 527 |
self.lu.LogWarning("On %s script %s failed, output: %s" % |
523 | 528 |
(node_name, script, output)) |
529 |
|
|
524 | 530 |
if errs and phase == constants.HOOKS_PHASE_PRE: |
525 | 531 |
raise errors.HooksAbort(errs) |
532 |
|
|
526 | 533 |
return results |
527 | 534 |
|
528 | 535 |
def RunConfigUpdate(self): |
Also available in: Unified diff