Revision e7b6183b qa/qa_config.py

b/qa/qa_config.py
25 25

  
26 26
import os
27 27

  
28
from ganeti import constants
28 29
from ganeti import utils
29 30
from ganeti import serializer
30 31
from ganeti import compat
......
33 34

  
34 35

  
35 36
_INSTANCE_CHECK_KEY = "instance-check"
37
_ENABLED_HV_KEY = "enabled-hypervisors"
36 38

  
37 39

  
38 40
cfg = None
......
67 69
      raise qa_error.Error("Can't find instance check script '%s': %s" %
68 70
                           (check, err))
69 71

  
72
  enabled_hv = frozenset(GetEnabledHypervisors())
73
  if not enabled_hv:
74
    raise qa_error.Error("No hypervisor is enabled")
75

  
76
  difference = enabled_hv - constants.HYPER_TYPES
77
  if difference:
78
    raise qa_error.Error("Unknown hypervisor(s) enabled: %s" %
79
                         utils.CommaJoin(difference))
80

  
70 81

  
71 82
def get(name, default=None):
72 83
  return cfg.get(name, default)
......
154 165
  return cfg.get(_INSTANCE_CHECK_KEY, None)
155 166

  
156 167

  
168
def GetEnabledHypervisors():
169
  """Returns list of enabled hypervisors.
170

  
171
  @rtype: list
172

  
173
  """
174
  try:
175
    value = cfg[_ENABLED_HV_KEY]
176
  except KeyError:
177
    return [constants.DEFAULT_ENABLED_HYPERVISOR]
178
  else:
179
    if isinstance(value, basestring):
180
      # The configuration key ("enabled-hypervisors") implies there can be
181
      # multiple values. Multiple hypervisors are comma-separated on the
182
      # command line option to "gnt-cluster init", so we need to handle them
183
      # equally here.
184
      return value.split(",")
185
    else:
186
      return value
187

  
188

  
189
def GetDefaultHypervisor():
190
  """Returns the default hypervisor to be used.
191

  
192
  """
193
  return GetEnabledHypervisors()[0]
194

  
195

  
157 196
def GetInstanceNicMac(inst, default=None):
158 197
  """Returns MAC address for instance's network interface.
159 198

  

Also available in: Unified diff