Revision a5961235

b/lib/cmdlib.py
415 415
                               % ",".join(delta))
416 416

  
417 417

  
418
def _CheckBooleanOpField(op, name):
419
  """Validates boolean opcode parameters.
420

  
421
  This will ensure that an opcode parameter is either a boolean value,
422
  or None (but that it always exists).
423

  
424
  """
425
  val = getattr(op, name, None)
426
  if not (val is None or isinstance(val, bool)):
427
    raise errors.OpPrereqError("Invalid boolean parameter '%s' (%s)" %
428
                               (name, str(val)))
429
  setattr(op, name, val)
430

  
431

  
432
def _CheckNodeOnline(lu, node):
433
  """Ensure that a given node is online.
434

  
435
  @param lu: the LU on behalf of which we make the check
436
  @param node: the node to check
437
  @raise errors.OpPrereqError: if the nodes is offline
438

  
439
  """
440
  if lu.cfg.GetNodeInfo(node).offline:
441
    raise errors.OpPrereqError("Can't use offline node %s" % node)
442

  
443

  
418 444
def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
419 445
                          memory, vcpus, nics):
420 446
  """Builds instance related env variables for hooks

Also available in: Unified diff