Fixup some issues of Inspur AS13000 cinder driver

Although Inspur AS13000 cinder driver has been merged,
some small issues have been left there, and this patch
is a follow-up for https://review.openstack.org/#/c/562977.

Change-Id: I3544c4ab3bf78feea36fed63a6d799ed4bb43d5a
Closes-Bug: #1810709
This commit is contained in:
wang yong 2019-01-07 19:51:32 +08:00 committed by Jay Bryant
parent b123042bb2
commit 3c17fd5491
3 changed files with 58 additions and 64 deletions

View File

@ -473,7 +473,7 @@ class AS13000DriverTestCase(test.TestCase):
mock.Mock())
mock_wvf = self.mock_object(self.as13000_san,
'_wait_volume_filled',
mock.Mock(side_effect=(False, True)))
mock.Mock())
mock_ev = self.mock_object(self.as13000_san, 'extend_volume',
mock.Mock())
@ -485,11 +485,7 @@ class AS13000DriverTestCase(test.TestCase):
]
mock_lock_op.assert_has_calls(lock_op_calls)
mock_fv.assert_called_once_with('dest_volume', 'fake_pool')
wait_volume_filled_calls = [
mock.call('dest_volume', 'fake_pool', 10, 5),
mock.call('dest_volume', 'fake_pool', 10, 5),
]
mock_wvf.assert_has_calls(wait_volume_filled_calls)
mock_wvf.assert_called_once_with('dest_volume', 'fake_pool')
mock_eh.assert_called()
mock_tnd.assert_called()
@ -1207,25 +1203,28 @@ class AS13000DriverTestCase(test.TestCase):
params=params,
request_type='post')
@ddt.data(2, 3)
def test__wait_volume_filled(self, attempts):
mock_gv = self.mock_object(self.as13000_san, '_get_volumes',
mock.Mock(side_effect=(
[{'name': 'fake_v1', 'lvmType': 2}],
[{'name': 'fake_v1', 'lvmType': 2}],
[{'name': 'fake_v1', 'lvmType': 1}]
)))
mock_el = self.mock_object(eventlet, 'sleep',
mock.Mock(return_value=None))
def test__wait_volume_filled(self):
# Need to mock sleep as it is called by @utils.retry
self.mock_object(time, 'sleep')
ret = self.as13000_san._wait_volume_filled('fake_v1', 'fake_pool',
attempts, 1)
if attempts == 2:
self.assertEqual(ret, False)
else:
self.assertEqual(ret, True)
expected = [{'name': 'fake_v1', 'lvmType': 1}]
mock_gv = self.mock_object(self.as13000_san, '_get_volumes',
mock.Mock(return_value=expected))
self.as13000_san._wait_volume_filled('fake_v1', 'fake_pool')
mock_gv.assert_called_with('fake_pool')
def test__wait_volume_filled_failed(self):
# Need to mock sleep as it is called by @utils.retry
self.mock_object(time, 'sleep')
expected = [{'name': 'fake_v1', 'lvmType': 2}]
mock_gv = self.mock_object(self.as13000_san, '_get_volumes',
mock.Mock(return_value=expected))
self.assertRaises(exception.VolumeDriverException,
self.as13000_san._wait_volume_filled,
'fake_v1',
'fake_pool')
mock_gv.assert_called_with('fake_pool')
mock_el.assert_called_with(1)
def test__get_lun_list(self):
target_name = 'fake_name'

View File

@ -167,11 +167,11 @@ class RestAPIExecutor(object):
class AS13000Driver(san.SanISCSIDriver):
"""Driver for Inspur AS13000 storage.
Version history:
.. code-block:: none
1.0.0 - Initial driver
Version history:
1.0.0 - Initial driver
"""
VENDOR = 'INSPUR'
@ -331,9 +331,7 @@ class AS13000Driver(san.SanISCSIDriver):
self._filling_volume(dest_name, dest_pool)
# wait until the cloned volume has been filled
while True:
if self._wait_volume_filled(dest_name, dest_pool, 10, 5):
break
self._wait_volume_filled(dest_name, dest_pool)
# unlock the original snapshot
self._snapshot_lock_op('unlock', src_vol_name, snap_name, src_pool)
@ -770,21 +768,18 @@ class AS13000Driver(san.SanISCSIDriver):
params=params,
request_type=request_type)
@utils.trace
def _wait_volume_filled(self, name, pool, attempts, interval):
@utils.retry(exception.VolumeDriverException, interval=5, retries=36)
def _wait_volume_filled(self, name, pool):
"""Wait until the volume is filled."""
try_num = 0
while try_num < attempts:
volumes = self._get_volumes(pool)
for vol in volumes:
if name == vol['name']:
if vol['lvmType'] == 1:
return True
else:
break
eventlet.sleep(interval)
try_num += 1
return False
volumes = self._get_volumes(pool)
for vol in volumes:
if name == vol['name']:
if vol['lvmType'] == 1:
return
else:
break
msg = (_('Volume %s is not filled.') % name)
raise exception.VolumeDriverException(msg)
@utils.trace
def _check_volume(self, volume):

View File

@ -41,10 +41,10 @@ storage cinder driver.
#. In the ``cinder.conf`` configuration file under the ``[DEFAULT]``
section, set the enabled_backends parameter.
.. code-block:: ini
.. code-block:: ini
[DEFAULT]
enabled_backends = AS13000-1
[DEFAULT]
enabled_backends = AS13000-1
#. Add a backend group section for backend group specified
@ -53,25 +53,25 @@ storage cinder driver.
#. In the newly created backend group section, set the
following configuration options:
.. code-block:: ini
.. code-block:: ini
[AS13000-1]
# The driver path
volume_driver = cinder.volume.drivers.inspur.as13000.as13000_driver.AS13000Driver
# Management IP of Inspur AS13000 storage array
san_ip = 10.0.0.10
# The Rest API port
san_api_port = 8088
# Management username of Inspur AS13000 storage array
san_login = root
# Management password of Inspur AS13000 storage array
san_password = passw0rd
# The Pool used to allocated volumes
as13000_ipsan_pools = Pool0
# The Meta Pool to use, should be a replication Pool
as13000_meta_pool = Pool_Rep
# Backend name
volume_backend_name = AS13000
[AS13000-1]
# The driver path
volume_driver = cinder.volume.drivers.inspur.as13000.as13000_driver.AS13000Driver
# Management IP of Inspur AS13000 storage array
san_ip = 10.0.0.10
# The Rest API port
san_api_port = 8088
# Management username of Inspur AS13000 storage array
san_login = root
# Management password of Inspur AS13000 storage array
san_password = passw0rd
# The Pool used to allocated volumes
as13000_ipsan_pools = Pool0
# The Meta Pool to use, should be a replication Pool
as13000_meta_pool = Pool_Rep
# Backend name
volume_backend_name = AS13000
#. Save the changes to the ``/etc/cinder/cinder.conf`` file and