Browse Source

NEC driver: Never use target info in migration_status

NEC driver uses target info in migration_status at volume creation.
The target info will be deleted from migration_status in future
cinder version. This patch change the driver not to use target info
in migration_status.

Change-Id: I04b188d1300979b3b4b070781c6c2105f638b649
Partial-Bug: #1706729
changes/37/511737/3
Shunei Shiono 4 years ago
parent
commit
a638f483fb
2 changed files with 75 additions and 124 deletions
  1. +24
    -41
      cinder/tests/unit/volume/drivers/nec/test_volume.py
  2. +51
    -83
      cinder/volume/drivers/nec/volume_helper.py

+ 24
- 41
cinder/tests/unit/volume/drivers/nec/test_volume.py View File

@ -446,40 +446,6 @@ class VolumeIDConvertTest(volume_helper.MStorageDSVDriver, unittest.TestCase):
"ID:%(volid)s should be change to %(ldname)s" %
{'volid': volid, 'ldname': ldname})
@ddt.data(("AAAAAAAA", "LX:3R9ZwR", "target:BBBBBBBB"))
@ddt.unpack
def test_migrate_volumeid_should_change_62scale_andpostfix(self,
volid,
ldname,
status):
self.vol.id = volid
self.vol.migration_status = status
actual = self._convert_id2name_in_migrate(self.vol)
self.assertEqual(ldname, actual,
"ID:%(volid)s/%(status)s should be "
"change to %(ldname)s" %
{'volid': volid,
'status': status,
'ldname': ldname})
@ddt.data(("AAAAAAAA", "LX:37mA82", "deleting:BBBBBBBB"),
("AAAAAAAA", "LX:37mA82", ""),
("AAAAAAAA", "LX:37mA82", "success"))
@ddt.unpack
def test_NOTmigrate_volumeid_should_change_62scale(self,
volid,
ldname,
status):
self.vol.id = volid
self.vol.migration_status = status
actual = self._convert_id2name_in_migrate(self.vol)
self.assertEqual(ldname, actual,
"ID:%(volid)s/%(status)s should be "
"change to %(ldname)s" %
{'volid': volid,
'status': status,
'ldname': ldname})
class NominatePoolLDTest(volume_helper.MStorageDSVDriver, unittest.TestCase):
@ -735,7 +701,7 @@ class BindLDTest(volume_helper.MStorageDSVDriver, unittest.TestCase):
self.create_volume(self.vol)
self._bind_ld.assert_called_once_with(
self.vol, self.vol.size, None,
self._convert_id2name_in_migrate,
self._convert_id2name,
self._select_leastused_poolnumber)
@mock.patch('cinder.volume.drivers.nec.cli.MStorageISMCLI._execute',
@ -893,12 +859,6 @@ class ExportTest(volume_helper.MStorageDSVDriver, unittest.TestCase):
self._cli.delldsetld.return_value = False, 'iSM31064'
self.remove_export(context, self.vol)
self.vol.status = None
migstat = 'target:1febb976-86d0-42ed-9bc0-4aa3e158f27d'
self.vol.migration_status = migstat
ret = self.remove_export(context, self.vol)
self.assertIsNone(ret)
def test_iscsi_initialize_connection(self):
self.vol.id = "46045673-41e7-44a7-9333-02f07feab04b"
loc = "127.0.0.1:3260:1 iqn.2010-10.org.openstack:volume-00000001 88"
@ -1155,3 +1115,26 @@ class VolumeStats_test(volume_helper.MStorageDSVDriver, unittest.TestCase):
self.assertEqual(self.VERSION, stats.get('driver_version'))
self.assertEqual('10.0.0.1', stats.get('location_info').split(':')[0])
self.assertEqual('0,1', stats.get('location_info').split(':')[1])
class Migrate_test(volume_helper.MStorageDSVDriver, unittest.TestCase):
@mock.patch('cinder.volume.drivers.nec.volume_common.MStorageVolumeCommon.'
'_create_ismview_dir', new=mock.Mock())
def setUp(self):
self._set_config(conf.Configuration(None), 'dummy', 'dummy')
self.do_setup(None)
self.newvol = DummyVolume()
self.newvol.id = "46045673-41e7-44a7-9333-02f07feab04b"
self.sourcevol = DummyVolume()
self.sourcevol.id = "1febb976-86d0-42ed-9bc0-4aa3e158f27d"
@mock.patch('cinder.volume.drivers.nec.cli.MStorageISMCLI.'
'view_all', patch_view_all)
@mock.patch('cinder.volume.drivers.nec.cli.MStorageISMCLI._execute',
patch_execute)
def test_update_migrate_volume(self):
update_data = self.update_migrated_volume(None, self.sourcevol,
self.newvol, 'available')
self.assertIsNone(update_data['_name_id'])
self.assertIsNone(update_data['provider_location'])

+ 51
- 83
cinder/volume/drivers/nec/volume_helper.py View File

@ -49,23 +49,6 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
ldname = ldname + '_m'
return ldname
def _convert_id2name_in_migrate(self, volume):
"""If LD has migrate_status, get LD name from source LD UUID."""
LOG.debug('migration_status:%s', volume.migration_status)
migstat = volume.migration_status
if migstat is not None and 'target:' in migstat:
index = migstat.find('target:')
if index != -1:
migstat = migstat[len('target:'):]
ldname = (self.get_ldname(migstat,
self._properties['ld_name_format']))
else:
ldname = (self.get_ldname(volume.id,
self._properties['ld_name_format']))
LOG.debug('ldname=%s.', ldname)
return ldname
def _select_ldnumber(self, used_ldns, max_ld_count):
"""Pick up unused LDN."""
for ldn in range(0, max_ld_count + 1):
@ -308,7 +291,7 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
selected_pool) = self._bind_ld(volume,
volume.size,
None,
self._convert_id2name_in_migrate,
self._convert_id2name,
self._select_leastused_poolnumber)
# check io limit.
@ -632,6 +615,48 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
return (True, [])
def update_migrated_volume(self, ctxt, volume, new_volume,
original_volume_status):
"""Updates metadata after host-assisted migration.
This method should rename the back-end volume name(id) on the
destination host back to its original name(id) on the source host.
:param ctxt: The context used to run the method update_migrated_volume
:param volume: The original volume that was migrated to this backend
:param new_volume: The migration volume object that was created on
this backend as part of the migration process
:param original_volume_status: The status of the original volume
:returns: model_update to update DB with any needed changes
"""
xml = self._cli.view_all(self._properties['ismview_path'])
pools, lds, ldsets, used_ldns, hostports, max_ld_count = (
self.configs(xml))
name_id = None
provider_location = None
if original_volume_status == 'available':
original_name = self._convert_id2name(volume)
temp_name = self._convert_id2name(new_volume)
try:
if original_name in lds:
self._cli.unbind(original_name)
self._cli.changeldname(None, original_name, temp_name)
except exception.CinderException as e:
LOG.warning('Unable to rename the logical volume '
'(Volume ID = %(id)s), (%(exception)s)',
{'id': volume.id, 'exception': e})
# If the rename fails, _name_id should be set to the new
# volume id and provider_location should be set to the
# one from the new volume as well.
name_id = new_volume._name_id or new_volume.id
provider_location = new_volume.provider_location
else:
# The back-end will not be renamed.
name_id = new_volume._name_id or new_volume.id
provider_location = new_volume.provider_location
return {'_name_id': name_id, 'provider_location': provider_location}
def check_for_export(self, context, volume_id):
pass
@ -684,21 +709,8 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
ldset = self._validate_iscsildset_exist(
ldsets, connector, metadata)
if (hasattr(volume, 'migration_status') and
volume.migration_status is not None and
'target:' in volume.migration_status):
LOG.debug('migration_status:%s', volume.migration_status)
migstat = volume.migration_status
index = migstat.find('target:')
if index != -1:
migstat = migstat[len('target:'):]
ldname = (
self.get_ldname(
migstat, self._properties['ld_name_format']))
else:
ldname = (
self.get_ldname(
volume.id, self._properties['ld_name_format']))
ldname = self.get_ldname(
volume.id, self._properties['ld_name_format'])
# add LD to LD set.
if ldname not in lds:
@ -802,23 +814,8 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
break
target_lun += 1
if (hasattr(volume, 'migration_status') and
volume.migration_status is not None and
'target:' in volume.migration_status):
LOG.debug('migration_status:%s', volume.migration_status)
migstat = volume.migration_status
index = migstat.find('target:')
if index != -1:
migstat = migstat[len('target:'):]
ldname = (
self.get_ldname(
migstat,
self._properties['ld_name_format']))
else:
ldname = (
self.get_ldname(
volume.id,
self._properties['ld_name_format']))
ldname = self.get_ldname(
volume.id, self._properties['ld_name_format'])
# add LD to LD set.
if ldname not in lds:
@ -1013,24 +1010,8 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
LOG.debug('migrate:%s', volume.migration_status)
ldset = self.get_ldset(ldsets, metadata)
if (hasattr(volume, 'migration_status') and
volume.migration_status is not None and
'target:' in volume.migration_status):
LOG.debug('migration_status:%s', volume.migration_status)
migstat = volume.migration_status
index = migstat.find('target:')
if index != -1:
migstat = migstat[len('target:'):]
ldname = (
self.get_ldname(
migstat,
self._properties['ld_name_format']))
else:
ldname = (
self.get_ldname(
volume.id,
self._properties['ld_name_format']))
ldname = self.get_ldname(
volume.id, self._properties['ld_name_format'])
if ldname not in lds:
LOG.debug('LD `%s` already unbound?', ldname)
@ -1303,21 +1284,8 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
target_wwns, init_targ_map = (
self._build_initiator_target_map(connector, fc_ports))
if (hasattr(volume, 'migration_status') and
volume.migration_status is not None and
'target:' in volume.migration_status):
LOG.debug('migration_status:%s', volume.migration_status)
migstat = volume.migration_status
index = migstat.find('target:')
if index != -1:
migstat = migstat[len('target:'):]
ldname = (
self.get_ldname(migstat,
self._properties['ld_name_format']))
else:
ldname = (
self.get_ldname(volume.id,
self._properties['ld_name_format']))
ldname = self.get_ldname(
volume.id, self._properties['ld_name_format'])
# get lun.
if ldname not in lds:


Loading…
Cancel
Save