Revision aac4511a lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
6096 | 6096 |
HTYPE = constants.HTYPE_NODE |
6097 | 6097 |
REQ_BGL = False |
6098 | 6098 |
|
6099 |
def CheckArguments(self): |
|
6100 |
_CheckIAllocatorOrNode(self, "iallocator", "remote_node") |
|
6101 |
|
|
6099 | 6102 |
def ExpandNames(self): |
6100 | 6103 |
self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name) |
6101 | 6104 |
|
6102 |
self.needed_locks = { |
|
6103 |
locking.LEVEL_NODE: [self.op.node_name], |
|
6104 |
} |
|
6105 |
|
|
6106 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND |
|
6105 |
self.needed_locks = {} |
|
6107 | 6106 |
|
6108 | 6107 |
# Create tasklets for migrating instances for all instances on this node |
6109 | 6108 |
names = [] |
6110 | 6109 |
tasklets = [] |
6111 | 6110 |
|
6111 |
self.lock_all_nodes = False |
|
6112 |
|
|
6112 | 6113 |
for inst in _GetNodePrimaryInstances(self.cfg, self.op.node_name): |
6113 | 6114 |
logging.debug("Migrating instance %s", inst.name) |
6114 | 6115 |
names.append(inst.name) |
6115 | 6116 |
|
6116 |
tasklets.append(TLMigrateInstance(self, inst.name, False)) |
|
6117 |
tasklets.append(TLMigrateInstance(self, inst.name, False, |
|
6118 |
self.op.iallocator, None)) |
|
6119 |
|
|
6120 |
if inst.disk_template in constants.DTS_EXT_MIRROR: |
|
6121 |
# We need to lock all nodes, as the iallocator will choose the |
|
6122 |
# destination nodes afterwards |
|
6123 |
self.lock_all_nodes = True |
|
6117 | 6124 |
|
6118 | 6125 |
self.tasklets = tasklets |
6119 | 6126 |
|
6127 |
# Declare node locks |
|
6128 |
if self.lock_all_nodes: |
|
6129 |
self.needed_locks[locking.LEVEL_NODE] = locking.ALL_SET |
|
6130 |
else: |
|
6131 |
self.needed_locks[locking.LEVEL_NODE] = [self.op.node_name] |
|
6132 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_APPEND |
|
6133 |
|
|
6120 | 6134 |
# Declare instance locks |
6121 | 6135 |
self.needed_locks[locking.LEVEL_INSTANCE] = names |
6122 | 6136 |
|
6123 | 6137 |
def DeclareLocks(self, level): |
6124 |
if level == locking.LEVEL_NODE: |
|
6138 |
if level == locking.LEVEL_NODE and not self.lock_all_nodes:
|
|
6125 | 6139 |
self._LockInstancesNodes() |
6126 | 6140 |
|
6127 | 6141 |
def BuildHooksEnv(self): |
Also available in: Unified diff