Commit 604c8be2 authored by Dimitris Bliablias's avatar Dimitris Bliablias Committed by Petr Pudlak

Add missing Gluster storage verification checks

This patch, extends the file-based storage type verification checks to
include the new Gluster storage type. Those modifications include a
missing check for the gluster storage directory at cluster
initialization time, and extends the 'gnt-cluster verify' command to
also verify the gluster file-storage path.
Signed-off-by: default avatarDimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 7ec47185
......@@ -394,7 +394,7 @@ def _InitFileStorageDir(file_storage_dir):
def _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir,
default_dir, file_disk_template,
default_dir, file_disk_template, _storage_path_acceptance_fn,
init_fn=_InitFileStorageDir, acceptance_fn=None):
"""Checks if a file-base storage type is enabled and inits the dir.
......@@ -406,14 +406,19 @@ def _PrepareFileBasedStorage(
@param default_dir: default file storage directory when C{file_storage_dir}
is 'None'
@type file_disk_template: string
@param file_disk_template: a disk template whose storage type is 'ST_FILE' or
'ST_SHARED_FILE'
@param file_disk_template: a disk template whose storage type is 'ST_FILE',
'ST_SHARED_FILE' or 'ST_GLUSTER'
@type _storage_path_acceptance_fn: function
@param _storage_path_acceptance_fn: checks whether the given file-based
storage directory is acceptable
@see: C{cluster.CheckFileBasedStoragePathVsEnabledDiskTemplates} for details
@rtype: string
@returns: the name of the actual file storage directory
"""
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE
constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
))
if file_storage_dir is None:
......@@ -423,8 +428,8 @@ def _PrepareFileBasedStorage(
lambda path: filestorage.CheckFileStoragePathAcceptance(
path, exact_match_ok=True)
cluster.CheckFileStoragePathVsEnabledDiskTemplates(
logging.warning, file_storage_dir, enabled_disk_templates)
_storage_path_acceptance_fn(logging.warning, file_storage_dir,
enabled_disk_templates)
file_storage_enabled = file_disk_template in enabled_disk_templates
if file_storage_enabled:
......@@ -449,6 +454,7 @@ def _PrepareFileStorage(
return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_FILE_STORAGE_DIR, constants.DT_FILE,
cluster.CheckFileStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn)
......@@ -463,6 +469,7 @@ def _PrepareSharedFileStorage(
return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR, constants.DT_SHARED_FILE,
cluster.CheckSharedFileStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn)
......@@ -477,6 +484,7 @@ def _PrepareGlusterStorage(
return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_GLUSTER_STORAGE_DIR, constants.DT_GLUSTER,
cluster.CheckGlusterStoragePathVsEnabledDiskTemplates,
init_fn=init_fn, acceptance_fn=acceptance_fn)
......@@ -661,6 +669,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
file_storage_dir)
shared_file_storage_dir = _PrepareSharedFileStorage(enabled_disk_templates,
shared_file_storage_dir)
gluster_storage_dir = _PrepareGlusterStorage(enabled_disk_templates,
gluster_storage_dir)
if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix):
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix,
......
......@@ -728,8 +728,9 @@ def CheckFileBasedStoragePathVsEnabledDiskTemplates(
"""
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE
constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
))
file_storage_enabled = file_disk_template in enabled_disk_templates
if file_storage_dir is not None:
if file_storage_dir == "":
......@@ -772,6 +773,18 @@ def CheckSharedFileStoragePathVsEnabledDiskTemplates(
constants.DT_SHARED_FILE)
def CheckGlusterStoragePathVsEnabledDiskTemplates(
logging_warn_fn, file_storage_dir, enabled_disk_templates):
"""Checks whether the given gluster storage directory is acceptable.
@see: C{CheckFileBasedStoragePathVsEnabledDiskTemplates}
"""
CheckFileBasedStoragePathVsEnabledDiskTemplates(
logging_warn_fn, file_storage_dir, enabled_disk_templates,
constants.DT_GLUSTER)
def CheckCompressionTools(tools):
"""Check whether the provided compression tools look like executables.
......@@ -2987,7 +3000,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
"""
assert (file_disk_template in utils.storage.GetDiskTemplatesOfStorageTypes(
constants.ST_FILE, constants.ST_SHARED_FILE
constants.ST_FILE, constants.ST_SHARED_FILE, constants.ST_GLUSTER
))
cluster = self.cfg.GetClusterInfo()
......@@ -3020,6 +3033,17 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
constants.NV_SHARED_FILE_STORAGE_PATH,
constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE)
def _VerifyGlusterStoragePaths(self, ninfo, nresult):
"""Verifies (file) storage paths.
@see: C{_VerifyStoragePaths}
"""
self._VerifyStoragePaths(
ninfo, nresult, constants.DT_GLUSTER,
constants.NV_GLUSTER_STORAGE_PATH,
constants.CV_ENODEGLUSTERSTORAGEPATHUNUSABLE)
def _VerifyOob(self, ninfo, nresult):
"""Verifies out of band functionality of a node.
......@@ -3289,7 +3313,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
"""
return ([], list(self.my_node_info.keys()))
def Exec(self, feedback_fn):
def Exec(self, feedback_fn): # pylint: disable=R0915
"""Verify integrity of the node group, performing various test on nodes.
"""
......@@ -3588,6 +3612,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
node_i.uuid == master_node_uuid)
self._VerifyFileStoragePaths(node_i, nresult)
self._VerifySharedFileStoragePaths(node_i, nresult)
self._VerifyGlusterStoragePaths(node_i, nresult)
if nimg.vm_capable:
self._UpdateVerifyNodeLVM(node_i, nresult, vg_name, nimg)
......
......@@ -3012,6 +3012,12 @@ cvEnodesharedfilestoragepathunusable =
Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
"Shared file storage path unusable")
cvEnodeglusterstoragepathunusable :: (String, String, String)
cvEnodeglusterstoragepathunusable =
("node",
Types.cVErrorCodeToRaw CvENODEGLUSTERSTORAGEPATHUNUSABLE,
"Gluster storage path unusable")
cvEnodessh :: (String, String, String)
cvEnodessh =
("node",
......@@ -3073,6 +3079,7 @@ cvAllEcodes =
cvEnoderpc,
cvEnodesetup,
cvEnodesharedfilestoragepathunusable,
cvEnodeglusterstoragepathunusable,
cvEnodessh,
cvEnodetime,
cvEnodeuserscripts,
......@@ -3114,6 +3121,9 @@ nvFileStoragePath = "file-storage-path"
nvSharedFileStoragePath :: String
nvSharedFileStoragePath = "shared-file-storage-path"
nvGlusterStoragePath :: String
nvGlusterStoragePath = "gluster-storage-path"
nvHvinfo :: String
nvHvinfo = "hvinfo"
......
......@@ -404,6 +404,8 @@ $(THH.declareLADT ''String "CVErrorCode"
, ("CvENODEFILESTORAGEPATHUNUSABLE", "ENODEFILESTORAGEPATHUNUSABLE")
, ("CvENODESHAREDFILESTORAGEPATHUNUSABLE",
"ENODESHAREDFILESTORAGEPATHUNUSABLE")
, ("CvENODEGLUSTERSTORAGEPATHUNUSABLE",
"ENODEGLUSTERSTORAGEPATHUNUSABLE")
, ("CvEGROUPDIFFERENTPVSIZE", "EGROUPDIFFERENTPVSIZE")
])
$(THH.makeJSONInstance ''CVErrorCode)
......
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