Merge "3PAR: Remove metadata that tracks the instance id"

This commit is contained in:
Jenkins 2016-04-22 21:47:49 +00:00 committed by Gerrit Code Review
commit 23ba93fa52
4 changed files with 6 additions and 193 deletions

View File

@ -2218,53 +2218,6 @@ class HPE3PARBaseDriver(object):
'provider_location': provider_location}
self.assertEqual(expected_update, actual_update)
def test_attach_volume(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
self.driver.attach_volume(context.get_admin_context(),
self.volume,
'abcdef',
'newhost',
'/dev/vdb')
expected = [
mock.call.setVolumeMetaData(
self.VOLUME_3PAR_NAME,
'HPQ-CS-instance_uuid',
'abcdef')]
mock_client.assert_has_calls(expected)
# test the exception
mock_client.setVolumeMetaData.side_effect = Exception('Custom ex')
self.assertRaises(exception.CinderException,
self.driver.attach_volume,
context.get_admin_context(),
self.volume,
'abcdef',
'newhost',
'/dev/vdb')
def test_detach_volume(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
self.driver.detach_volume(context.get_admin_context(), self.volume,
None)
expected = [
mock.call.removeVolumeMetaData(
self.VOLUME_3PAR_NAME,
'HPQ-CS-instance_uuid')]
mock_client.assert_has_calls(expected)
def test_create_snapshot(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
@ -2614,53 +2567,6 @@ class HPE3PARBaseDriver(object):
expected +
self.standard_logout)
def test_update_volume_key_value_pair(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
key = 'a'
value = 'b'
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
common = self.driver._login()
common.update_volume_key_value_pair(
self.volume,
key,
value)
expected = [
mock.call.setVolumeMetaData(self.VOLUME_3PAR_NAME, key, value)]
mock_client.assert_has_calls(expected)
# check exception
mock_client.setVolumeMetaData.side_effect = Exception('fake')
self.assertRaises(exception.VolumeBackendAPIException,
common.update_volume_key_value_pair,
self.volume,
None,
'b')
def test_clear_volume_key_value_pair(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
key = 'a'
common = self.driver._login()
common.clear_volume_key_value_pair(self.volume, key)
expected = [
mock.call.removeVolumeMetaData(self.VOLUME_3PAR_NAME, key)]
mock_client.assert_has_calls(expected)
def test_extend_volume(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client

View File

@ -234,10 +234,11 @@ class HPE3PARCommon(object):
3.0.16 - Use same LUN ID for each VLUN path #1551994
3.0.17 - Don't fail on clearing 3PAR object volume key. bug #1546392
3.0.18 - create_cloned_volume account for larger size. bug #1554740
3.0.19 - Remove metadata that tracks the instance ID. bug #1572665
"""
VERSION = "3.0.18"
VERSION = "3.0.19"
stats = {}
@ -2283,72 +2284,6 @@ class HPE3PARCommon(object):
LOG.error(_LE("Exception: %s"), ex)
raise exception.NotFound()
def update_volume_key_value_pair(self, volume, key, value):
"""Updates key,value pair as metadata onto virtual volume.
If key already exists, the value will be replaced.
"""
LOG.debug("VOLUME (%(disp_name)s : %(vol_name)s %(id)s) "
"Updating KEY-VALUE pair: (%(key)s : %(val)s)",
{'disp_name': volume['display_name'],
'vol_name': volume['name'],
'id': self._get_3par_vol_name(volume['id']),
'key': key,
'val': value})
try:
volume_name = self._get_3par_vol_name(volume['id'])
if value is None:
value = ''
self.client.setVolumeMetaData(volume_name, key, value)
except Exception as ex:
msg = _('Failure in update_volume_key_value_pair:%s') % ex
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
def clear_volume_key_value_pair(self, volume, key):
"""Clears key,value pairs metadata from virtual volume."""
LOG.debug("VOLUME (%(disp_name)s : %(vol_name)s %(id)s) "
"Clearing Key : %(key)s)",
{'disp_name': volume['display_name'],
'vol_name': volume['name'],
'id': self._get_3par_vol_name(volume['id']),
'key': key})
try:
volume_name = self._get_3par_vol_name(volume['id'])
self.client.removeVolumeMetaData(volume_name, key)
except Exception as ex:
LOG.warning(_LW('Issue occurred in clear_volume_key_value_pair: '
'%s'), six.text_type(ex))
def attach_volume(self, volume, instance_uuid):
"""Save the instance UUID in the volume.
TODO: add support for multi-attach
"""
LOG.debug("Attach Volume\n%s", pprint.pformat(volume))
try:
self.update_volume_key_value_pair(volume,
'HPQ-CS-instance_uuid',
instance_uuid)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error attaching volume %s"), volume)
def detach_volume(self, volume, attachment=None):
"""Remove the instance uuid from the volume.
TODO: add support for multi-attach.
"""
LOG.debug("Detach Volume\n%s", pprint.pformat(volume))
try:
self.clear_volume_key_value_pair(volume, 'HPQ-CS-instance_uuid')
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error detaching volume %s"), volume)
def migrate_volume(self, volume, host):
"""Migrate directly if source and dest are managed by same storage.

View File

@ -100,10 +100,11 @@ class HPE3PARFCDriver(driver.TransferVD,
3.0.4 - Adding manage/unmanage snapshot support
3.0.5 - Optimize array ID retrieval
3.0.6 - Update replication to version 2.1
3.0.7 - Remove metadata that tracks the instance ID. bug #1572665
"""
VERSION = "3.0.6"
VERSION = "3.0.7"
def __init__(self, *args, **kwargs):
super(HPE3PARFCDriver, self).__init__(*args, **kwargs)
@ -556,21 +557,6 @@ class HPE3PARFCDriver(driver.TransferVD,
finally:
self._logout(common)
def attach_volume(self, context, volume, instance_uuid, host_name,
mountpoint):
common = self._login()
try:
common.attach_volume(volume, instance_uuid)
finally:
self._logout(common)
def detach_volume(self, context, volume, attachment=None):
common = self._login()
try:
common.detach_volume(volume, attachment)
finally:
self._logout(common)
def retype(self, context, volume, new_type, diff, host):
"""Convert the volume to be of the new type."""
common = self._login()

View File

@ -113,10 +113,11 @@ class HPE3PARISCSIDriver(driver.TransferVD,
3.0.7 - Optimize array ID retrieval
3.0.8 - Update replication to version 2.1
3.0.9 - Use same LUN ID for each VLUN path #1551994
3.0.10 - Remove metadata that tracks the instance ID. bug #1572665
"""
VERSION = "3.0.9"
VERSION = "3.0.10"
def __init__(self, *args, **kwargs):
super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs)
@ -876,21 +877,6 @@ class HPE3PARISCSIDriver(driver.TransferVD,
finally:
self._logout(common)
def attach_volume(self, context, volume, instance_uuid, host_name,
mountpoint):
common = self._login()
try:
common.attach_volume(volume, instance_uuid)
finally:
self._logout(common)
def detach_volume(self, context, volume, attachment=None):
common = self._login()
try:
common.detach_volume(volume, attachment)
finally:
self._logout(common)
def retype(self, context, volume, new_type, diff, host):
"""Convert the volume to be of the new type."""
common = self._login()