Commit 4b322a76 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

gnt-cluster verify: consider shared file storage



This patch enhances 'gnt-cluster verify' in a way that it
now validates the acceptance and existance of the shared
storage directory.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 4e6cfd11
......@@ -1140,6 +1140,12 @@ def VerifyNode(what, cluster_name, all_hvparams):
if pathresult:
result[constants.NV_FILE_STORAGE_PATH] = pathresult
if what.get(constants.NV_SHARED_FILE_STORAGE_PATH):
pathresult = filestorage.CheckFileStoragePath(
what[constants.NV_SHARED_FILE_STORAGE_PATH])
if pathresult:
result[constants.NV_SHARED_FILE_STORAGE_PATH] = pathresult
return result
......
......@@ -2417,21 +2417,54 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
"Node should not have returned forbidden file storage"
" paths")
def _VerifyStoragePaths(self, ninfo, nresult):
def _VerifyStoragePaths(self, ninfo, nresult, file_disk_template,
verify_key, error_key):
"""Verifies (file) storage paths.
@type ninfo: L{objects.Node}
@param ninfo: the node to check
@param nresult: the remote results for the node
"""
@type file_disk_template: string
@param file_disk_template: file-based disk template, whose directory
is supposed to be verified
@type verify_key: string
@param verify_key: key for the verification map of this file
verification step
@param error_key: error key to be added to the verification results
in case something goes wrong in this verification step
"""
assert (file_disk_template in
utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE))
cluster = self.cfg.GetClusterInfo()
if cluster.IsFileStorageEnabled():
if cluster.IsDiskTemplateEnabled(file_disk_template):
self._ErrorIf(
constants.NV_FILE_STORAGE_PATH in nresult,
constants.CV_ENODEFILESTORAGEPATHUNUSABLE, ninfo.name,
"The configured file storage path is unusable: %s" %
nresult.get(constants.NV_FILE_STORAGE_PATH))
verify_key in nresult,
error_key, ninfo.name,
"The configured %s storage path is unusable: %s" %
(file_disk_template, nresult.get(verify_key)))
def _VerifyFileStoragePaths(self, ninfo, nresult):
"""Verifies (file) storage paths.
@see: C{_VerifyStoragePaths}
"""
self._VerifyStoragePaths(
ninfo, nresult, constants.DT_FILE,
constants.NV_FILE_STORAGE_PATH,
constants.CV_ENODEFILESTORAGEPATHUNUSABLE)
def _VerifySharedFileStoragePaths(self, ninfo, nresult):
"""Verifies (file) storage paths.
@see: C{_VerifyStoragePaths}
"""
self._VerifyStoragePaths(
ninfo, nresult, constants.DT_SHARED_FILE,
constants.NV_SHARED_FILE_STORAGE_PATH,
constants.CV_ENODESHAREDFILESTORAGEPATHUNUSABLE)
def _VerifyOob(self, ninfo, nresult):
"""Verifies out of band functionality of a node.
......@@ -2948,7 +2981,8 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
self._VerifyOob(node_i, nresult)
self._VerifyAcceptedFileStoragePaths(node_i, nresult,
node_i.uuid == master_node_uuid)
self._VerifyStoragePaths(node_i, nresult)
self._VerifyFileStoragePaths(node_i, nresult)
self._VerifySharedFileStoragePaths(node_i, nresult)
if nimg.vm_capable:
self._UpdateVerifyNodeLVM(node_i, nresult, vg_name, nimg)
......
......@@ -1659,6 +1659,9 @@ CV_ENODEFILESTORAGEPATHS = \
(CV_TNODE, "ENODEFILESTORAGEPATHS", "Detected bad file storage paths")
CV_ENODEFILESTORAGEPATHUNUSABLE = \
(CV_TNODE, "ENODEFILESTORAGEPATHUNUSABLE", "File storage path unusable")
CV_ENODESHAREDFILESTORAGEPATHUNUSABLE = \
(CV_TNODE, "ENODESHAREDFILESTORAGEPATHUNUSABLE",
"Shared file storage path unusable")
CV_ALL_ECODES = compat.UniqueFrozenset([
CV_ECLUSTERCFG,
......@@ -1694,6 +1697,7 @@ CV_ALL_ECODES = compat.UniqueFrozenset([
CV_ENODEUSERSCRIPTS,
CV_ENODEFILESTORAGEPATHS,
CV_ENODEFILESTORAGEPATHUNUSABLE,
CV_ENODESHAREDFILESTORAGEPATHUNUSABLE,
])
CV_ALL_ECODES_STRINGS = \
......
......@@ -198,6 +198,8 @@ def CheckFileStoragePath(
path, _allowed_paths_file=pathutils.FILE_STORAGE_PATHS_FILE):
"""Checks whether the path exists and is acceptable to use.
Can be used for any file-based storage, for example shared-file storage.
@type path: string
@param path: path to check
@rtype: string
......
......@@ -267,6 +267,8 @@ $(THH.declareSADT "CVErrorCode"
, ("CvENODEUSERSCRIPTS", 'C.cvEnodeuserscriptsCode)
, ("CvENODEFILESTORAGEPATHS", 'C.cvEnodefilestoragepathsCode)
, ("CvENODEFILESTORAGEPATHUNUSABLE", 'C.cvEnodefilestoragepathunusableCode)
, ("CvENODESHAREDFILESTORAGEPATHUNUSABLE",
'C.cvEnodesharedfilestoragepathunusableCode)
])
$(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