Revision b954f097 lib/backend.py

b/lib/backend.py
2481 2481
  return result
2482 2482

  
2483 2483

  
2484
def DiagnoseExtStorage(top_dirs=None):
2485
  """Compute the validity for all ExtStorage Providers.
2486

  
2487
  @type top_dirs: list
2488
  @param top_dirs: the list of directories in which to
2489
      search (if not given defaults to
2490
      L{pathutils.ES_SEARCH_PATH})
2491
  @rtype: list of L{objects.ExtStorage}
2492
  @return: a list of tuples (name, path, status, diagnose, parameters)
2493
      for all (potential) ExtStorage Providers under all
2494
      search paths, where:
2495
          - name is the (potential) ExtStorage Provider
2496
          - path is the full path to the ExtStorage Provider
2497
          - status True/False is the validity of the ExtStorage Provider
2498
          - diagnose is the error message for an invalid ExtStorage Provider,
2499
            otherwise empty
2500
          - parameters is a list of (name, help) parameters, if any
2501

  
2502
  """
2503
  if top_dirs is None:
2504
    top_dirs = pathutils.ES_SEARCH_PATH
2505

  
2506
  result = []
2507
  for dir_name in top_dirs:
2508
    if os.path.isdir(dir_name):
2509
      try:
2510
        f_names = utils.ListVisibleFiles(dir_name)
2511
      except EnvironmentError, err:
2512
        logging.exception("Can't list the ExtStorage directory %s: %s",
2513
                          dir_name, err)
2514
        break
2515
      for name in f_names:
2516
        es_path = utils.PathJoin(dir_name, name)
2517
        status, es_inst = bdev.ExtStorageFromDisk(name, base_dir=dir_name)
2518
        if status:
2519
          diagnose = ""
2520
          parameters = es_inst.supported_parameters
2521
        else:
2522
          diagnose = es_inst
2523
          parameters = []
2524
        result.append((name, es_path, status, diagnose, parameters))
2525

  
2526
  return result
2527

  
2528

  
2484 2529
def BlockdevGrow(disk, amount, dryrun, backingstore):
2485 2530
  """Grow a stack of block devices.
2486 2531

  

Also available in: Unified diff