Browse Source

Brick connector fix for GlusterFS

Fixes an InvalidParameterValue error by passing the required
information to Brick for mounting.

See also: 1cd3626 Brick connector revised fix for NFS

Bump driver version 1.1.1.

Closes-Bug: 1238085

Change-Id: Ie45889460dd4775a556d592161c98c24a56989c7
tags/2014.1.b3
Eric Harney 5 years ago
parent
commit
4edde1fc93
2 changed files with 61 additions and 10 deletions
  1. 38
    5
      cinder/tests/test_glusterfs.py
  2. 23
    5
      cinder/volume/drivers/glusterfs.py

+ 38
- 5
cinder/tests/test_glusterfs.py View File

@@ -1,4 +1,3 @@
1
-
2 1
 # Copyright (c) 2013 Red Hat, Inc.
3 2
 # All Rights Reserved.
4 3
 #
@@ -24,6 +23,7 @@ from mox import IgnoreArg
24 23
 from mox import IsA
25 24
 from mox import stubout
26 25
 
26
+from cinder import brick
27 27
 from cinder import context
28 28
 from cinder import db
29 29
 from cinder import exception
@@ -91,6 +91,23 @@ class GlusterFsDriverTestCase(test.TestCase):
91 91
         stub = mox_lib.MockObject(attr_to_replace)
92 92
         self.stubs.Set(obj, attr_name, stub)
93 93
 
94
+    def test_set_execute(self):
95
+        mox = self._mox
96
+        drv = self._driver
97
+
98
+        rfsclient = brick.remotefs.remotefs.RemoteFsClient
99
+
100
+        mox.StubOutWithMock(rfsclient, 'set_execute')
101
+
102
+        def my_execute(*a, **k):
103
+            pass
104
+
105
+        rfsclient.set_execute(my_execute)
106
+
107
+        mox.ReplayAll()
108
+
109
+        drv.set_execute(my_execute)
110
+
94 111
     def test_local_path(self):
95 112
         """local_path common use case."""
96 113
         glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
@@ -191,14 +208,22 @@ class GlusterFsDriverTestCase(test.TestCase):
191 208
                          drv._get_hash_str(self.TEST_EXPORT1))
192 209
 
193 210
     def test_get_mount_point_for_share(self):
194
-        """_get_mount_point_for_share should calculate correct value."""
211
+        """_get_mount_point_for_share should call RemoteFsClient."""
212
+        mox = self._mox
195 213
         drv = self._driver
214
+        hashed_path = '/mnt/test/abcdefabcdef'
215
+
216
+        mox.StubOutWithMock(brick.remotefs.remotefs.RemoteFsClient,
217
+                            'get_mount_point')
196 218
 
197 219
         glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
198 220
 
199
-        self.assertEqual('/mnt/test/ab03ab34eaca46a5fb81878f7e9b91fc',
200
-                         drv._get_mount_point_for_share(
201
-                             self.TEST_EXPORT1))
221
+        brick.remotefs.remotefs.RemoteFsClient.\
222
+            get_mount_point(self.TEST_EXPORT1).AndReturn(hashed_path)
223
+
224
+        mox.ReplayAll()
225
+
226
+        drv._get_mount_point_for_share(self.TEST_EXPORT1)
202 227
 
203 228
     def test_get_available_capacity_with_df(self):
204 229
         """_get_available_capacity should calculate correct value."""
@@ -1646,3 +1671,11 @@ class GlusterFsDriverTestCase(test.TestCase):
1646 1671
         self.assertEqual(conn_info['data']['format'], 'raw')
1647 1672
         self.assertEqual(conn_info['driver_volume_type'], 'glusterfs')
1648 1673
         self.assertEqual(conn_info['data']['name'], volume['name'])
1674
+        self.assertEqual(conn_info['mount_point_base'],
1675
+                         self.TEST_MNT_POINT_BASE)
1676
+
1677
+    def test_get_mount_point_base(self):
1678
+        (mox, drv) = self._mox, self._driver
1679
+
1680
+        self.assertEqual(drv._get_mount_point_base(),
1681
+                         self.TEST_MNT_POINT_BASE)

+ 23
- 5
cinder/volume/drivers/glusterfs.py View File

@@ -23,11 +23,13 @@ import time
23 23
 
24 24
 from oslo.config import cfg
25 25
 
26
+from cinder.brick.remotefs import remotefs
26 27
 from cinder import compute
27 28
 from cinder import db
28 29
 from cinder import exception
29 30
 from cinder.image import image_utils
30 31
 from cinder.openstack.common import log as logging
32
+from cinder.openstack.common import processutils
31 33
 from cinder import units
32 34
 from cinder import utils
33 35
 from cinder.volume.drivers import nfs
@@ -68,12 +70,25 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
68 70
     driver_volume_type = 'glusterfs'
69 71
     driver_prefix = 'glusterfs'
70 72
     volume_backend_name = 'GlusterFS'
71
-    VERSION = '1.1.0'
73
+    VERSION = '1.1.1'
72 74
 
73
-    def __init__(self, *args, **kwargs):
75
+    def __init__(self, execute=processutils.execute, *args, **kwargs):
76
+        self._remotefsclient = None
74 77
         super(GlusterfsDriver, self).__init__(*args, **kwargs)
75 78
         self.configuration.append_config_values(volume_opts)
76 79
         self._nova = None
80
+        self.base = getattr(self.configuration,
81
+                            'glusterfs_mount_point_base',
82
+                            CONF.glusterfs_mount_point_base)
83
+        self._remotefsclient = remotefs.RemoteFsClient(
84
+            'glusterfs',
85
+            execute,
86
+            glusterfs_mount_point_base=self.base)
87
+
88
+    def set_execute(self, execute):
89
+        super(GlusterfsDriver, self).set_execute(execute)
90
+        if self._remotefsclient:
91
+            self._remotefsclient.set_execute(execute)
77 92
 
78 93
     def do_setup(self, context):
79 94
         """Any initialization the volume driver does while starting."""
@@ -906,7 +921,8 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
906 921
 
907 922
         return {
908 923
             'driver_volume_type': 'glusterfs',
909
-            'data': data
924
+            'data': data,
925
+            'mount_point_base': self._get_mount_point_base()
910 926
         }
911 927
 
912 928
     def terminate_connection(self, volume, connector, **kwargs):
@@ -1095,8 +1111,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
1095 1111
         """Return mount point for share.
1096 1112
         :param glusterfs_share: example 172.18.194.100:/var/glusterfs
1097 1113
         """
1098
-        return os.path.join(self.configuration.glusterfs_mount_point_base,
1099
-                            self._get_hash_str(glusterfs_share))
1114
+        return self._remotefsclient.get_mount_point(glusterfs_share)
1100 1115
 
1101 1116
     def _get_available_capacity(self, glusterfs_share):
1102 1117
         """Calculate available space on the GlusterFS share.
@@ -1127,3 +1142,6 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
1127 1142
             command.extend(self.shares[glusterfs_share].split())
1128 1143
 
1129 1144
         self._do_mount(command, ensure, glusterfs_share)
1145
+
1146
+    def _get_mount_point_base(self):
1147
+        return self.base

Loading…
Cancel
Save