Revision ddc1de7c lib/opcodes.py
b/lib/opcodes.py | ||
---|---|---|
1373 | 1373 |
] |
1374 | 1374 |
|
1375 | 1375 |
|
1376 |
def _TestInstSetParamsModList(fn): |
|
1377 |
"""Generates a check for modification lists. |
|
1378 |
|
|
1379 |
""" |
|
1380 |
mod_item_fn = \ |
|
1381 |
ht.TAnd(ht.TIsLength(2), ht.TItems([ |
|
1382 |
ht.TOr(ht.TElemOf(constants.DDMS_VALUES), ht.TPositiveInt), |
|
1383 |
fn, |
|
1384 |
])) |
|
1385 |
|
|
1386 |
return ht.TListOf(mod_item_fn) |
|
1387 |
|
|
1388 |
|
|
1376 | 1389 |
class OpInstanceSetParams(OpCode): |
1377 |
"""Change the parameters of an instance.""" |
|
1390 |
"""Change the parameters of an instance. |
|
1391 |
|
|
1392 |
""" |
|
1393 |
_TestNicModifications = _TestInstSetParamsModList(_TestNicDef) |
|
1394 |
_TestDiskModifications = _TestInstSetParamsModList(_TDiskParams) |
|
1395 |
|
|
1378 | 1396 |
OP_DSC_FIELD = "instance_name" |
1379 | 1397 |
OP_PARAMS = [ |
1380 | 1398 |
_PInstanceName, |
1381 | 1399 |
_PForce, |
1382 | 1400 |
_PForceVariant, |
1383 | 1401 |
_PIgnoreIpolicy, |
1384 |
# TODO: Use _TestNicDef |
|
1385 |
("nics", ht.EmptyList, ht.TList, |
|
1402 |
("nics", ht.EmptyList, _TestNicModifications, |
|
1386 | 1403 |
"List of NIC changes. Each item is of the form ``(op, settings)``." |
1387 | 1404 |
" ``op`` can be ``%s`` to add a new NIC with the specified settings," |
1388 | 1405 |
" ``%s`` to remove the last NIC or a number to modify the settings" |
1389 | 1406 |
" of the NIC with that index." % |
1390 | 1407 |
(constants.DDM_ADD, constants.DDM_REMOVE)), |
1391 |
("disks", ht.EmptyList, ht.TList, "List of disk changes. See ``nics``."), |
|
1408 |
("disks", ht.EmptyList, _TestDiskModifications, |
|
1409 |
"List of disk changes. See ``nics``."), |
|
1392 | 1410 |
("beparams", ht.EmptyDict, ht.TDict, "Per-instance backend parameters"), |
1393 | 1411 |
("runtime_mem", None, ht.TMaybeStrictPositiveInt, "New runtime memory"), |
1394 | 1412 |
("hvparams", ht.EmptyDict, ht.TDict, |
Also available in: Unified diff