Commit 5f074973 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ht: Add TMaybeDict check



This replaces a number of equal “ht.TOr(ht.TDict, ht.TNone)” checks.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent f623cc78
......@@ -163,14 +163,14 @@ def TMap(fn, test):
#: a non-empty string
TNonEmptyString = TAnd(TString, TTrue)
#: a maybe non-empty string
TMaybeString = TOr(TNonEmptyString, TNone)
#: a maybe boolean (bool or none)
TMaybeBool = TOr(TBool, TNone)
#: Maybe a dictionary (dict or None)
TMaybeDict = TOr(TDict, TNone)
#: a positive integer
TPositiveInt = TAnd(TInt, lambda v: v >= 0)
......
......@@ -533,8 +533,8 @@ class OpClusterSetParams(OpCode):
("remove_uids", None, ht.NoType),
("maintain_node_health", None, ht.TMaybeBool),
("prealloc_wipe_disks", None, ht.TMaybeBool),
("nicparams", None, ht.TOr(ht.TDict, ht.TNone)),
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("nicparams", None, ht.TMaybeDict),
("ndparams", None, ht.TMaybeDict),
("drbd_helper", None, ht.TOr(ht.TString, ht.TNone)),
("default_iallocator", None, ht.TOr(ht.TString, ht.TNone)),
("master_netdev", None, ht.TOr(ht.TString, ht.TNone)),
......@@ -649,7 +649,7 @@ class OpNodeAdd(OpCode):
("group", None, ht.TMaybeString),
("master_capable", None, ht.TMaybeBool),
("vm_capable", None, ht.TMaybeBool),
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("ndparams", None, ht.TMaybeDict),
]
......@@ -714,7 +714,7 @@ class OpNodeSetParams(OpCode):
("master_capable", None, ht.TMaybeBool),
("vm_capable", None, ht.TMaybeBool),
("secondary_ip", None, ht.TMaybeString),
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("ndparams", None, ht.TMaybeDict),
("powered", None, ht.TMaybeBool),
]
......@@ -803,7 +803,7 @@ class OpInstanceReinstall(OpCode):
_PInstanceName,
("os_type", None, ht.TMaybeString),
("force_variant", False, ht.TBool),
("osparams", None, ht.TOr(ht.TDict, ht.TNone)),
("osparams", None, ht.TMaybeDict),
]
......@@ -985,7 +985,7 @@ class OpInstanceSetParams(OpCode):
("remote_node", None, ht.TMaybeString),
("os_name", None, ht.TMaybeString),
("force_variant", False, ht.TBool),
("osparams", None, ht.TOr(ht.TDict, ht.TNone)),
("osparams", None, ht.TMaybeDict),
]
......@@ -1007,7 +1007,7 @@ class OpGroupAdd(OpCode):
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
_PGroupName,
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("ndparams", None, ht.TMaybeDict),
("alloc_policy", None,
ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES))),
]
......@@ -1036,7 +1036,7 @@ class OpGroupSetParams(OpCode):
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
_PGroupName,
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
("ndparams", None, ht.TMaybeDict),
("alloc_policy", None, ht.TOr(ht.TNone,
ht.TElemOf(constants.VALID_ALLOC_POLICIES))),
]
......
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