Revision c26dabd7 lib/backend.py

b/lib/backend.py
882 882
  return detail
883 883

  
884 884

  
885
def _OSOndiskVersion(name, os_dir=None):
885
def _OSOndiskVersion(name, os_dir):
886 886
  """Compute and return the api version of a given OS.
887 887

  
888 888
  This function will try to read the api version of the os given by
889 889
  the 'name' parameter and residing in the 'os_dir' directory.
890 890

  
891
  By default if os_dir is not given it will search for a matching name in all
892
  the constants.OS_SEARCH_PATH directories. 
893

  
894 891
  Return value will be either an integer denoting the version or None in the
895 892
  case when this is not a valid OS name.
896 893

  
897 894
  """
898
  if os_dir is None:
899
    for base_dir in constants.OS_SEARCH_PATH:
900
      t_os_dir = os.path.sep.join([base_dir, name])
901
      if os.path.isdir(t_os_dir):
902
        os_dir = t_os_dir
903
        break
904
  
905
  if os_dir is None:
906
    raise errors.InvalidOS(name, "OS dir not found in search path")
907 895

  
908 896
  api_file = os.path.sep.join([os_dir, "ganeti_api_version"])
909 897

  
......
994 982
  if os_dir is None:
995 983
    raise errors.InvalidOS(name, "OS dir not found in search path")
996 984

  
997
  api_version = _OSOndiskVersion(name, os_dir=os_dir)
985
  api_version = _OSOndiskVersion(name, os_dir)
998 986

  
999 987
  if api_version != constants.OS_API_VERSION:
1000 988
    raise errors.InvalidOS(name, "API version mismatch (found %s want %s)"

Also available in: Unified diff