Revision a01225a6 lib/cmdlib.py

b/lib/cmdlib.py
12108 12108
    constants.IALLOCATOR_MODE_RELOC:
12109 12109
      (_AddRelocateInstance, ["name", "relocate_from"], ht.TList),
12110 12110
    constants.IALLOCATOR_MODE_MEVAC:
12111
      (_AddEvacuateNodes, ["evac_nodes"], ht.TList),
12111
      (_AddEvacuateNodes, ["evac_nodes"],
12112
       ht.TListOf(ht.TAnd(ht.TIsLength(2),
12113
                          ht.TListOf(ht.TString)))),
12112 12114
    constants.IALLOCATOR_MODE_MRELOC:
12113 12115
      (_AddMultiRelocate, ["instances", "reloc_mode", "target_groups"],
12114 12116
       ht.TListOf(ht.TListOf(ht.TStrictDict(True, False, {
......
12166 12168
                               (self._result_check, self.result),
12167 12169
                               errors.ECODE_INVAL)
12168 12170

  
12169
    if self.mode == constants.IALLOCATOR_MODE_RELOC:
12170
      assert self.relocate_from is not None
12171
      assert self.required_nodes == 1
12172

  
12171
    if self.mode in (constants.IALLOCATOR_MODE_RELOC,
12172
                     constants.IALLOCATOR_MODE_MEVAC):
12173 12173
      node2group = dict((name, ndata["group"])
12174 12174
                        for (name, ndata) in self.in_data["nodes"].items())
12175 12175

  
12176 12176
      fn = compat.partial(self._NodesToGroups, node2group,
12177 12177
                          self.in_data["nodegroups"])
12178 12178

  
12179
      request_groups = fn(self.relocate_from)
12180
      result_groups = fn(rdict["result"])
12181

  
12182
      if result_groups != request_groups:
12183
        raise errors.OpExecError("Groups of nodes returned by iallocator (%s)"
12184
                                 " differ from original groups (%s)" %
12185
                                 (utils.CommaJoin(result_groups),
12186
                                  utils.CommaJoin(request_groups)))
12179
      if self.mode == constants.IALLOCATOR_MODE_RELOC:
12180
        assert self.relocate_from is not None
12181
        assert self.required_nodes == 1
12182

  
12183
        request_groups = fn(self.relocate_from)
12184
        result_groups = fn(rdict["result"])
12185

  
12186
        if result_groups != request_groups:
12187
          raise errors.OpExecError("Groups of nodes returned by iallocator (%s)"
12188
                                   " differ from original groups (%s)" %
12189
                                   (utils.CommaJoin(result_groups),
12190
                                    utils.CommaJoin(request_groups)))
12191
      elif self.mode == constants.IALLOCATOR_MODE_MEVAC:
12192
        request_groups = fn(self.evac_nodes)
12193
        for (instance_name, secnode) in self.result:
12194
          result_groups = fn([secnode])
12195
          if result_groups != request_groups:
12196
            raise errors.OpExecError("Iallocator returned new secondary node"
12197
                                     " '%s' (group '%s') for instance '%s'"
12198
                                     " which is not in original group '%s'" %
12199
                                     (secnode, utils.CommaJoin(result_groups),
12200
                                      instance_name,
12201
                                      utils.CommaJoin(request_groups)))
12202
      else:
12203
        raise errors.ProgrammerError("Unhandled mode '%s'" % self.mode)
12187 12204

  
12188 12205
    self.out_data = rdict
12189 12206

  

Also available in: Unified diff