-
# Copyright (c) 2013 Red Hat, Inc.
# All Rights Reserved.
#
from mox import IsA
from mox import stubout
+from cinder import brick
from cinder import context
from cinder import db
from cinder import exception
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
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."""
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)
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
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."""
return {
'driver_volume_type': 'glusterfs',
- 'data': data
+ 'data': data,
+ 'mount_point_base': self._get_mount_point_base()
}
def terminate_connection(self, volume, connector, **kwargs):
"""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.
command.extend(self.shares[glusterfs_share].split())
self._do_mount(command, ensure, glusterfs_share)
+
+ def _get_mount_point_base(self):
+ return self.base