Add missing Gluster storage verification checks
authorDimitris Bliablias <bl.dimitris@gmail.com>
Mon, 18 May 2015 13:01:47 +0000 (15:01 +0200)
committerKlaus Aehlig <aehlig@google.com>
Mon, 18 May 2015 13:11:25 +0000 (15:11 +0200)
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: Dimitris Bliablias <bl.dimitris@gmail.com>
Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>

Cherry-picked from 604c8be2596195d94efcd96f286542f74912b2e5

Signed-off-by: Lisa Velden <velden@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/bootstrap.py
lib/cmdlib/cluster.py
src/Ganeti/Constants.hs
src/Ganeti/Types.hs

index 8a75548..7468361 100644 (file)
@@ -403,7 +403,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.
 
@@ -415,14 +415,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:
@@ -432,8 +437,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:
@@ -458,6 +463,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)
 
 
@@ -472,6 +478,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)
 
 
@@ -486,6 +493,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)
 
 
@@ -682,6 +690,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,
index b0d5d0b..6e1ba2e 100644 (file)
@@ -828,8 +828,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 == "":
@@ -872,6 +873,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.
 
@@ -3095,7 +3108,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()
@@ -3128,6 +3141,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.
 
@@ -3397,7 +3421,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.
 
     """
@@ -3696,6 +3720,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)
index 7fd11c3..03b32c5 100644 (file)
@@ -3015,6 +3015,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",
@@ -3076,6 +3082,7 @@ cvAllEcodes =
    cvEnoderpc,
    cvEnodesetup,
    cvEnodesharedfilestoragepathunusable,
+   cvEnodeglusterstoragepathunusable,
    cvEnodessh,
    cvEnodetime,
    cvEnodeuserscripts,
@@ -3117,6 +3124,9 @@ nvFileStoragePath = "file-storage-path"
 nvSharedFileStoragePath :: String
 nvSharedFileStoragePath = "shared-file-storage-path"
 
+nvGlusterStoragePath :: String
+nvGlusterStoragePath = "gluster-storage-path"
+
 nvHvinfo :: String
 nvHvinfo = "hvinfo"
 
index aedef7e..d3c3118 100644 (file)
@@ -413,6 +413,8 @@ $(THH.declareLADT ''String "CVErrorCode"
   , ("CvENODEFILESTORAGEPATHUNUSABLE", "ENODEFILESTORAGEPATHUNUSABLE")
   , ("CvENODESHAREDFILESTORAGEPATHUNUSABLE",
      "ENODESHAREDFILESTORAGEPATHUNUSABLE")
+  , ("CvENODEGLUSTERSTORAGEPATHUNUSABLE",
+     "ENODEGLUSTERSTORAGEPATHUNUSABLE")
   , ("CvEGROUPDIFFERENTPVSIZE",        "EGROUPDIFFERENTPVSIZE")
   ])
 $(THH.makeJSONInstance ''CVErrorCode)