Change in vdsm[master]: gluster: New verb to mount & update fstab for meta-volume

dnarayan at redhat.com dnarayan at redhat.com
Mon May 4 14:11:14 UTC 2015


Darshan N has uploaded a new change for review.

Change subject: gluster: New verb to mount & update fstab for meta-volume
......................................................................

gluster: New verb to mount & update fstab for meta-volume

This patch adds a new verb 'MetaVolumeMount' to
update fstab entry for meta-volume and mount it. This
meta-volume is needed by various glusterfs features
like snapshot-schedule, geo-replication etc. It is
expected to be mounted on all gluster nodes.

Change-Id: If2d109a5de9374f21b1b94f73187b653c121a8b4
Signed-off-by: Darshan N <dnarayan at redhat.com>
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/apiwrapper.py
M vdsm/gluster/exception.py
M vdsm/rpc/vdsmapi-gluster-schema.json
5 files changed, 68 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/97/40497/1

diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 4f53eb4..b78653e 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -758,6 +758,11 @@
         pp.pprint(status)
         return status['status']['code'], status['status']['message']
 
+    def do_glusterMetaVolumeMount(self, args):
+        status = self.s.glusterMetaVolumeMount()
+        pp.pprint(status)
+        return status['status']['code'], status['status']['message']
+
 
 def getGlusterCmdDict(serv):
     return \
@@ -1288,5 +1293,10 @@
              serv.do_glusterVolumeEmptyCheck,
              ('volumeName=<volume name>',
               'Check if the given volume is empty or not'
+              )),
+         'glusterMetaVolumeMount': (
+             serv.do_glusterMetaVolumeMount,
+             ('',
+              'mount the meta-volume'
               ))
          }
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 222aacb..c2ba04c 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -22,16 +22,23 @@
 import os
 from functools import wraps
 from vdsm.define import doneCode
+from vdsm import constants
+from vdsm import utils
+from hostname import getHostNameFqdn, HostNameException
 from pwd import getpwnam
 
 import supervdsm as svdsm
 import exception as ge
 from . import makePublic
 from . import safeWrite
+import fstab
 
 _SUCCESS = {'status': doneCode}
 GEOREP_PUB_KEY_PATH = "/var/lib/glusterd/geo-replication/common_secret.pem.pub"
 MOUNT_BROKER_ROOT = "/var/mountbroker-root"
+META_VOLUME = "/gluster_shared_storage"
+META_VOL_MOUNT_POINT = "/var/run/gluster/shared_storage"
+FS_TYPE = "glusterfs"
 
 
 GLUSTER_RPM_PACKAGES = (
@@ -140,6 +147,29 @@
         except OSError as e:
             raise ge.GlusterMountBrokerRootCreateFailedException(err=[str(e)])
     return
+
+
+ at makePublic
+def metaVolumeFstabUpdate():
+    try:
+        device = getHostNameFqdn() + ":" + META_VOLUME
+        fstab.FsTab().add(device, META_VOL_MOUNT_POINT, FS_TYPE,
+                          mntOpts=['defaults', '_netdev'])
+    except (IOError, HostNameException) as e:
+        raise ge.GlusterMetaVolumeFstabUpdateFailedException(err=[str(e)])
+    except ge.GlusterException as e:
+        raise ge.GlusterMetaVolumeFstabUpdateFailedException(err=[e.message])
+    return device
+
+
+ at makePublic
+def mountMetaVolume(device):
+    command = [constants.EXT_MOUNT, device]
+    rc, out, err = utils.execCmd(command)
+    if rc:
+        raise ge.GlusterMetaVolumeMountFailedException(
+            rc, out, err)
+    return True
 
 
 class GlusterApi(object):
@@ -645,6 +675,11 @@
         status = self.svdsmProxy.glusterVolumeEmptyCheck(volumeName)
         return {'volumeEmptyCheck': status}
 
+    @exportAsVerb
+    def metaVolumeMount(self, options=None):
+        device = self.svdsmProxy.glusterMetaVolumeFstabUpdate()
+        self.svdsmProxy.glusterMountMetaVolume(device)
+
 
 def getGlusterMethods(gluster):
     l = []
diff --git a/vdsm/gluster/apiwrapper.py b/vdsm/gluster/apiwrapper.py
index 6d70a85..245a823 100644
--- a/vdsm/gluster/apiwrapper.py
+++ b/vdsm/gluster/apiwrapper.py
@@ -309,6 +309,9 @@
     def volumeEmptyCheck(self, volumeName):
         return self._gluster.volumeEmptyCheck(volumeName)
 
+    def metaVolumeMount(self):
+        return self._gluster.metaVolumeMount()
+
 
 class GlusterSnapshot(GlusterApiBase):
     def __init__(self):
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index d093661..10f3f76 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -581,6 +581,16 @@
     message = "Failed to Check if gluster volume is empty"
 
 
+class GlusterMetaVolumeMountFailedException(GlusterVolumeException):
+    code = 4575
+    message = "Failed to mount meta volume"
+
+
+class GlusterMetaVolumeFstabUpdateFailedException(GlusterVolumeException):
+    code = 4576
+    message = "Failed to Update fstab entry for meta-volume"
+
+
 # geo-replication
 class GlusterGeoRepException(GlusterException):
     code = 4200
diff --git a/vdsm/rpc/vdsmapi-gluster-schema.json b/vdsm/rpc/vdsmapi-gluster-schema.json
index 935adff..704ef57 100644
--- a/vdsm/rpc/vdsmapi-gluster-schema.json
+++ b/vdsm/rpc/vdsmapi-gluster-schema.json
@@ -2145,3 +2145,13 @@
 {'command': {'class': 'GlusterVolume', 'name': 'volumeEmptyCheck'},
  'data': {'volumeName': 'str'},
  'returns': 'VolumeEmptyCheck'}
+
+##
+# @GlusterVolume.metaVolumeMount:
+#
+# Mount glusterfs meta volume
+#
+# Since: 4.17.0
+##
+{'command': {'class': 'GlusterVolume', 'name': 'metaVolumeMount'},
+ 'data': {}}


-- 
To view, visit https://gerrit.ovirt.org/40497
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2d109a5de9374f21b1b94f73187b653c121a8b4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Darshan N <dnarayan at redhat.com>


More information about the vdsm-patches mailing list