import hashlib
import os
-from oslo.config import cfg
-
from cinder.brick import exception
from cinder.openstack.common.gettextutils import _
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
-remotefs_client_opts = [
- cfg.StrOpt('nfs_mount_point_base',
- default='$state_path/mnt',
- help='Base dir containing mount points for nfs shares'),
- cfg.StrOpt('nfs_mount_options',
- default=None,
- help='Mount options passed to the nfs client. See section '
- 'of the nfs man page for details'),
- cfg.StrOpt('glusterfs_mount_point_base',
- default='$state_path/mnt',
- help='Base dir containing mount points for gluster shares'),
-]
-
-CONF = cfg.CONF
-CONF.register_opts(remotefs_client_opts)
-
class RemoteFsClient(object):
self._mount_type = mount_type
if mount_type == "nfs":
- self._mount_base = CONF.nfs_mount_point_base
- self._mount_options = CONF.nfs_mount_options
+ self._mount_base = kwargs.get('nfs_mount_point_base', None)
+ if not self._mount_base:
+ raise exception.InvalidParameterValue(
+ err=_('nfs_mount_point_base required'))
+ self._mount_options = kwargs.get('nfs_mount_options', None)
elif mount_type == "glusterfs":
- self._mount_base = CONF.glusterfs_mount_point_base
+ self._mount_base = kwargs.get('glusterfs_mount_point_base', None)
+ if not self._mount_base:
+ raise exception.InvalidParameterValue(
+ err=_('glusterfs_mount_point_base required'))
self._mount_options = None
else:
raise exception.ProtocolNotSupported(protocol=mount_type)
obj = connector.InitiatorConnector.factory('aoe', None)
self.assertEqual(obj.__class__.__name__, "AoEConnector")
- obj = connector.InitiatorConnector.factory('nfs', None)
+ obj = connector.InitiatorConnector.factory(
+ 'nfs', None, nfs_mount_point_base='/mnt/test')
self.assertEqual(obj.__class__.__name__, "RemoteFsConnector")
- obj = connector.InitiatorConnector.factory('glusterfs', None)
+ obj = connector.InitiatorConnector.factory(
+ 'glusterfs', None, glusterfs_mount_point_base='/mnt/test')
self.assertEqual(obj.__class__.__name__, "RemoteFsConnector")
obj = connector.InitiatorConnector.factory('local', None)
self.connection_properties = {
'export': self.TEST_DEV,
'name': '9c592d52-ce47-4263-8c21-4ecf3c029cdb'}
- self.connector = connector.RemoteFsConnector('nfs', root_helper='sudo')
- self.connector._remotefsclient._mount_options = None
- self.connector._remotefsclient._mount_base = '/mnt/test'
+ self.connector = connector.RemoteFsConnector(
+ 'nfs', root_helper='sudo', nfs_mount_point_base='/mnt/test')
def tearDown(self):
self.mox.VerifyAll()
def setUp(self):
super(BrickRemoteFsTestCase, self).setUp()
self._mox = mox.Mox()
- self._nfsclient = remotefs.RemoteFsClient('nfs', 'sudo')
- self._nfsclient._mount_options = None
- self._nfsclient._mount_base = self.TEST_MNT_BASE
+ self._nfsclient = remotefs.RemoteFsClient(
+ 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE)
self.addCleanup(self._mox.UnsetStubs)
def test_get_hash_str(self):
client.mount(self.TEST_EXPORT)
mox.VerifyAll()
+
+ def test_nfs_mount_options(self):
+ opts = 'test_nfs_mount_options'
+ client = remotefs.RemoteFsClient(
+ 'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE,
+ nfs_mount_options=opts)
+ self.assertEqual(opts, client._mount_options)
+
+ def test_nfs_mount_point_base(self):
+ base = '/mnt/test/nfs/mount/point/base'
+ client = remotefs.RemoteFsClient('nfs', 'sudo',
+ nfs_mount_point_base=base)
+ self.assertEqual(base, client._mount_base)
+
+ def test_glusterfs_mount_point_base(self):
+ base = '/mnt/test/glusterfs/mount/point/base'
+ client = remotefs.RemoteFsClient('glusterfs', 'sudo',
+ glusterfs_mount_point_base=base)
+ self.assertEqual(base, client._mount_base)
from cinder.volume.drivers.netapp import nfs as netapp_nfs
+from oslo.config import cfg
+CONF = cfg.CONF
+
LOG = logging.getLogger(__name__)
def create_configuration():
configuration = mox.MockObject(conf.Configuration)
configuration.append_config_values(mox.IgnoreArg())
+ configuration.nfs_mount_point_base = '/mnt/test'
+ configuration.nfs_mount_options = None
return configuration
kwargs = {}
kwargs['netapp_mode'] = 'proxy'
kwargs['configuration'] = create_configuration()
- self._driver = netapp_nfs.NetAppDirectCmodeNfsDriver(
- **kwargs)
+ self._driver = netapp_nfs.NetAppDirectCmodeNfsDriver(**kwargs)
def test_check_for_setup_error(self):
mox = self.mox
def setUp(self):
super(TestNexentaNfsDriver, self).setUp()
- self.stubs = stubout.StubOutForTesting()
self.configuration = mox_lib.MockObject(conf.Configuration)
self.configuration.nexenta_shares_config = None
self.configuration.nexenta_mount_point_base = '$state_path/mnt'
self.configuration.nexenta_sparsed_volumes = True
self.configuration.nexenta_volume_compression = 'on'
+ self.configuration.nfs_mount_point_base = '/mnt/test'
+ self.configuration.nfs_mount_options = None
self.nms_mock = self.mox.CreateMockAnything()
for mod in ('appliance', 'folder', 'server', 'volume', 'netstorsvc'):
setattr(self.nms_mock, mod, self.mox.CreateMockAnything())
self.configuration.nfs_sparsed_volumes = True
self.configuration.nfs_used_ratio = 0.95
self.configuration.nfs_oversub_ratio = 1.0
+ self.configuration.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
+ self.configuration.nfs_mount_options = None
self._driver = nfs.NfsDriver(configuration=self.configuration)
self._driver.shares = {}
- self._driver._remotefsclient._mount_options = None
- self._driver._remotefsclient._mount_base = self.TEST_MNT_POINT_BASE
self.addCleanup(self.stubs.UnsetAll)
self.addCleanup(self._mox.UnsetStubs)
from oslo.config import cfg
-from cinder.brick.remotefs import remotefs
from cinder import compute
from cinder import db
from cinder import exception
cfg.BoolOpt('glusterfs_qcow2_volumes',
default=False,
help=('Create volumes as QCOW2 files rather than raw files.')),
+ cfg.StrOpt('glusterfs_mount_point_base',
+ default='$state_path/mnt',
+ help='Base dir containing mount points for gluster shares.'),
]
CONF = cfg.CONF
def __init__(self, *args, **kwargs):
super(GlusterfsDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(volume_opts)
- self.configuration.append_config_values(remotefs.remotefs_client_opts)
self._nova = None
def do_setup(self, context):
default=1.0,
help=('This will compare the allocated to available space on '
'the volume destination. If the ratio exceeds this '
- 'number, the destination will no longer be valid.'))
+ 'number, the destination will no longer be valid.')),
+ cfg.StrOpt('nfs_mount_point_base',
+ default='$state_path/mnt',
+ help=('Base dir containing mount points for nfs shares.')),
+ cfg.StrOpt('nfs_mount_options',
+ default=None,
+ help=('Mount options passed to the nfs client. See section '
+ 'of the nfs man page for details.')),
]
VERSION = "0.0.0"
+ def __init__(self, *args, **kwargs):
+ super(RemoteFsDriver, self).__init__(*args, **kwargs)
+
def check_for_setup_error(self):
"""Just to override parent behavior."""
pass
super(NfsDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(volume_opts)
root_helper = utils.get_root_helper()
- self._remotefsclient = remotefs.RemoteFsClient('nfs', root_helper,
- execute=execute)
+ base = getattr(self.configuration,
+ 'nfs_mount_point_base',
+ CONF.nfs_mount_point_base)
+ opts = getattr(self.configuration,
+ 'nfs_mount_options',
+ CONF.nfs_mount_options)
+ self._remotefsclient = remotefs.RemoteFsClient(
+ 'nfs', root_helper, execute=execute,
+ nfs_mount_point_base=base,
+ nfs_mount_options=opts)
def set_execute(self, execute):
super(NfsDriver, self).set_execute(execute)
#volumes_dir=$state_path/volumes
-#
-# Options defined in cinder.brick.remotefs.remotefs
-#
-
-# Base dir containing mount points for nfs shares (string
-# value)
-#nfs_mount_point_base=$state_path/mnt
-
-# Mount options passed to the nfs client. See section of the
-# nfs man page for details (string value)
-#nfs_mount_options=<None>
-
-# Base dir containing mount points for gluster shares (string
-# value)
-#glusterfs_mount_point_base=$state_path/mnt
-
-
#
# Options defined in cinder.common.config
#
# (boolean value)
#glusterfs_qcow2_volumes=false
+# Base dir containing mount points for gluster shares. (string
+# value)
+#glusterfs_mount_point_base=$state_path/mnt
+
#
# Options defined in cinder.volume.drivers.gpfs
# destination will no longer be valid. (floating point value)
#nfs_oversub_ratio=1.0
+# Base dir containing mount points for nfs shares. (string
+# value)
+#nfs_mount_point_base=$state_path/mnt
+
+# Mount options passed to the nfs client. See section of the
+# nfs man page for details. (string value)
+#nfs_mount_options=<None>
+
#
# Options defined in cinder.volume.drivers.rbd