Revision cb92e7a1 lib/cmdlib.py

b/lib/cmdlib.py
10145 10145
  """
10146 10146
  REQ_BGL = False
10147 10147

  
10148
  _MODE2IALLOCATOR = {
10149
    constants.NODE_EVAC_PRI: constants.IALLOCATOR_NEVAC_PRI,
10150
    constants.NODE_EVAC_SEC: constants.IALLOCATOR_NEVAC_SEC,
10151
    constants.NODE_EVAC_ALL: constants.IALLOCATOR_NEVAC_ALL,
10152
    }
10153
  assert frozenset(_MODE2IALLOCATOR.keys()) == constants.NODE_EVAC_MODES
10154
  assert (frozenset(_MODE2IALLOCATOR.values()) ==
10155
          constants.IALLOCATOR_NEVAC_MODES)
10156

  
10148 10157
  def CheckArguments(self):
10149 10158
    _CheckIAllocatorOrNode(self, "iallocator", "remote_node")
10150 10159

  
......
10159 10168
        raise errors.OpPrereqError("Can not use evacuated node as a new"
10160 10169
                                   " secondary node", errors.ECODE_INVAL)
10161 10170

  
10162
      if self.op.mode != constants.IALLOCATOR_NEVAC_SEC:
10171
      if self.op.mode != constants.NODE_EVAC_SEC:
10163 10172
        raise errors.OpPrereqError("Without the use of an iallocator only"
10164 10173
                                   " secondary instances can be evacuated",
10165 10174
                                   errors.ECODE_INVAL)
......
10185 10194
    """Builds list of instances to operate on.
10186 10195

  
10187 10196
    """
10188
    assert self.op.mode in constants.IALLOCATOR_NEVAC_MODES
10197
    assert self.op.mode in constants.NODE_EVAC_MODES
10189 10198

  
10190
    if self.op.mode == constants.IALLOCATOR_NEVAC_PRI:
10199
    if self.op.mode == constants.NODE_EVAC_PRI:
10191 10200
      # Primary instances only
10192 10201
      inst_fn = _GetNodePrimaryInstances
10193 10202
      assert self.op.remote_node is None, \
10194 10203
        "Evacuating primary instances requires iallocator"
10195
    elif self.op.mode == constants.IALLOCATOR_NEVAC_SEC:
10204
    elif self.op.mode == constants.NODE_EVAC_SEC:
10196 10205
      # Secondary instances only
10197 10206
      inst_fn = _GetNodeSecondaryInstances
10198 10207
    else:
10199 10208
      # All instances
10200
      assert self.op.mode == constants.IALLOCATOR_NEVAC_ALL
10209
      assert self.op.mode == constants.NODE_EVAC_ALL
10201 10210
      inst_fn = _GetNodeInstances
10202 10211

  
10203 10212
    return inst_fn(self.cfg, self.op.node_name)
......
10272 10281
    elif self.op.iallocator is not None:
10273 10282
      # TODO: Implement relocation to other group
10274 10283
      ial = IAllocator(self.cfg, self.rpc, constants.IALLOCATOR_MODE_NODE_EVAC,
10275
                       evac_mode=self.op.mode,
10284
                       evac_mode=self._MODE2IALLOCATOR[self.op.mode],
10276 10285
                       instances=list(self.instance_names))
10277 10286

  
10278 10287
      ial.Run(self.op.iallocator)
......
10286 10295
      jobs = _LoadNodeEvacResult(self, ial.result, self.op.early_release, True)
10287 10296

  
10288 10297
    elif self.op.remote_node is not None:
10289
      assert self.op.mode == constants.IALLOCATOR_NEVAC_SEC
10298
      assert self.op.mode == constants.NODE_EVAC_SEC
10290 10299
      jobs = [
10291 10300
        [opcodes.OpInstanceReplaceDisks(instance_name=instance_name,
10292 10301
                                        remote_node=self.op.remote_node,

Also available in: Unified diff