Revision d721894a

b/lib/utils/storage.py
82 82
  """Retrieves the identifier of the default storage entity for the given
83 83
  storage type.
84 84

  
85
  @type cfg: C{objects.ConfigData}
86
  @param cfg: the configuration data
85 87
  @type disk_template: string
86 88
  @param disk_template: a disk template, for example 'drbd'
87 89
  @rtype: string
......
90 92

  
91 93
  """
92 94
  storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[disk_template]
95
  cluster = cfg.GetClusterInfo()
93 96
  if disk_template in GetLvmDiskTemplates():
94 97
    return (storage_type, cfg.GetVGName())
95
  # FIXME: Adjust this, once FILE_STORAGE_DIR and SHARED_FILE_STORAGE_DIR
96
  # are not in autoconf anymore.
97 98
  elif disk_template == constants.DT_FILE:
98
    return (storage_type, pathutils.DEFAULT_FILE_STORAGE_DIR)
99
    return (storage_type, cluster.file_storage_dir)
100
  # FIXME: Adjust this, once SHARED_FILE_STORAGE_DIR
101
  # is not in autoconf anymore.
99 102
  elif disk_template == constants.DT_SHARED_FILE:
100 103
    return (storage_type, pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR)
101 104
  else:
b/test/py/ganeti.utils.storage_unittest.py
26 26
import unittest
27 27

  
28 28
from ganeti import constants
29
from ganeti import errors
30 29
from ganeti import objects
31 30
from ganeti import pathutils
32 31
from ganeti.utils import storage
......
38 37

  
39 38
  def setUp(self):
40 39
    self._default_vg_name = "some_vg_name"
40
    self._cluster = mock.Mock()
41
    self._cluster.file_storage_dir = "my/file/storage/dir"
41 42
    self._cfg = mock.Mock()
42 43
    self._cfg.GetVGName = mock.Mock(return_value=self._default_vg_name)
44
    self._cfg.GetClusterInfo = mock.Mock(return_value=self._cluster)
43 45

  
44 46
  def testGetDefaultStorageUnitForDiskTemplateLvm(self):
45 47
    for disk_template in [constants.DT_DRBD8, constants.DT_PLAIN]:
......
54 56
        storage._GetDefaultStorageUnitForDiskTemplate(self._cfg,
55 57
                                                      constants.DT_FILE)
56 58
    self.assertEqual(storage_type, constants.ST_FILE)
57
    self.assertEqual(storage_key, pathutils.DEFAULT_FILE_STORAGE_DIR)
59
    self.assertEqual(storage_key, self._cluster.file_storage_dir)
58 60

  
59 61
  def testGetDefaultStorageUnitForDiskTemplateSharedFile(self):
60 62
    (storage_type, storage_key) = \

Also available in: Unified diff