Revision fed67843 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
3216 | 3216 |
|
3217 | 3217 |
""" |
3218 | 3218 |
REG_BGL = False |
3219 |
_SKIP_MASTER = (constants.OOB_POWER_OFF, constants.OOB_POWER_CYCLE) |
|
3219 | 3220 |
|
3220 | 3221 |
def CheckPrereq(self): |
3221 | 3222 |
"""Check prerequisites. |
... | ... | |
3230 | 3231 |
self.nodes = [] |
3231 | 3232 |
self.master_node = self.cfg.GetMasterNode() |
3232 | 3233 |
|
3233 |
if self.op.command in (constants.OOB_POWER_OFF, constants.OOB_POWER_CYCLE): |
|
3234 |
# This does two things, it checks if master is in the list and if so and |
|
3235 |
# force_master is set it puts it to the end so the master is done last |
|
3236 |
try: |
|
3234 |
if self.op.node_names: |
|
3235 |
if self.op.command in self._SKIP_MASTER: |
|
3236 |
if self.master_node in self.op.node_names: |
|
3237 |
master_node_obj = self.cfg.GetNodeInfo(self.master_node) |
|
3238 |
master_oob_handler = _SupportsOob(self.cfg, master_node_obj) |
|
3239 |
|
|
3240 |
if master_oob_handler: |
|
3241 |
additional_text = ("Run '%s %s %s' if you want to operate on the" |
|
3242 |
" master regardless") % (master_oob_handler, |
|
3243 |
self.op.command, |
|
3244 |
self.master_node) |
|
3245 |
else: |
|
3246 |
additional_text = "The master node does not support out-of-band" |
|
3247 |
|
|
3248 |
raise errors.OpPrereqError(("Operating on the master node %s is not" |
|
3249 |
" allowed for %s\n%s") % |
|
3250 |
(self.master_node, self.op.command, |
|
3251 |
additional_text), errors.ECODE_INVAL) |
|
3252 |
else: |
|
3253 |
self.op.node_names = self.cfg.GetNodeList() |
|
3254 |
if self.op.command in self._SKIP_MASTER: |
|
3237 | 3255 |
self.op.node_names.remove(self.master_node) |
3238 |
except ValueError: |
|
3239 |
pass |
|
3240 |
else: |
|
3241 |
if self.op.force_master: |
|
3242 |
self.op.node_names.append(self.master_node) |
|
3243 |
else: |
|
3244 |
self.LogWarning("Master %s was skipped, use the force master" |
|
3245 |
" option to operate on the master too", |
|
3246 |
self.master_node) |
|
3247 |
if not self.op.node_names: |
|
3248 |
raise errors.OpPrereqError("No nodes left to operate on, aborting", |
|
3249 |
errors.ECODE_INVAL) |
|
3250 | 3256 |
|
3251 |
assert (self.master_node not in self.op.node_names or
|
|
3252 |
self.op.node_names[-1] == self.master_node)
|
|
3257 |
if self.op.command in self._SKIP_MASTER:
|
|
3258 |
assert self.master_node not in self.op.node_names
|
|
3253 | 3259 |
|
3254 | 3260 |
for node_name in self.op.node_names: |
3255 | 3261 |
node = self.cfg.GetNodeInfo(node_name) |
... | ... | |
3273 | 3279 |
if self.op.node_names: |
3274 | 3280 |
self.op.node_names = [_ExpandNodeName(self.cfg, name) |
3275 | 3281 |
for name in self.op.node_names] |
3282 |
lock_names = self.op.node_names |
|
3276 | 3283 |
else: |
3277 |
self.op.node_names = self.cfg.GetNodeList()
|
|
3284 |
lock_names = locking.ALL_SET
|
|
3278 | 3285 |
|
3279 | 3286 |
self.needed_locks = { |
3280 |
locking.LEVEL_NODE: self.op.node_names,
|
|
3287 |
locking.LEVEL_NODE: lock_names,
|
|
3281 | 3288 |
} |
3282 | 3289 |
|
3283 | 3290 |
def Exec(self, feedback_fn): |
Also available in: Unified diff