[IBM DS8000] Support volume name template
Previous cinder driver use display name as volume name in the backend. Now DS8000 cinder driver will use name based on volume_name_template. Change-Id: If5df3c3b34936911a1053f86fba6fad2a922dec4 Closes-bug: #1884030
This commit is contained in:
parent
8ea6f80319
commit
a791d3032c
@ -4464,3 +4464,52 @@ class DS8KProxyTest(test.TestCase):
|
|||||||
pprc_pairs_3]
|
pprc_pairs_3]
|
||||||
self.driver.failover_replication(self.ctxt, group, [volume], 'default')
|
self.driver.failover_replication(self.ctxt, group, [volume], 'default')
|
||||||
self.assertTrue(mock_get_pprc_pairs.called)
|
self.assertTrue(mock_get_pprc_pairs.called)
|
||||||
|
|
||||||
|
@mock.patch('cinder.volume.volume_utils.CONF')
|
||||||
|
def test_create_volume_with_template(self, mock_conf):
|
||||||
|
self.driver = FakeDS8KProxy(self.storage_info, self.logger,
|
||||||
|
self.exception, self)
|
||||||
|
self.driver.setup(self.ctxt)
|
||||||
|
mock_conf.volume_name_template = 'volume-%s'
|
||||||
|
vol_id = 'd403b4d9-473a-42d0-94c5-be45a1268928'
|
||||||
|
vol_name = mock_conf.volume_name_template % vol_id
|
||||||
|
volume = self._create_volume(id=vol_id)
|
||||||
|
lun = ds8kproxy.Lun(volume)
|
||||||
|
exp_vol_name = helper.filter_alnum(vol_name)[:16]
|
||||||
|
self.assertEqual(lun.ds_name, exp_vol_name)
|
||||||
|
|
||||||
|
@mock.patch.object(eventlet, 'sleep')
|
||||||
|
@mock.patch.object(helper.DS8KCommonHelper, 'get_flashcopy')
|
||||||
|
def test_create_snapshot_with_tmpt(self, mock_get_flashcopy, mock_sleep):
|
||||||
|
"""test a successful creation of snapshot."""
|
||||||
|
self.driver = FakeDS8KProxy(self.storage_info, self.logger,
|
||||||
|
self.exception, self)
|
||||||
|
self.driver.setup(self.ctxt)
|
||||||
|
|
||||||
|
vol_type = volume_types.create(self.ctxt, 'VOL_TYPE', {})
|
||||||
|
location = six.text_type({'vol_hex_id': '0002'})
|
||||||
|
volume = self._create_volume(volume_type_id=vol_type.id,
|
||||||
|
provider_location=location)
|
||||||
|
snapshot = self._create_snapshot(volume_id=volume.id)
|
||||||
|
mock_get_flashcopy.side_effect = [[TEST_FLASHCOPY], {}]
|
||||||
|
snapshot_update = self.driver.create_snapshot(snapshot)
|
||||||
|
location = ast.literal_eval(snapshot_update['provider_location'])
|
||||||
|
self.assertEqual(TEST_VOLUME_ID, location['vol_hex_id'])
|
||||||
|
lun = ds8kproxy.Lun(snapshot, is_snapshot=True)
|
||||||
|
exp_snap_name = helper.filter_alnum(snapshot.name)[:16]
|
||||||
|
self.assertIn(lun.ds_name, exp_snap_name)
|
||||||
|
|
||||||
|
@mock.patch.object(eventlet, 'sleep')
|
||||||
|
def test_create_fb_replicated_volume_with_tmpt(self, mock_sleep):
|
||||||
|
"""create FB volume when enable replication."""
|
||||||
|
self.configuration.replication_device = [TEST_REPLICATION_DEVICE]
|
||||||
|
self.driver = FakeDS8KProxy(self.storage_info, self.logger,
|
||||||
|
self.exception, self)
|
||||||
|
self.driver.setup(self.ctxt)
|
||||||
|
|
||||||
|
extra_spec = {'replication_enabled': '<is> True'}
|
||||||
|
vol_type = volume_types.create(self.ctxt, 'VOL_TYPE', extra_spec)
|
||||||
|
volume = self._create_volume(volume_type_id=vol_type.id)
|
||||||
|
lun = ds8kproxy.Lun(volume)
|
||||||
|
exp_repl_name = helper.filter_alnum(volume.name)[:16]
|
||||||
|
self.assertEqual(lun.replica_ds_name, exp_repl_name)
|
||||||
|
@ -222,7 +222,7 @@ class Lun(object):
|
|||||||
self.ds_id = provider_location['vol_hex_id']
|
self.ds_id = provider_location['vol_hex_id']
|
||||||
else:
|
else:
|
||||||
self.ds_id = None
|
self.ds_id = None
|
||||||
self.cinder_name = volume.display_name
|
self.cinder_name = volume.name
|
||||||
self.pool_lss_pair = {}
|
self.pool_lss_pair = {}
|
||||||
self.is_snapshot = is_snapshot
|
self.is_snapshot = is_snapshot
|
||||||
if self.is_snapshot:
|
if self.is_snapshot:
|
||||||
@ -230,20 +230,14 @@ class Lun(object):
|
|||||||
if volume.group_snapshot else None)
|
if volume.group_snapshot else None)
|
||||||
self.size = volume.volume_size
|
self.size = volume.volume_size
|
||||||
# ds8k supports at most 16 chars
|
# ds8k supports at most 16 chars
|
||||||
self.ds_name = (
|
self.ds_name = helper.filter_alnum(self.cinder_name)[:16]
|
||||||
"OS%s:%s" % ('snap', helper.filter_alnum(self.cinder_name))
|
|
||||||
)[:16]
|
|
||||||
self.metadata = self._get_snapshot_metadata(volume)
|
self.metadata = self._get_snapshot_metadata(volume)
|
||||||
self.source_volid = volume.volume_id
|
self.source_volid = volume.volume_id
|
||||||
else:
|
else:
|
||||||
self.group = Group(volume.group) if volume.group else None
|
self.group = Group(volume.group) if volume.group else None
|
||||||
self.size = volume.size
|
self.size = volume.size
|
||||||
self.ds_name = (
|
self.ds_name = helper.filter_alnum(self.cinder_name)[:16]
|
||||||
"OS%s:%s" % ('vol', helper.filter_alnum(self.cinder_name))
|
self.replica_ds_name = helper.filter_alnum(self.cinder_name)[:16]
|
||||||
)[:16]
|
|
||||||
self.replica_ds_name = (
|
|
||||||
"OS%s:%s" % ('Replica', helper.filter_alnum(self.cinder_name))
|
|
||||||
)[:16]
|
|
||||||
self.previous_status = volume.previous_status
|
self.previous_status = volume.previous_status
|
||||||
self.replication_status = volume.replication_status
|
self.replication_status = volume.replication_status
|
||||||
self.replication_driver_data = (
|
self.replication_driver_data = (
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
IBM DS8000 Driver `Bug #1884030
|
||||||
|
<https://bugs.launchpad.net/cinder/+bug/1884030>`_:
|
||||||
|
Support for volume_name_template configuration option.
|
Loading…
Reference in New Issue
Block a user