Revision 42ce2e13

b/lib/utils.py
520 520
  return os.path.isdir("/sys/class/net/%s/bridge" % bridge)
521 521

  
522 522

  
523
def CheckBEParams(beparams):
524
  """Checks whether the user-supplied be-params are valid,
525
  and converts them from string format where appropriate.
526

  
527
  @type beparams: dict
528
  @param beparams: new params dict
529

  
530
  """
531
  if beparams:
532
    for item in beparams:
533
      if item not in constants.BES_PARAMETERS:
534
        raise errors.OpPrereqError("Unknown backend parameter %s" % item)
535
      if item in (constants.BE_MEMORY, constants.BE_VCPUS):
536
        val = beparams[item]
537
        if val != constants.VALUE_DEFAULT:
538
          try:
539
            val = int(val)
540
          except ValueError, err:
541
            raise errors.OpPrereqError("Invalid %s size: %s" % (item, str(err)))
542
          beparams[item] = val
543
      if item in (constants.BE_AUTO_BALANCE):
544
        val = beparams[item]
545
        if val == constants.VALUE_TRUE:
546
          beparams[item] = True
547
        elif val == constants.VALUE_FALSE:
548
          beparams[item] = False
549
        else:
550
          raise errors.OpPrereqError("Invalid %s value: %s" % (item, val))
551

  
552

  
523 553
def NiceSort(name_list):
524 554
  """Sort a list of strings based on digit and non-digit groupings.
525 555

  

Also available in: Unified diff