Commit 3e3ddbf0 authored by Constantinos Venetsanopoulos's avatar Constantinos Venetsanopoulos Committed by Iustin Pop
Browse files

Remove checks wrt IDISK_PARAMS from OpCode level



Change the "--disks" option validation, to just check the format
of the dict and do not check whether the keys are included in the
IDISK_PARAMS constant at OpCode level. This allows the passing of
arbitrary parameters at the CLI, which will then be logically
checked at LU level (inside CheckArguments).

Currently, the check wrt to IDISK_PARAMS already happens in all
related LUs (InstanceSetParams, InstanceCreate, InstanceRecreateDisks),
with the use of ForceDictType(), so there is no need for additional
checking code.
Signed-off-by: default avatarConstantinos Venetsanopoulos <cven@grnet.gr>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
[iustin@google.com: fixed a unittest that needed adjustement]
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cefd4a4a
......@@ -207,10 +207,12 @@ _TSetParamsResult = \
ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetParamsResultItemItems)),
ht.TItems(_TSetParamsResultItemItems)))
# TODO: Generate check from constants.IDISK_PARAMS_TYPES (however, not all users
# of this check support all parameters)
# In the disks option we can provide arbitrary parameters too, which
# we may not be able to validate at this level, so we just check the
# format of the dict here and the checks concerning IDISK_PARAMS will
# happen at the LU level
_TDiskParams = \
ht.Comment("Disk parameters")(ht.TDictOf(ht.TElemOf(constants.IDISK_PARAMS),
ht.Comment("Disk parameters")(ht.TDictOf(ht.TNonEmptyString,
ht.TOr(ht.TNonEmptyString, ht.TInt)))
_TQueryRow = \
......
......@@ -1003,7 +1003,7 @@ class TestInstanceCreation(testutils.GanetiTestCase):
# Invalid disks and nics
for field in ["disks", "nics"]:
invalid_values = [None, 1, "", {}, [1, 2, 3], ["hda1", "hda2"],
[{"_unknown_": 999, }]]
[{"_unknown_": False, }]]
for invvalue in invalid_values:
data = reqfields.copy()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment