Revision 9a833381
b/lib/cmdlib.py | ||
---|---|---|
6056 | 6056 |
HTYPE = constants.HTYPE_NODE |
6057 | 6057 |
REQ_BGL = False |
6058 | 6058 |
|
6059 |
def CheckArguments(self): |
|
6060 |
_CheckIAllocatorOrNode(self, "iallocator", "remote_node") |
|
6061 |
|
|
6059 | 6062 |
def ExpandNames(self): |
6060 | 6063 |
self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name) |
6061 | 6064 |
|
6062 |
self.needed_locks = { |
|
6063 |
locking.LEVEL_NODE: [self.op.node_name], |
|
6064 |
} |
|
6065 |
|
|
6066 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND |
|
6065 |
self.needed_locks = {} |
|
6067 | 6066 |
|
6068 | 6067 |
# Create tasklets for migrating instances for all instances on this node |
6069 | 6068 |
names = [] |
6070 | 6069 |
tasklets = [] |
6071 | 6070 |
|
6071 |
self.lock_all_nodes = False |
|
6072 |
|
|
6072 | 6073 |
for inst in _GetNodePrimaryInstances(self.cfg, self.op.node_name): |
6073 | 6074 |
logging.debug("Migrating instance %s", inst.name) |
6074 | 6075 |
names.append(inst.name) |
6075 | 6076 |
|
6076 |
tasklets.append(TLMigrateInstance(self, inst.name, False)) |
|
6077 |
tasklets.append(TLMigrateInstance(self, inst.name, False, |
|
6078 |
self.op.iallocator, None)) |
|
6079 |
|
|
6080 |
if inst.disk_template in constants.DTS_EXT_MIRROR: |
|
6081 |
# We need to lock all nodes, as the iallocator will choose the |
|
6082 |
# destination nodes afterwards |
|
6083 |
self.lock_all_nodes = True |
|
6077 | 6084 |
|
6078 | 6085 |
self.tasklets = tasklets |
6079 | 6086 |
|
6087 |
# Declare node locks |
|
6088 |
if self.lock_all_nodes: |
|
6089 |
self.needed_locks[locking.LEVEL_NODE] = locking.ALL_SET |
|
6090 |
else: |
|
6091 |
self.needed_locks[locking.LEVEL_NODE] = [self.op.node_name] |
|
6092 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND |
|
6093 |
|
|
6080 | 6094 |
# Declare instance locks |
6081 | 6095 |
self.needed_locks[locking.LEVEL_INSTANCE] = names |
6082 | 6096 |
|
6083 | 6097 |
def DeclareLocks(self, level): |
6084 |
if level == locking.LEVEL_NODE: |
|
6098 |
if level == locking.LEVEL_NODE and not self.lock_all_nodes:
|
|
6085 | 6099 |
self._LockInstancesNodes() |
6086 | 6100 |
|
6087 | 6101 |
def BuildHooksEnv(self): |
Also available in: Unified diff