Commit ac156ecd authored by Santi Raffa's avatar Santi Raffa Committed by Thomas Thrainer

Gluster: use ssconf value for mountpoint directory

Gluster still does not mount anything autonomously, but this commit
changes where Gluster expects its mountpoint to be.
Signed-off-by: default avatarSanti Raffa <rsanti@google.com>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent d3e6fd0e
......@@ -849,25 +849,35 @@ class LUInstanceCreate(LogicalUnit):
# build the full file storage dir path
joinargs = []
if self.op.disk_template in (constants.DT_SHARED_FILE,
constants.DT_GLUSTER):
get_fsd_fn = self.cfg.GetSharedFileStorageDir
else:
get_fsd_fn = self.cfg.GetFileStorageDir
cfg_storage = None
if self.op.disk_template == constants.DT_FILE:
cfg_storage = self.cfg.GetFileStorageDir()
elif self.op.disk_template == constants.DT_SHARED_FILE:
cfg_storage = self.cfg.GetSharedFileStorageDir()
elif self.op.disk_template == constants.DT_GLUSTER:
cfg_storage = self.cfg.GetGlusterStorageDir()
if not cfg_storage:
raise errors.OpPrereqError(
"Cluster file storage dir for {tpl} storage type not defined".format(
tpl=repr(self.op.disk_template)
),
errors.ECODE_STATE
)
cfg_storagedir = get_fsd_fn()
if not cfg_storagedir:
raise errors.OpPrereqError("Cluster file storage dir not defined",
errors.ECODE_STATE)
joinargs.append(cfg_storagedir)
joinargs.append(cfg_storage)
if self.op.file_storage_dir is not None:
joinargs.append(self.op.file_storage_dir)
joinargs.append(self.op.instance_name)
if self.op.disk_template != constants.DT_GLUSTER:
joinargs.append(self.op.instance_name)
# pylint: disable=W0142
self.instance_file_storage_dir = utils.PathJoin(*joinargs)
if len(joinargs) > 1:
# pylint: disable=W0142
self.instance_file_storage_dir = utils.PathJoin(*joinargs)
else:
self.instance_file_storage_dir = joinargs[0]
def CheckPrereq(self): # pylint: disable=R0914
"""Check prerequisites.
......
......@@ -53,7 +53,8 @@ class GlusterVolume(object):
"""
def __init__(self, server_addr, port, volume, _run_cmd=utils.RunCmd):
def __init__(self, server_addr, port, volume, _run_cmd=utils.RunCmd,
_mount_point=None):
"""Creates a Gluster volume object.
@type server_addr: str
......@@ -72,8 +73,10 @@ class GlusterVolume(object):
port = netutils.ValidatePortNumber(port)
self._port = port
self._volume = volume
self.mount_point = io.PathJoin(constants.GLUSTER_MOUNTPOINT,
self._volume)
if _mount_point: # tests
self.mount_point = _mount_point
else:
self.mount_point = ssconf.SimpleStore().GetGlusterStorageDir()
self._run_cmd = _run_cmd
......
......@@ -92,7 +92,7 @@ def _GetDefaultStorageUnitForDiskTemplate(cfg, disk_template):
elif disk_template == constants.DT_SHARED_FILE:
return (storage_type, cluster.shared_file_storage_dir)
elif disk_template == constants.DT_GLUSTER:
return (storage_type, constants.GLUSTER_MOUNTPOINT)
return (storage_type, cluster.gluster_storage_dir)
else:
return (storage_type, None)
......
......@@ -31,7 +31,6 @@ module Ganeti.Storage.Utils
import Ganeti.Config
import Ganeti.Objects
import Ganeti.Types
import Ganeti.Constants
import qualified Ganeti.Types as T
import Control.Monad
......
......@@ -446,7 +446,7 @@ class TestLUInstanceCreate(CmdlibTestCase):
self.cluster.file_storage_dir = None
op = self.CopyOpCode(self.file_op)
self.ExecOpCodeExpectOpPrereqError(
op, "Cluster file storage dir not defined")
op, "Cluster file storage dir for 'file' storage type not defined")
def testFileInstanceAdditionalPath(self):
op = self.CopyOpCode(self.file_op,
......
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