Revision dacd8ba4 qa/qa_config.py

b/qa/qa_config.py
38 38
_ENABLED_HV_KEY = "enabled-hypervisors"
39 39
_VCLUSTER_MASTER_KEY = "vcluster-master"
40 40
_VCLUSTER_BASEDIR_KEY = "vcluster-basedir"
41
_ENABLED_STORAGE_TYPES_KEY = "enabled-storage-types"
41 42

  
42 43
#: QA configuration (L{_QaConfig})
43 44
_config = None
......
349 350
    @rtype: list
350 351

  
351 352
    """
353
    return self._GetStringListParameter(
354
      _ENABLED_HV_KEY,
355
      [constants.DEFAULT_ENABLED_HYPERVISOR])
356

  
357
  def GetDefaultHypervisor(self):
358
    """Returns the default hypervisor to be used.
359

  
360
    """
361
    return self.GetEnabledHypervisors()[0]
362

  
363
  def GetEnabledStorageTypes(self):
364
    """Returns the list of enabled storage types.
365

  
366
    @rtype: list
367

  
368
    """
369
    return self._GetStringListParameter(
370
      _ENABLED_STORAGE_TYPES_KEY,
371
      list(constants.DEFAULT_ENABLED_STORAGE_TYPES))
372

  
373
  def GetDefaultStorageType(self):
374
    """Returns the default storage type to be used.
375

  
376
    """
377
    return self.GetEnabledStorageTypes()[0]
378

  
379
  def _GetStringListParameter(self, key, default_values):
380
    """Retrieves a parameter's value that is supposed to be a list of strings.
381

  
382
    @rtype: list
383

  
384
    """
352 385
    try:
353
      value = self._data[_ENABLED_HV_KEY]
386
      value = self._data[key]
354 387
    except KeyError:
355
      return [constants.DEFAULT_ENABLED_HYPERVISOR]
388
      return default_values
356 389
    else:
357 390
      if value is None:
358 391
        return []
359 392
      elif isinstance(value, basestring):
360
        # The configuration key ("enabled-hypervisors") implies there can be
361
        # multiple values. Multiple hypervisors are comma-separated on the
362
        # command line option to "gnt-cluster init", so we need to handle them
363
        # equally here.
364 393
        return value.split(",")
365 394
      else:
366 395
        return value
367 396

  
368
  def GetDefaultHypervisor(self):
369
    """Returns the default hypervisor to be used.
370

  
371
    """
372
    return self.GetEnabledHypervisors()[0]
373

  
374 397
  def SetExclusiveStorage(self, value):
375 398
    """Set the expected value of the C{exclusive_storage} flag for the cluster.
376 399

  
......
528 551
  return GetConfig().GetDefaultHypervisor(*args)
529 552

  
530 553

  
554
def GetEnabledStorageTypes(*args):
555
  """Wrapper for L{_QaConfig.GetEnabledStorageTypes}.
556

  
557
  """
558
  return GetConfig().GetEnabledStorageTypes(*args)
559

  
560

  
561
def GetDefaultStorageType(*args):
562
  """Wrapper for L{_QaConfig.GetDefaultStorageType}.
563

  
564
  """
565
  return GetConfig().GetDefaultStorageType(*args)
566

  
567

  
531 568
def GetMasterNode():
532 569
  """Wrapper for L{_QaConfig.GetMasterNode}.
533 570

  

Also available in: Unified diff