7212 |
7212 |
(self.op.name, self.op.node_name))
|
7213 |
7213 |
|
7214 |
7214 |
|
|
7215 |
class LUNodeEvacuationStrategy(NoHooksLU):
|
|
7216 |
"""Computes the node evacuation strategy.
|
|
7217 |
|
|
7218 |
"""
|
|
7219 |
_OP_REQP = ["nodes"]
|
|
7220 |
REQ_BGL = False
|
|
7221 |
|
|
7222 |
def CheckArguments(self):
|
|
7223 |
if not hasattr(self.op, "remote_node"):
|
|
7224 |
self.op.remote_node = None
|
|
7225 |
if not hasattr(self.op, "iallocator"):
|
|
7226 |
self.op.iallocator = None
|
|
7227 |
if self.op.remote_node is not None and self.op.iallocator is not None:
|
|
7228 |
raise errors.OpPrereqError("Give either the iallocator or the new"
|
|
7229 |
" secondary, not both", errors.ECODE_INVAL)
|
|
7230 |
|
|
7231 |
def ExpandNames(self):
|
|
7232 |
self.op.nodes = _GetWantedNodes(self, self.op.nodes)
|
|
7233 |
self.needed_locks = locks = {}
|
|
7234 |
if self.op.remote_node is None:
|
|
7235 |
locks[locking.LEVEL_NODE] = locking.ALL_SET
|
|
7236 |
else:
|
|
7237 |
self.op.remote_node = _ExpandNodeName(self.cfg, self.op.remote_node)
|
|
7238 |
locks[locking.LEVEL_NODE] = self.op.nodes + [self.op.remote_node]
|
|
7239 |
|
|
7240 |
def CheckPrereq(self):
|
|
7241 |
pass
|
|
7242 |
|
|
7243 |
def Exec(self, feedback_fn):
|
|
7244 |
if self.op.remote_node is not None:
|
|
7245 |
instances = []
|
|
7246 |
for node in self.op.nodes:
|
|
7247 |
instances.extend(_GetNodeSecondaryInstances(self.cfg, node))
|
|
7248 |
result = []
|
|
7249 |
for i in instances:
|
|
7250 |
if i.primary_node == self.op.remote_node:
|
|
7251 |
raise errors.OpPrereqError("Node %s is the primary node of"
|
|
7252 |
" instance %s, cannot use it as"
|
|
7253 |
" secondary" %
|
|
7254 |
(self.op.remote_node, i.name),
|
|
7255 |
errors.ECODE_INVAL)
|
|
7256 |
result.append([i.name, self.op.remote_node])
|
|
7257 |
else:
|
|
7258 |
ial = IAllocator(self.cfg, self.rpc,
|
|
7259 |
mode=constants.IALLOCATOR_MODE_MEVAC,
|
|
7260 |
evac_nodes=self.op.nodes)
|
|
7261 |
ial.Run(self.op.iallocator, validate=True)
|
|
7262 |
if not ial.success:
|
|
7263 |
raise errors.OpExecError("No valid evacuation solution: %s" % ial.info,
|
|
7264 |
errors.ECODE_NORES)
|
|
7265 |
result = ial.result
|
|
7266 |
return result
|
|
7267 |
|
|
7268 |
|
7215 |
7269 |
class LUGrowDisk(LogicalUnit):
|
7216 |
7270 |
"""Grow a disk of an instance.
|
7217 |
7271 |
|