From 57bde97bc9bc0168b7954349aa373225091aad04 Mon Sep 17 00:00:00 2001 From: Mikhail Khodos Date: Fri, 11 Mar 2016 17:20:23 -0800 Subject: [PATCH] Fix for NexentaEdge jsonrpc url formatting LOG.info if the volume is already deleted on appliance instead of raising an error. Convert nexenta_blocksize to str before sending request. Changed the chunksize default to recommended value of 32768. Change-Id: I3f8d7c668450972e336450488b75ce2ab7d78ba1 --- cinder/tests/unit/test_nexenta_edge.py | 3 +++ cinder/volume/drivers/nexenta/iscsi.py | 3 ++- cinder/volume/drivers/nexenta/nexentaedge/iscsi.py | 7 ++++--- cinder/volume/drivers/nexenta/nexentaedge/jsonrpc.py | 8 ++++---- cinder/volume/drivers/nexenta/options.py | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cinder/tests/unit/test_nexenta_edge.py b/cinder/tests/unit/test_nexenta_edge.py index a6426cd4888..6c5e6e9dfec 100644 --- a/cinder/tests/unit/test_nexenta_edge.py +++ b/cinder/tests/unit/test_nexenta_edge.py @@ -17,6 +17,7 @@ import mock from cinder import context +from cinder import exception from cinder import test from cinder.volume import configuration as conf from cinder.volume.drivers.nexenta.nexentaedge import iscsi @@ -97,6 +98,8 @@ class TestNexentaEdgeISCSIDriver(test.TestCase): self.assertRaises(RuntimeError, self.driver.create_volume, MOCK_VOL) def test_delete_volume(self): + self.mock_api.side_effect = exception.VolumeBackendAPIException( + 'No volume') self.driver.delete_volume(MOCK_VOL) self.mock_api.assert_called_with(NEDGE_URL, { 'objectPath': NEDGE_BUCKET + '/' + MOCK_VOL['id'] diff --git a/cinder/volume/drivers/nexenta/iscsi.py b/cinder/volume/drivers/nexenta/iscsi.py index 0ba72dab98c..99fcd789ba8 100644 --- a/cinder/volume/drivers/nexenta/iscsi.py +++ b/cinder/volume/drivers/nexenta/iscsi.py @@ -17,6 +17,7 @@ .. automodule:: nexenta.iscsi """ +import six from oslo_log import log as logging from oslo_utils import excutils @@ -214,7 +215,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver): self.nms.zvol.create( self._get_zvol_name(volume['name']), '%sG' % (volume['size'],), - self.configuration.nexenta_blocksize, + six.text_type(self.configuration.nexenta_blocksize), self.configuration.nexenta_sparse) def extend_volume(self, volume, new_size): diff --git a/cinder/volume/drivers/nexenta/nexentaedge/iscsi.py b/cinder/volume/drivers/nexenta/nexentaedge/iscsi.py index 488a30f777c..7b8eb99621a 100644 --- a/cinder/volume/drivers/nexenta/nexentaedge/iscsi.py +++ b/cinder/volume/drivers/nexenta/nexentaedge/iscsi.py @@ -20,7 +20,7 @@ from oslo_utils import excutils from oslo_utils import units from cinder import exception -from cinder.i18n import _, _LE +from cinder.i18n import _, _LE, _LI from cinder.volume import driver from cinder.volume.drivers.nexenta.nexentaedge import jsonrpc from cinder.volume.drivers.nexenta import options @@ -164,8 +164,9 @@ class NexentaEdgeISCSIDriver(driver.ISCSIDriver): '/iscsi', {'objectPath': self.bucket_path + '/' + volume['name']}) except exception.VolumeBackendAPIException: - with excutils.save_and_reraise_exception(): - LOG.exception(_LE('Error deleting volume')) + LOG.info( + _LI('Volume was already deleted from appliance, skipping.'), + resource=volume) def extend_volume(self, volume, new_size): try: diff --git a/cinder/volume/drivers/nexenta/nexentaedge/jsonrpc.py b/cinder/volume/drivers/nexenta/nexentaedge/jsonrpc.py index 10d2e833a8b..fce277a289d 100644 --- a/cinder/volume/drivers/nexenta/nexentaedge/jsonrpc.py +++ b/cinder/volume/drivers/nexenta/nexentaedge/jsonrpc.py @@ -47,8 +47,8 @@ class NexentaEdgeJSONProxy(object): @property def url(self): - return '%s://%s:%s%s' % (self.protocol, - self.host, self.port, self.path) + return '%s://%s:%s/%s' % (self.protocol, + self.host, self.port, self.path) def __getattr__(self, name): if not self.method: @@ -68,7 +68,7 @@ class NexentaEdgeJSONProxy(object): @retry(retry_exc_tuple, interval=1, retries=6) def __call__(self, *args): - self.path += args[0] + self.path = args[0] data = None if len(args) > 1: data = json.dumps(args[1]) @@ -79,7 +79,7 @@ class NexentaEdgeJSONProxy(object): 'Authorization': 'Basic %s' % auth } - LOG.debug('Sending JSON data: %s', self.url) + LOG.debug('Sending JSON data: %s, data: %s', self.url, data) if self.method == 'get': req = requests.get(self.url, headers=headers) diff --git a/cinder/volume/drivers/nexenta/options.py b/cinder/volume/drivers/nexenta/options.py index 5441456e839..d6dcf402f2e 100644 --- a/cinder/volume/drivers/nexenta/options.py +++ b/cinder/volume/drivers/nexenta/options.py @@ -44,7 +44,7 @@ NEXENTA_EDGE_OPTS = [ help='NexentaEdge iSCSI Gateway client ' 'address for non-VIP service'), cfg.IntOpt('nexenta_chunksize', - default=16384, + default=32768, help='NexentaEdge iSCSI LUN object chunk size') ]