Revision 35007011

b/lib/backend.py
2051 2051
    return False, ("API version mismatch for path '%s': found %s, want %s." %
2052 2052
                   (os_dir, api_versions, constants.OS_API_VERSIONS))
2053 2053

  
2054
  # OS Files dictionary, we will populate it with the absolute path names
2055
  os_files = dict.fromkeys(constants.OS_SCRIPTS)
2054
  # OS Files dictionary, we will populate it with the absolute path
2055
  # names; if the value is True, then it is a required file, otherwise
2056
  # an optional one
2057
  os_files = dict.fromkeys(constants.OS_SCRIPTS, True)
2056 2058

  
2057 2059
  if max(api_versions) >= constants.OS_API_V15:
2058
    os_files[constants.OS_VARIANTS_FILE] = ""
2060
    os_files[constants.OS_VARIANTS_FILE] = False
2059 2061

  
2060 2062
  if max(api_versions) >= constants.OS_API_V20:
2061
    os_files[constants.OS_PARAMETERS_FILE] = ""
2063
    os_files[constants.OS_PARAMETERS_FILE] = True
2062 2064
  else:
2063 2065
    del os_files[constants.OS_SCRIPT_VERIFY]
2064 2066

  
2065
  for filename in os_files:
2067
  for (filename, required) in os_files.items():
2066 2068
    os_files[filename] = utils.PathJoin(os_dir, filename)
2067 2069

  
2068 2070
    try:
2069 2071
      st = os.stat(os_files[filename])
2070 2072
    except EnvironmentError, err:
2073
      if err.errno == errno.ENOENT and not required:
2074
        del os_files[filename]
2075
        continue
2071 2076
      return False, ("File '%s' under path '%s' is missing (%s)" %
2072 2077
                     (filename, os_dir, _ErrnoOrStr(err)))
2073 2078

  
......
2086 2091
    try:
2087 2092
      variants = utils.ReadFile(variants_file).splitlines()
2088 2093
    except EnvironmentError, err:
2089
      return False, ("Error while reading the OS variants file at %s: %s" %
2090
                     (variants_file, _ErrnoOrStr(err)))
2091
    if not variants:
2092
      return False, ("No supported os variant found")
2094
      # we accept missing files, but not other errors
2095
      if err.errno != errno.ENOENT:
2096
        return False, ("Error while reading the OS variants file at %s: %s" %
2097
                       (variants_file, _ErrnoOrStr(err)))
2093 2098

  
2094 2099
  parameters = []
2095 2100
  if constants.OS_PARAMETERS_FILE in os_files:
......
2166 2171
  result["DEBUG_LEVEL"] = "%d" % debug
2167 2172

  
2168 2173
  # OS variants
2169
  if api_version >= constants.OS_API_V15:
2174
  if api_version >= constants.OS_API_V15 and inst_os.supported_variants:
2170 2175
    variant = objects.OS.GetVariant(os_name)
2171 2176
    if not variant:
2172 2177
      variant = inst_os.supported_variants[0]
2173
    result["OS_VARIANT"] = variant
2178
  else:
2179
    variant = ""
2180
  result["OS_VARIANT"] = variant
2174 2181

  
2175 2182
  # OS params
2176 2183
  for pname, pvalue in os_params.items():
b/lib/cmdlib.py
2193 2193
      _ErrorIf(len(os_data) > 1, self.ENODEOS, node,
2194 2194
               "OS '%s' has multiple entries (first one shadows the rest): %s",
2195 2195
               os_name, utils.CommaJoin([v[0] for v in os_data]))
2196
      # this will catched in backend too
2197
      _ErrorIf(compat.any(v >= constants.OS_API_V15 for v in f_api)
2198
               and not f_var, self.ENODEOS, node,
2199
               "OS %s with API at least %d does not declare any variant",
2200
               os_name, constants.OS_API_V15)
2201 2196
      # comparisons with the 'base' image
2202 2197
      test = os_name not in base.oslist
2203 2198
      _ErrorIf(test, self.ENODEOS, node,
b/man/ganeti-os-interface.rst
255 255
variants.list
256 256
~~~~~~~~~~~~~
257 257

  
258
variants.list is a plain text file containing all the declared
259
supported variants for this OS, one per line. At least one variant
260
must be supported.
258
variants.list is a plain text file containing all the declared supported
259
variants for this OS, one per line. If this file is missing or empty,
260
then the OS won't be considered to support variants.
261 261

  
262 262
parameters.list
263 263
~~~~~~~~~~~~~~~
......
308 308

  
309 309
The ``variants.list`` file has been added, so OSes should support at
310 310
least one variant, declaring it in that file and must be prepared to
311
parse the OS_VARIANT environment variable. OSes are free to support
312
more variants than just the declared ones.
311
parse the OS_VARIANT environment variable. OSes are free to support more
312
variants than just the declared ones. Note that this file is optional;
313
without it, the variants functionality is disabled.
313 314

  
314 315
Version 5 to 10
315 316
^^^^^^^^^^^^^^^

Also available in: Unified diff