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
This commit is contained in:
Eric Harney 2013-12-20 11:30:51 -05:00
parent 8fca3a85f3
commit 4edde1fc93
2 changed files with 61 additions and 10 deletions

View File

@ -1,4 +1,3 @@
# Copyright (c) 2013 Red Hat, Inc.
# All Rights Reserved.
#
@ -24,6 +23,7 @@ from mox import IgnoreArg
from mox import IsA
from mox import stubout
from cinder import brick
from cinder import context
from cinder import db
from cinder import exception
@ -91,6 +91,23 @@ class GlusterFsDriverTestCase(test.TestCase):
stub = mox_lib.MockObject(attr_to_replace)
self.stubs.Set(obj, attr_name, stub)
def test_set_execute(self):
mox = self._mox
drv = self._driver
rfsclient = brick.remotefs.remotefs.RemoteFsClient
mox.StubOutWithMock(rfsclient, 'set_execute')
def my_execute(*a, **k):
pass
rfsclient.set_execute(my_execute)
mox.ReplayAll()
drv.set_execute(my_execute)
def test_local_path(self):
"""local_path common use case."""
glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
@ -191,14 +208,22 @@ class GlusterFsDriverTestCase(test.TestCase):
drv._get_hash_str(self.TEST_EXPORT1))
def test_get_mount_point_for_share(self):
"""_get_mount_point_for_share should calculate correct value."""
"""_get_mount_point_for_share should call RemoteFsClient."""
mox = self._mox
drv = self._driver
hashed_path = '/mnt/test/abcdefabcdef'
mox.StubOutWithMock(brick.remotefs.remotefs.RemoteFsClient,
'get_mount_point')
glusterfs.CONF.glusterfs_mount_point_base = self.TEST_MNT_POINT_BASE
self.assertEqual('/mnt/test/ab03ab34eaca46a5fb81878f7e9b91fc',
drv._get_mount_point_for_share(
self.TEST_EXPORT1))
brick.remotefs.remotefs.RemoteFsClient.\
get_mount_point(self.TEST_EXPORT1).AndReturn(hashed_path)
mox.ReplayAll()
drv._get_mount_point_for_share(self.TEST_EXPORT1)
def test_get_available_capacity_with_df(self):
"""_get_available_capacity should calculate correct value."""
@ -1646,3 +1671,11 @@ class GlusterFsDriverTestCase(test.TestCase):
self.assertEqual(conn_info['data']['format'], 'raw')
self.assertEqual(conn_info['driver_volume_type'], 'glusterfs')
self.assertEqual(conn_info['data']['name'], volume['name'])
self.assertEqual(conn_info['mount_point_base'],
self.TEST_MNT_POINT_BASE)
def test_get_mount_point_base(self):
(mox, drv) = self._mox, self._driver
self.assertEqual(drv._get_mount_point_base(),
self.TEST_MNT_POINT_BASE)

View File

@ -23,11 +23,13 @@ import time
from oslo.config import cfg
from cinder.brick.remotefs import remotefs
from cinder import compute
from cinder import db
from cinder import exception
from cinder.image import image_utils
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
from cinder import units
from cinder import utils
from cinder.volume.drivers import nfs
@ -68,12 +70,25 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
driver_volume_type = 'glusterfs'
driver_prefix = 'glusterfs'
volume_backend_name = 'GlusterFS'
VERSION = '1.1.0'
VERSION = '1.1.1'
def __init__(self, *args, **kwargs):
def __init__(self, execute=processutils.execute, *args, **kwargs):
self._remotefsclient = None
super(GlusterfsDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(volume_opts)
self._nova = None
self.base = getattr(self.configuration,
'glusterfs_mount_point_base',
CONF.glusterfs_mount_point_base)
self._remotefsclient = remotefs.RemoteFsClient(
'glusterfs',
execute,
glusterfs_mount_point_base=self.base)
def set_execute(self, execute):
super(GlusterfsDriver, self).set_execute(execute)
if self._remotefsclient:
self._remotefsclient.set_execute(execute)
def do_setup(self, context):
"""Any initialization the volume driver does while starting."""
@ -906,7 +921,8 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
return {
'driver_volume_type': 'glusterfs',
'data': data
'data': data,
'mount_point_base': self._get_mount_point_base()
}
def terminate_connection(self, volume, connector, **kwargs):
@ -1095,8 +1111,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
"""Return mount point for share.
:param glusterfs_share: example 172.18.194.100:/var/glusterfs
"""
return os.path.join(self.configuration.glusterfs_mount_point_base,
self._get_hash_str(glusterfs_share))
return self._remotefsclient.get_mount_point(glusterfs_share)
def _get_available_capacity(self, glusterfs_share):
"""Calculate available space on the GlusterFS share.
@ -1127,3 +1142,6 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
command.extend(self.shares[glusterfs_share].split())
self._do_mount(command, ensure, glusterfs_share)
def _get_mount_point_base(self):
return self.base