Revision 9e289e36
b/daemons/ganeti-watcher | ||
---|---|---|
94 | 94 |
EnsureDaemon(constants.CONFD) |
95 | 95 |
|
96 | 96 |
|
97 |
def RunWatcherHooks(): |
|
98 |
"""Run the watcher hooks. |
|
99 |
|
|
100 |
""" |
|
101 |
hooks_dir = os.path.join(constants.HOOKS_BASE_DIR, |
|
102 |
constants.HOOKS_NAME_WATCHER) |
|
103 |
|
|
104 |
try: |
|
105 |
results = utils.RunParts(hooks_dir) |
|
106 |
except Exception, msg: # pylint: disable-msg=W0703 |
|
107 |
logging.critical("RunParts %s failed: %s", hooks_dir, msg) |
|
108 |
|
|
109 |
for (relname, status, runresult) in results: |
|
110 |
if status == constants.RUNPARTS_SKIP: |
|
111 |
logging.debug("Watcher hook %s: skipped", relname) |
|
112 |
elif status == constants.RUNPARTS_ERR: |
|
113 |
logging.warning("Watcher hook %s: error (%s)", relname, runresult) |
|
114 |
elif status == constants.RUNPARTS_RUN: |
|
115 |
if runresult.failed: |
|
116 |
logging.warning("Watcher hook %s: failed (exit: %d) (output: %s)", |
|
117 |
relname, runresult.exit_code, runresult.output) |
|
118 |
else: |
|
119 |
logging.debug("Watcher hook %s: success (output: %s)", relname, |
|
120 |
runresult.output) |
|
121 |
|
|
97 | 122 |
class WatcherState(object): |
98 | 123 |
"""Interface to a state file recording restart attempts. |
99 | 124 |
|
... | ... | |
488 | 513 |
update_file = False |
489 | 514 |
try: |
490 | 515 |
StartNodeDaemons() |
516 |
RunWatcherHooks() |
|
491 | 517 |
|
492 | 518 |
notepad = WatcherState() |
493 | 519 |
try: |
b/lib/constants.py | ||
---|---|---|
191 | 191 |
HOOKS_PHASE_PRE = "pre" |
192 | 192 |
HOOKS_PHASE_POST = "post" |
193 | 193 |
HOOKS_NAME_CFGUPDATE = "config-update" |
194 |
HOOKS_NAME_WATCHER = "watcher" |
|
194 | 195 |
HOOKS_VERSION = 2 |
195 | 196 |
|
196 | 197 |
# hooks subject type (what object type does the LU deal with) |
Also available in: Unified diff