Revision a4e588b7 lib/cmdlib.py

b/lib/cmdlib.py
3201 3201
    if self.op.instances:
3202 3202
      self.wanted_names = _GetWantedInstances(self, self.op.instances)
3203 3203
      self.needed_locks = {
3204
        locking.LEVEL_NODE: [],
3204
        locking.LEVEL_NODE_RES: [],
3205 3205
        locking.LEVEL_INSTANCE: self.wanted_names,
3206 3206
        }
3207
      self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
3207
      self.recalculate_locks[locking.LEVEL_NODE_RES] = constants.LOCKS_REPLACE
3208 3208
    else:
3209 3209
      self.wanted_names = None
3210 3210
      self.needed_locks = {
3211
        locking.LEVEL_NODE: locking.ALL_SET,
3211
        locking.LEVEL_NODE_RES: locking.ALL_SET,
3212 3212
        locking.LEVEL_INSTANCE: locking.ALL_SET,
3213 3213
        }
3214 3214
    self.share_locks = _ShareAll()
3215 3215

  
3216 3216
  def DeclareLocks(self, level):
3217
    if level == locking.LEVEL_NODE and self.wanted_names is not None:
3218
      self._LockInstancesNodes(primary_only=True)
3217
    if level == locking.LEVEL_NODE_RES and self.wanted_names is not None:
3218
      self._LockInstancesNodes(primary_only=True, level=level)
3219 3219

  
3220 3220
  def CheckPrereq(self):
3221 3221
    """Check prerequisites.
......
3266 3266
      for idx, disk in enumerate(instance.disks):
3267 3267
        per_node_disks[pnode].append((instance, idx, disk))
3268 3268

  
3269
    assert not (frozenset(per_node_disks.keys()) -
3270
                self.owned_locks(locking.LEVEL_NODE_RES)), \
3271
      "Not owning correct locks"
3272
    assert not self.owned_locks(locking.LEVEL_NODE)
3273

  
3269 3274
    changed = []
3270 3275
    for node, dskl in per_node_disks.items():
3271 3276
      newl = [v[2].Copy() for v in dskl]

Also available in: Unified diff