Fix gnt-debug iallocator
[ganeti-local] / lib / ht.py
index 4a511dc..06ea165 100644 (file)
--- a/lib/ht.py
+++ b/lib/ht.py
@@ -322,10 +322,16 @@ TMaybeDict = TOr(TDict, TNone)
 TPositiveInt = \
   TAnd(TInt, WithDesc("EqualGreaterZero")(lambda v: v >= 0))
 
+#: a maybe positive integer (positive integer or None)
+TMaybePositiveInt = TOr(TPositiveInt, TNone)
+
 #: a strictly positive integer
 TStrictPositiveInt = \
   TAnd(TInt, WithDesc("GreaterThanZero")(lambda v: v > 0))
 
+#: a maybe strictly positive integer (strictly positive integer or None)
+TMaybeStrictPositiveInt = TOr(TStrictPositiveInt, TNone)
+
 #: a strictly negative integer (0 > value)
 TStrictNegativeInt = \
   TAnd(TInt, WithDesc("LessThanZero")(compat.partial(operator.gt, 0)))
@@ -354,6 +360,9 @@ def TListOf(my_type):
   return desc(TAnd(TList, lambda lst: compat.all(my_type(v) for v in lst)))
 
 
+TMaybeListOf = lambda item_type: TOr(TNone, TListOf(item_type))
+
+
 def TDictOf(key_type, val_type):
   """Checks a dict type for the type of its key/values.