Revision 3d16a983

b/lib/cmdlib.py
70 70
  return {}
71 71

  
72 72

  
73
#: The without-default default value
74
_NoDefault = object()
75

  
76

  
77
#: The no-type (value to complex to check it in the type system)
78
_NoType = object()
79

  
80

  
73 81
# Some basic types
74 82
def _TNotNone(val):
75 83
  """Checks if the given value is not None.
......
163 171

  
164 172
# Type aliases
165 173

  
166
# non-empty string
174
#: a non-empty string
167 175
_TNonEmptyString = _TAnd(_TString, _TTrue)
168 176

  
169 177

  
170
# positive integer
178
#: a maybe non-empty string
179
_TMaybeString = _TOr(_TNonEmptyString, _TNone)
180

  
181

  
182
#: a maybe boolean (bool or none)
183
_TMaybeBool = _TOr(_TBool, _TNone)
184

  
185

  
186
#: a positive integer
171 187
_TPositiveInt = _TAnd(_TInt, lambda v: v >= 0)
172 188

  
189
#: a strictly positive integer
190
_TStrictPositiveInt = _TAnd(_TInt, lambda v: v > 0)
191

  
173 192

  
174 193
def _TListOf(my_type):
175 194
  """Checks if a given value is a list with all elements of the same type.
......
189 208
                                               for v in my_dict.values())))
190 209

  
191 210

  
211
# Common opcode attributes
212

  
213
#: output fields for a query operation
214
_POutputFields = ("output_fields", _NoDefault, _TListOf(_TNonEmptyString))
215

  
216

  
217
#: the shutdown timeout
218
_PShutdownTimeout = ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
219
                     _TPositiveInt)
220

  
221
#: the force parameter
222
_PForce = ("force", False, _TBool)
223

  
224
#: a required instance name (for single-instance LUs)
225
_PInstanceName = ("instance_name", _NoDefault, _TNonEmptyString)
226

  
227

  
228
#: a required node name (for single-node LUs)
229
_PNodeName = ("node_name", _NoDefault, _TNonEmptyString)
230

  
231

  
192 232
# End types
193 233
class LogicalUnit(object):
194 234
  """Logical Unit base class.

Also available in: Unified diff