Revision ef725c86 lib/cmdlib/test.py
b/lib/cmdlib/test.py | ||
---|---|---|
237 | 237 |
""" |
238 | 238 |
if self.op.mode in (constants.IALLOCATOR_MODE_ALLOC, |
239 | 239 |
constants.IALLOCATOR_MODE_MULTI_ALLOC): |
240 |
for attr in ["memory", "disks", "disk_template", |
|
241 |
"os", "tags", "nics", "vcpus"]: |
|
242 |
if not hasattr(self.op, attr): |
|
243 |
raise errors.OpPrereqError("Missing attribute '%s' on opcode input" % |
|
244 |
attr, errors.ECODE_INVAL) |
|
245 | 240 |
(self.inst_uuid, iname) = self.cfg.ExpandInstanceName(self.op.name) |
246 | 241 |
if iname is not None: |
247 | 242 |
raise errors.OpPrereqError("Instance '%s' already in the cluster" % |
248 | 243 |
iname, errors.ECODE_EXISTS) |
249 |
if not isinstance(self.op.nics, list): |
|
250 |
raise errors.OpPrereqError("Invalid parameter 'nics'", |
|
251 |
errors.ECODE_INVAL) |
|
252 |
if not isinstance(self.op.disks, list): |
|
253 |
raise errors.OpPrereqError("Invalid parameter 'disks'", |
|
254 |
errors.ECODE_INVAL) |
|
255 | 244 |
for row in self.op.disks: |
256 | 245 |
if (not isinstance(row, dict) or |
257 | 246 |
constants.IDISK_SIZE not in row or |
... | ... | |
280 | 269 |
if self.op.iallocator is None: |
281 | 270 |
raise errors.OpPrereqError("Missing allocator name", |
282 | 271 |
errors.ECODE_INVAL) |
283 |
elif self.op.direction != constants.IALLOCATOR_DIR_IN: |
|
284 |
raise errors.OpPrereqError("Wrong allocator test '%s'" % |
|
285 |
self.op.direction, errors.ECODE_INVAL) |
|
286 | 272 |
|
287 | 273 |
def Exec(self, feedback_fn): |
288 | 274 |
"""Run the allocator test. |
Also available in: Unified diff