gnt-cluster verify: consider shared file storage
authorHelga Velroyen <helgav@google.com>
Tue, 23 Jul 2013 14:56:53 +0000 (16:56 +0200)
committerHelga Velroyen <helgav@google.com>
Mon, 29 Jul 2013 12:27:15 +0000 (14:27 +0200)
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: Helga Velroyen <helgav@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

lib/backend.py
lib/cmdlib/cluster.py
lib/constants.py
lib/storage/filestorage.py
src/Ganeti/Types.hs

index 7063aa5..466578c 100644 (file)
@@ -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
 
 
index 483155c..cef1bc5 100644 (file)
@@ -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)
index 04b3516..43926e8 100644 (file)
@@ -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 = \
index 8198110..4b636e8 100644 (file)
@@ -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
index 849f92d..70de831 100644 (file)
@@ -267,6 +267,8 @@ $(THH.declareSADT "CVErrorCode"
   , ("CvENODEUSERSCRIPTS",             'C.cvEnodeuserscriptsCode)
   , ("CvENODEFILESTORAGEPATHS",        'C.cvEnodefilestoragepathsCode)
   , ("CvENODEFILESTORAGEPATHUNUSABLE", 'C.cvEnodefilestoragepathunusableCode)
+  , ("CvENODESHAREDFILESTORAGEPATHUNUSABLE",
+     'C.cvEnodesharedfilestoragepathunusableCode)
   ])
 $(THH.makeJSONInstance ''CVErrorCode)