Revision 3d45d304 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
57 | 57 |
from ganeti import query |
58 | 58 |
from ganeti import qlang |
59 | 59 |
from ganeti import opcodes |
60 |
from ganeti import ht |
|
60 | 61 |
|
61 | 62 |
import ganeti.masterd.instance # pylint: disable-msg=W0611 |
62 | 63 |
|
... | ... | |
11798 | 11799 |
self.success = self.info = self.result = None |
11799 | 11800 |
|
11800 | 11801 |
try: |
11801 |
(fn, keyset) = self._MODE_DATA[self.mode] |
|
11802 |
(fn, keyset, self._result_check) = self._MODE_DATA[self.mode]
|
|
11802 | 11803 |
except KeyError: |
11803 | 11804 |
raise errors.ProgrammerError("Unknown mode '%s' passed to the" |
11804 | 11805 |
" IAllocator" % self.mode) |
... | ... | |
12103 | 12104 |
constants.IALLOCATOR_MODE_ALLOC: |
12104 | 12105 |
(_AddNewInstance, |
12105 | 12106 |
["name", "mem_size", "disks", "disk_template", "os", "tags", "nics", |
12106 |
"vcpus", "hypervisor"]), |
|
12107 |
"vcpus", "hypervisor"], ht.TList),
|
|
12107 | 12108 |
constants.IALLOCATOR_MODE_RELOC: |
12108 |
(_AddRelocateInstance, ["name", "relocate_from"]), |
|
12109 |
(_AddRelocateInstance, ["name", "relocate_from"], ht.TList),
|
|
12109 | 12110 |
constants.IALLOCATOR_MODE_MEVAC: |
12110 |
(_AddEvacuateNodes, ["evac_nodes"]), |
|
12111 |
(_AddEvacuateNodes, ["evac_nodes"], ht.TList),
|
|
12111 | 12112 |
constants.IALLOCATOR_MODE_MRELOC: |
12112 |
(_AddMultiRelocate, ["instances", "reloc_mode", "target_groups"]), |
|
12113 |
(_AddMultiRelocate, ["instances", "reloc_mode", "target_groups"], |
|
12114 |
ht.TListOf(ht.TListOf(ht.TStrictDict(True, False, { |
|
12115 |
# pylint: disable-msg=E1101 |
|
12116 |
# Class '...' has no 'OP_ID' member |
|
12117 |
"OP_ID": ht.TElemOf([opcodes.OpInstanceFailover.OP_ID, |
|
12118 |
opcodes.OpInstanceMigrate.OP_ID, |
|
12119 |
opcodes.OpInstanceReplaceDisks.OP_ID]) |
|
12120 |
})))), |
|
12113 | 12121 |
} |
12114 | 12122 |
|
12115 | 12123 |
def Run(self, name, validate=True, call_fn=None): |
... | ... | |
12152 | 12160 |
" missing key '%s'" % key) |
12153 | 12161 |
setattr(self, key, rdict[key]) |
12154 | 12162 |
|
12155 |
if not isinstance(rdict["result"], list): |
|
12156 |
raise errors.OpExecError("Can't parse iallocator results: 'result' key" |
|
12157 |
" is not a list") |
|
12163 |
if not self._result_check(self.result): |
|
12164 |
raise errors.OpExecError("Iallocator returned invalid result," |
|
12165 |
" expected %s, got %s" % |
|
12166 |
(self._result_check, self.result), |
|
12167 |
errors.ECODE_INVAL) |
|
12158 | 12168 |
|
12159 | 12169 |
if self.mode == constants.IALLOCATOR_MODE_RELOC: |
12160 | 12170 |
assert self.relocate_from is not None |
Also available in: Unified diff