112 |
112 |
if lu_class.REQ_CLUSTER and self.cfg is None:
|
113 |
113 |
self.cfg = config.ConfigWriter()
|
114 |
114 |
self.sstore = ssconf.SimpleStore()
|
|
115 |
if self.cfg is not None:
|
|
116 |
write_count = self.cfg.write_count
|
|
117 |
else:
|
|
118 |
write_count = 0
|
115 |
119 |
lu = lu_class(self, op, self.cfg, self.sstore)
|
116 |
120 |
lu.CheckPrereq()
|
117 |
121 |
hm = HooksMaster(rpc.call_hooks_runner, lu)
|
118 |
122 |
hm.RunPhase(constants.HOOKS_PHASE_PRE)
|
119 |
123 |
result = lu.Exec(feedback_fn)
|
120 |
124 |
hm.RunPhase(constants.HOOKS_PHASE_POST)
|
|
125 |
if lu.cfg is not None:
|
|
126 |
# we use lu.cfg and not self.cfg as for init cluster, self.cfg
|
|
127 |
# is None but lu.cfg has been recently initialized in the
|
|
128 |
# lu.Exec method
|
|
129 |
if write_count != lu.cfg.write_count:
|
|
130 |
hm.RunConfigUpdate()
|
|
131 |
|
121 |
132 |
return result
|
122 |
133 |
|
123 |
134 |
def ChainOpCode(self, op, feedback_fn):
|
... | ... | |
186 |
197 |
"GANETI_HOOKS_VERSION": constants.HOOKS_VERSION,
|
187 |
198 |
"GANETI_OP_CODE": self.op.OP_ID,
|
188 |
199 |
"GANETI_OBJECT_TYPE": self.lu.HTYPE,
|
|
200 |
"GANETI_DATA_DIR": constants.DATA_DIR,
|
189 |
201 |
}
|
190 |
202 |
|
191 |
203 |
if self.lu.HPATH is not None:
|
... | ... | |
243 |
255 |
errs.append((node_name, script, output))
|
244 |
256 |
if errs:
|
245 |
257 |
raise errors.HooksAbort(errs)
|
|
258 |
|
|
259 |
def RunConfigUpdate(self):
|
|
260 |
"""Run the special configuration update hook
|
|
261 |
|
|
262 |
This is a special hook that runs only on the master after each
|
|
263 |
top-level LI if the configuration has been updated.
|
|
264 |
|
|
265 |
"""
|
|
266 |
phase = constants.HOOKS_PHASE_POST
|
|
267 |
hpath = constants.HOOKS_NAME_CFGUPDATE
|
|
268 |
if self.lu.sstore is None:
|
|
269 |
raise errors.ProgrammerError("Null sstore on config update hook")
|
|
270 |
nodes = [self.lu.sstore.GetMasterNode()]
|
|
271 |
results = self._RunWrapper(nodes, hpath, phase)
|