cmdlib: Node whitelist support for allocation request
[ganeti-local] / lib / ht.py
index 85d3b82..a449e82 100644 (file)
--- a/lib/ht.py
+++ b/lib/ht.py
@@ -187,6 +187,14 @@ def TNone(val):
   return val is None
 
 
+@WithDesc("ValueNone")
+def TValueNone(val):
+  """Checks if the given value is L{constants.VALUE_NONE}.
+
+  """
+  return val == constants.VALUE_NONE
+
+
 @WithDesc("Boolean")
 def TBool(val):
   """Checks if the given value is a boolean.
@@ -251,6 +259,14 @@ def TList(val):
   return isinstance(val, list)
 
 
+@WithDesc("Tuple")
+def TTuple(val):
+  """Checks if the given value is a tuple.
+
+  """
+  return isinstance(val, tuple)
+
+
 @WithDesc("Dictionary")
 def TDict(val):
   """Checks if the given value is a dictionary.
@@ -319,6 +335,13 @@ def TMaybe(test):
   return TOr(TNone, test)
 
 
+def TMaybeValueNone(test):
+  """Used for unsetting values.
+
+  """
+  return TMaybe(TOr(TValueNone, test))
+
+
 # Type aliases
 
 #: a non-empty string