Revision 9aacb199 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
593 | 593 |
raise errors.OpPrereqError(msg, errors.ECODE_INVAL) |
594 | 594 |
|
595 | 595 |
|
596 |
def _CheckNodeOnline(lu, node): |
|
596 |
def _CheckNodeOnline(lu, node, msg=None):
|
|
597 | 597 |
"""Ensure that a given node is online. |
598 | 598 |
|
599 | 599 |
@param lu: the LU on behalf of which we make the check |
600 | 600 |
@param node: the node to check |
601 |
@param msg: if passed, should be a message to replace the default one |
|
601 | 602 |
@raise errors.OpPrereqError: if the node is offline |
602 | 603 |
|
603 | 604 |
""" |
605 |
if msg is None: |
|
606 |
msg = "Can't use offline node" |
|
604 | 607 |
if lu.cfg.GetNodeInfo(node).offline: |
605 |
raise errors.OpPrereqError("Can't use offline node %s" % node, |
|
606 |
errors.ECODE_STATE) |
|
608 |
raise errors.OpPrereqError("%s: %s" % (msg, node), errors.ECODE_STATE) |
|
607 | 609 |
|
608 | 610 |
|
609 | 611 |
def _CheckNodeNotDrained(lu, node): |
... | ... | |
4994 | 4996 |
instance = self.cfg.GetInstanceInfo(self.op.instance_name) |
4995 | 4997 |
assert instance is not None, \ |
4996 | 4998 |
"Cannot retrieve locked instance %s" % self.op.instance_name |
4997 |
_CheckNodeOnline(self, instance.primary_node) |
|
4999 |
_CheckNodeOnline(self, instance.primary_node, "Instance primary node" |
|
5000 |
" offline, cannot reinstall") |
|
5001 |
for node in instance.secondary_nodes: |
|
5002 |
_CheckNodeOnline(self, node, "Instance secondary node offline," |
|
5003 |
" cannot reinstall") |
|
4998 | 5004 |
|
4999 | 5005 |
if instance.disk_template == constants.DT_DISKLESS: |
5000 | 5006 |
raise errors.OpPrereqError("Instance '%s' has no disks" % |
Also available in: Unified diff