From 62e96e1d2796eb09bc4dfb0fa1bf055f7315b7f6 Mon Sep 17 00:00:00 2001 From: Victor Rodionov Date: Fri, 11 Oct 2013 00:21:44 +0400 Subject: [PATCH] Nexenta NFS driver: caching for appliance volroot Added caching for NexentaStor appliance 'volroot' value. Change-Id: I3803981cc8c9b6c47dc9fccc6b2414e21d9d6285 --- cinder/tests/test_nexenta.py | 2 ++ cinder/volume/drivers/nexenta/nfs.py | 19 +++++++++++++++---- cinder/volume/drivers/nexenta/options.py | 6 +++++- etc/cinder/cinder.conf.sample | 4 ++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cinder/tests/test_nexenta.py b/cinder/tests/test_nexenta.py index 4d2271c70..437b9a789 100644 --- a/cinder/tests/test_nexenta.py +++ b/cinder/tests/test_nexenta.py @@ -390,9 +390,11 @@ class TestNexentaNfsDriver(test.TestCase): self.configuration.nexenta_volume_compression = 'on' self.configuration.nfs_mount_point_base = '/mnt/test' self.configuration.nfs_mount_options = None + self.configuration.nexenta_nms_cache_volroot = False self.nms_mock = self.mox.CreateMockAnything() for mod in ('appliance', 'folder', 'server', 'volume', 'netstorsvc'): setattr(self.nms_mock, mod, self.mox.CreateMockAnything()) + self.nms_mock.__hash__ = lambda *_, **__: 1 self.stubs.Set(jsonrpc, 'NexentaJSONProxy', lambda *_, **__: self.nms_mock) self.drv = nfs.NexentaNfsDriver(configuration=self.configuration) diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index 3edaa484a..cbe89d679 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -25,7 +25,6 @@ import hashlib import os -import urlparse from oslo.config import cfg @@ -39,6 +38,7 @@ from cinder.volume.drivers.nexenta import options from cinder.volume.drivers.nexenta import utils from cinder.volume.drivers import nfs +VERSION = '1.1.1' LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -51,10 +51,10 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 Version history: 1.0.0 - Initial driver version. 1.1.0 - Auto sharing for enclosing folder. + 1.1.1 - Added caching for NexentaStor appliance 'volroot' value. """ - VERSION = '1.1.0' - + VERSION = VERSION driver_prefix = 'nexenta' def __init__(self, *args, **kwargs): @@ -62,6 +62,9 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 if self.configuration: self.configuration.append_config_values( options.NEXENTA_NFS_OPTIONS) + conf = self.configuration + self.nms_cache_volroot = conf.nexenta_nms_cache_volroot + self._nms2volroot = {} def do_setup(self, context): super(NexentaNfsDriver, self).do_setup(context) @@ -386,9 +389,17 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 ctxt = context.get_admin_context() return self.db.volume_get(ctxt, snapshot['volume_id']) + def _get_volroot(self, nms): + """Returns volroot property value from NexentaStor appliance.""" + if not self.nms_cache_volroot: + return nms.server.get_prop('volroot') + if nms not in self._nms2volroot: + self._nms2volroot[nms] = nms.server.get_prop('volroot') + return self._nms2volroot[nms] + def _get_share_datasets(self, nfs_share): nms = self.share2nms[nfs_share] - volroot = nms.server.get_prop('volroot') + volroot = self._get_volroot(nms) path = nfs_share.split(':')[1][len(volroot):].strip('/') volume_name = path.split('/')[0] folder_name = '/'.join(path.split('/')[1:]) diff --git a/cinder/volume/drivers/nexenta/options.py b/cinder/volume/drivers/nexenta/options.py index 1f30db81c..b71e3d2d5 100644 --- a/cinder/volume/drivers/nexenta/options.py +++ b/cinder/volume/drivers/nexenta/options.py @@ -88,7 +88,11 @@ NEXENTA_NFS_OPTIONS = [ 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.BoolOpt('nexenta_nms_cache_volroot', + default=True, + help=('If set True cache NexentaStor appliance volroot option ' + 'value.')) ] NEXENTA_VOLUME_OPTIONS = [ diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 05e09b1d3..1cedb846b 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -1369,6 +1369,10 @@ # destination will no longer be valid. (floating point value) #nexenta_oversub_ratio=1.0 +# If set True cache NexentaStor appliance volroot option +# value. (boolean value) +#nexenta_nms_cache_volroot=true + # block size for volumes (blank=default,8KB) (string value) #nexenta_blocksize= -- 2.45.2