QNAP: driver fails to detach while uploading volume to image
After upload volume to image, driver fails to detach iscsi device. We fixed the passed parameters in detach function. Change-Id: I5d63a4850f61a838ff1d4a5f1b6612f863b2bfd1 Closes-Bug: #1766768
This commit is contained in:
parent
dba086ee9b
commit
ee9fda3e89
@ -31,6 +31,7 @@ from six.moves import urllib
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
from cinder import utils
|
||||
from cinder.volume import driver
|
||||
from cinder.volume.drivers import qnap
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -1263,6 +1264,7 @@ class QnapDriverLoginTestCase(QnapDriverBaseTestCase):
|
||||
self.assertEqual(ssl, self.driver.api_executor.ssl)
|
||||
|
||||
|
||||
@ddt
|
||||
class QnapDriverVolumeTestCase(QnapDriverBaseTestCase):
|
||||
"""Tests volume related api's."""
|
||||
|
||||
@ -2369,6 +2371,77 @@ class QnapDriverVolumeTestCase(QnapDriverBaseTestCase):
|
||||
fake_volume, fake_new_volume,
|
||||
'fakeOriginalVolumeStatus')
|
||||
|
||||
@data({
|
||||
'fake_spec': {},
|
||||
'expect_spec': {
|
||||
'force': False,
|
||||
'ignore_errors': False,
|
||||
'remote': False
|
||||
}
|
||||
}, {
|
||||
'fake_spec': {
|
||||
'force': mock.sentinel.force,
|
||||
'ignore_errors': mock.sentinel.ignore_errors,
|
||||
'remote': mock.sentinel.remote
|
||||
},
|
||||
'expect_spec': {
|
||||
'force': mock.sentinel.force,
|
||||
'ignore_errors': mock.sentinel.ignore_errors,
|
||||
'remote': mock.sentinel.remote
|
||||
}
|
||||
})
|
||||
@unpack
|
||||
@mock.patch.object(driver.BaseVD, '_detach_volume')
|
||||
@mock.patch('cinder.volume.drivers.qnap.QnapAPIExecutor')
|
||||
def test_detach_volume(
|
||||
self,
|
||||
mock_api_executor,
|
||||
mock_detach_volume,
|
||||
fake_spec, expect_spec):
|
||||
"""Test detach volume."""
|
||||
|
||||
mock_detach_volume.return_value = None
|
||||
mock_api_executor.return_value.get_basic_info.return_value = (
|
||||
'ES1640dc ', 'ES1640dc ', '1.1.3')
|
||||
self.driver = qnap.QnapISCSIDriver(
|
||||
configuration=create_configuration(
|
||||
'admin',
|
||||
'qnapadmin',
|
||||
'http://1.2.3.4:8080',
|
||||
'1.2.3.4',
|
||||
'Pool1',
|
||||
True))
|
||||
self.driver.do_setup('context')
|
||||
self.driver._detach_volume('context',
|
||||
'attach_info', 'volume',
|
||||
'property', **fake_spec)
|
||||
mock_detach_volume.assert_called_once_with(
|
||||
'context', 'attach_info', 'volume', 'property', **expect_spec)
|
||||
|
||||
@mock.patch.object(driver.BaseVD, '_attach_volume')
|
||||
@mock.patch('cinder.volume.drivers.qnap.QnapAPIExecutor')
|
||||
def test_attach_volume(
|
||||
self,
|
||||
mock_api_executor,
|
||||
mock_attach_volume):
|
||||
"""Test attach volume."""
|
||||
|
||||
mock_attach_volume.return_value = None
|
||||
mock_api_executor.return_value.get_basic_info.return_value = (
|
||||
'ES1640dc ', 'ES1640dc ', '1.1.3')
|
||||
self.driver = qnap.QnapISCSIDriver(
|
||||
configuration=create_configuration(
|
||||
'admin',
|
||||
'qnapadmin',
|
||||
'http://1.2.3.4:8080',
|
||||
'1.2.3.4',
|
||||
'Pool1',
|
||||
True))
|
||||
self.driver.do_setup('context')
|
||||
self.driver._attach_volume('context', 'volume', 'properties')
|
||||
mock_attach_volume.assert_called_once_with(
|
||||
'context', 'volume', 'properties', False)
|
||||
|
||||
|
||||
class QnapAPIExecutorEsTestCase(QnapDriverBaseTestCase):
|
||||
"""Tests QnapAPIExecutor."""
|
||||
|
@ -1083,10 +1083,13 @@ class QnapISCSIDriver(san.SanISCSIDriver):
|
||||
|
||||
@utils.synchronized('_attach_volume')
|
||||
def _detach_volume(self, context, attach_info, volume, properties,
|
||||
force=False, remote=False):
|
||||
super(QnapISCSIDriver, self)._detach_volume(context, attach_info,
|
||||
volume, properties,
|
||||
force, remote)
|
||||
force=False, remote=False, ignore_errors=False):
|
||||
super(QnapISCSIDriver, self)._detach_volume(
|
||||
context, attach_info,
|
||||
volume, properties,
|
||||
force=force, remote=remote,
|
||||
ignore_errors=ignore_errors
|
||||
)
|
||||
|
||||
@utils.synchronized('_attach_volume')
|
||||
def _attach_volume(self, context, volume, properties, remote=False):
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed QNAP driver failures to detach iscsi device while uploading volume
|
||||
to image.
|
Loading…
x
Reference in New Issue
Block a user