Commit d721894a authored by Helga Velroyen's avatar Helga Velroyen

storage utils: read file storage dir from cluster config

This patch make the storage utils read the file storage
directory from the cluster config instead of the constants.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 49a924bc
......@@ -82,6 +82,8 @@ def _GetDefaultStorageUnitForDiskTemplate(cfg, disk_template):
"""Retrieves the identifier of the default storage entity for the given
storage type.
@type cfg: C{objects.ConfigData}
@param cfg: the configuration data
@type disk_template: string
@param disk_template: a disk template, for example 'drbd'
@rtype: string
......@@ -90,12 +92,13 @@ def _GetDefaultStorageUnitForDiskTemplate(cfg, disk_template):
"""
storage_type = constants.DISK_TEMPLATES_STORAGE_TYPE[disk_template]
cluster = cfg.GetClusterInfo()
if disk_template in GetLvmDiskTemplates():
return (storage_type, cfg.GetVGName())
# FIXME: Adjust this, once FILE_STORAGE_DIR and SHARED_FILE_STORAGE_DIR
# are not in autoconf anymore.
elif disk_template == constants.DT_FILE:
return (storage_type, pathutils.DEFAULT_FILE_STORAGE_DIR)
return (storage_type, cluster.file_storage_dir)
# FIXME: Adjust this, once SHARED_FILE_STORAGE_DIR
# is not in autoconf anymore.
elif disk_template == constants.DT_SHARED_FILE:
return (storage_type, pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR)
else:
......
......@@ -26,7 +26,6 @@ import mock
import unittest
from ganeti import constants
from ganeti import errors
from ganeti import objects
from ganeti import pathutils
from ganeti.utils import storage
......@@ -38,8 +37,11 @@ class TestGetStorageUnitForDiskTemplate(unittest.TestCase):
def setUp(self):
self._default_vg_name = "some_vg_name"
self._cluster = mock.Mock()
self._cluster.file_storage_dir = "my/file/storage/dir"
self._cfg = mock.Mock()
self._cfg.GetVGName = mock.Mock(return_value=self._default_vg_name)
self._cfg.GetClusterInfo = mock.Mock(return_value=self._cluster)
def testGetDefaultStorageUnitForDiskTemplateLvm(self):
for disk_template in [constants.DT_DRBD8, constants.DT_PLAIN]:
......@@ -54,7 +56,7 @@ class TestGetStorageUnitForDiskTemplate(unittest.TestCase):
storage._GetDefaultStorageUnitForDiskTemplate(self._cfg,
constants.DT_FILE)
self.assertEqual(storage_type, constants.ST_FILE)
self.assertEqual(storage_key, pathutils.DEFAULT_FILE_STORAGE_DIR)
self.assertEqual(storage_key, self._cluster.file_storage_dir)
def testGetDefaultStorageUnitForDiskTemplateSharedFile(self):
(storage_type, storage_key) = \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment