HPE 3par: Add comment for cloned volumes

When volume is created via OpenStack ...
on 3par backend, some info (display_name, volume_type, etc)
is populated in Comment column.

However for cloned volume, this info is missing;
i.e comment column is empty.

For details, kindly refer launchpad bug.

This patch updates the code to add comment for cloned volumes.

Closes-Bug: #2062524
Change-Id: I52f102637642966cecb47db7d355bc5d0cb7ddfc
This commit is contained in:
raghavendrat
2024-04-19 09:23:19 +00:00
parent a1fb7da213
commit 46621c6397
3 changed files with 72 additions and 9 deletions

View File

@@ -691,6 +691,11 @@ class HPE3PARBaseDriver(test.TestCase):
'minor': 10,
'revision': 0}
wsapi_version_clone = {'major': 1,
'build': 40600052,
'minor': 10,
'revision': 0}
# Use this to point to latest version of wsapi
wsapi_version_latest = wsapi_version_for_compression
@@ -2666,13 +2671,19 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
self.standard_login +
expected)
@ddt.data('volume', 'volume_name_id')
def test_create_cloned_volume(self, volume_attr):
@ddt.data({'volume_attr': 'volume', 'wsapi_version': None},
{'volume_attr': 'volume_name_id', 'wsapi_version': None},
{'volume_attr': 'volume',
'wsapi_version': HPE3PARBaseDriver.wsapi_version_clone},
{'volume_attr': 'volume_name_id',
'wsapi_version': HPE3PARBaseDriver.wsapi_version_clone})
@ddt.unpack
def test_create_cloned_volume(self, volume_attr, wsapi_version):
src_vref = getattr(self, volume_attr)
vol_name = getattr(self, volume_attr.upper() + '_3PAR_NAME')
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
mock_client = self.setup_driver(wsapi_version=wsapi_version)
mock_client.getVolume.return_value = {'name': mock.ANY}
mock_client.copyVolume.return_value = {'taskid': 1}
mock_client.getStorageSystemInfo.return_value = {
@@ -2690,11 +2701,24 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
'host': volume_utils.append_host(self.FAKE_HOST,
HPE3PAR_CPG2),
'source_volid': src_vref.id}
model_update = self.driver.create_cloned_volume(volume, src_vref)
if not wsapi_version:
# (i) old/default
model_update = self.driver.create_cloned_volume(volume,
src_vref)
else:
# (ii) wsapi having support for comment in cloned volume
common = self.driver._login()
model_update = common.create_cloned_volume(volume, src_vref)
self.assertIsNone(model_update)
# snapshot name is random
snap_name = mock.ANY
optional = mock.ANY
optional_fields = {'snapCPG': 'OpenStackCPGSnap', 'tpvv': True,
'tdvv': False, 'online': True}
if wsapi_version:
optional_fields['comment'] = mock.ANY
expected = [
mock.call.createSnapshot(snap_name, vol_name, optional),
@@ -2703,8 +2727,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
snap_name,
'osv-0DM4qZEVSKON-AAAAAAAAA',
HPE3PAR_CPG2,
{'snapCPG': 'OpenStackCPGSnap', 'tpvv': True,
'tdvv': False, 'online': True})]
optional_fields)]
mock_client.assert_has_calls(expected)

View File

@@ -313,11 +313,12 @@ class HPE3PARCommon(object):
4.0.23 - Fixed login/logout while accessing wsapi. Bug #2068795
4.0.24 - Fixed retype volume - thin to deco. Bug #2080927
4.0.25 - Update the calculation of free_capacity
4.0.26 - Added comment for cloned volumes. Bug #2062524
"""
VERSION = "4.0.25"
VERSION = "4.0.26"
stats = {}
@@ -2506,7 +2507,7 @@ class HPE3PARCommon(object):
hpe_tiramisu=hpe_tiramisu)
def _copy_volume(self, src_name, dest_name, cpg, snap_cpg=None,
tpvv=True, tdvv=False, compression=None):
tpvv=True, tdvv=False, compression=None, comment=None):
# Virtual volume sets are not supported with the -online option
LOG.debug('Creating clone of a volume %(src)s to %(dest)s.',
{'src': src_name, 'dest': dest_name})
@@ -2522,6 +2523,9 @@ class HPE3PARCommon(object):
self.API_VERSION >= COMPRESSION_API_VERSION):
optional['compression'] = compression
if comment:
optional['comment'] = comment
body = self.client.copyVolume(src_name, dest_name, cpg, optional)
return body['taskid']
@@ -2646,13 +2650,42 @@ class HPE3PARCommon(object):
compression_val = self.get_compression_policy(
type_info['hpe3par_keys'])
LOG.info("array version: %(ver)s",
{'ver': self.API_VERSION})
comment_line = None
if self.API_VERSION >= 40600000:
# comment can be added
comments = {'volume_id': volume['id'],
'name': volume['name'],
'type': 'OpenStack'}
volume_type = type_info['volume_type']
type_id = volume.get('volume_type_id', None)
if type_id:
comments['volume_type_name'] = volume_type.get('name')
comments['volume_type_id'] = type_id
if vvs_name:
comments['vvs'] = vvs_name
else:
comments['qos'] = qos
display_name = volume.get('display_name', None)
if display_name:
comments['display_name'] = display_name
comment_line = json.dumps(comments)
LOG.debug("comment_line: %(comment)s",
{'comment': comment_line})
# make the 3PAR copy the contents.
# can't delete the original until the copy is done.
self._copy_volume(snapshot['name'], vol_name, cpg=cpg,
snap_cpg=type_info['snap_cpg'],
tpvv=type_info['tpvv'],
tdvv=type_info['tdvv'],
compression=compression_val)
compression=compression_val,
comment=comment_line)
if qos or vvs_name or flash_cache is not None:
try:

View File

@@ -0,0 +1,7 @@
---
fixes:
- |
HPE 3PAR driver `bug #2062524
<https://bugs.launchpad.net/cinder/+bug/2062524>`_:
Fixed: Added comment for cloned volumes.