3PAR: Added volume to vvset in online copy

During online copy, newly created cloned volume
is not a part of vvset in which source volume is present.

With this patch, cloned volume created
from source volume will be added to vvset.

Change-Id: I6a213efc69e0ff1171780b4d56cd8d2dedbd61d7
Closes-Bug: #1664464
This commit is contained in:
Vivek Soni 2017-05-08 22:56:01 -07:00
parent 9da1945871
commit 33b3ece265
2 changed files with 85 additions and 2 deletions

View File

@ -2253,6 +2253,66 @@ class HPE3PARBaseDriver(object):
expected +
self.standard_logout)
@mock.patch.object(volume_types, 'get_volume_type')
def test_clone_volume_with_vvs(self, _mock_volume_types):
# Setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
_mock_volume_types.return_value = {
'name': 'gold',
'id': 'gold-id',
'extra_specs': {'vvs': self.VVS_NAME}}
mock_client = self.setup_driver()
mock_client.getVolume.return_value = {'name': mock.ANY}
mock_client.copyVolume.return_value = {'taskid': 1}
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
common = self.driver._login()
volume_vvs = {'id': self.CLONE_ID,
'name': self.VOLUME_NAME,
'display_name': 'Foo Volume',
'size': 2,
'host': self.FAKE_CINDER_HOST,
'volume_type': 'gold',
'volume_type_id': 'gold-id'}
src_vref = {'id': self.VOLUME_ID,
'name': self.VOLUME_NAME,
'size': 2, 'status': 'available',
'volume_type': 'gold',
'host': self.FAKE_CINDER_HOST,
'volume_type_id': 'gold-id'}
model_update = self.driver.create_cloned_volume(volume_vvs,
src_vref)
self.assertIsNone(model_update)
clone_vol_vvs = common.get_volume_settings_from_type(volume_vvs)
source_vol_vvs = common.get_volume_settings_from_type(src_vref)
self.assertEqual(clone_vol_vvs, source_vol_vvs)
expected = [
mock.call.copyVolume(
self.VOLUME_NAME_3PAR,
'osv-0DM4qZEVSKON-AAAAAAAAA',
'OpenStackCPG',
{'snapCPG': 'OpenStackCPGSnap', 'tpvv': True,
'tdvv': False, 'online': True}),
mock.call.addVolumeToVolumeSet(
self.VVS_NAME,
'osv-0DM4qZEVSKON-AAAAAAAAA')]
mock_client.assert_has_calls(
self.standard_login +
expected +
self.standard_logout)
def test_backup_iscsi_volume_with_chap_disabled(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
@ -2465,7 +2525,10 @@ class HPE3PARBaseDriver(object):
self.VOLUME_3PAR_NAME,
expected_cpg,
{'snapCPG': 'OpenStackCPGSnap', 'tpvv': True,
'tdvv': False, 'online': True})]
'tdvv': False, 'online': True}),
mock.call.addVolumeToVolumeSet(
'yourvvs',
'osv-0DM4qZEVSKON-DXN-NwVpw')]
mock_client.assert_has_calls(
self.standard_login +

View File

@ -257,10 +257,11 @@ class HPE3PARCommon(object):
3.0.32 - Add consistency group capability to generic volume group
in HPE-3APR
3.0.33 - Added replication feature in retype flow. bug #1680313
3.0.34 - Add cloned volume to vvset in online copy. bug #1664464
"""
VERSION = "3.0.33"
VERSION = "3.0.34"
stats = {}
@ -2133,6 +2134,10 @@ class HPE3PARCommon(object):
type_info = self.get_volume_settings_from_type(volume)
cpg = type_info['cpg']
qos = type_info['qos']
vvs_name = type_info['vvs_name']
flash_cache = self.get_flash_cache_policy(
type_info['hpe3par_keys'])
compression_val = self.get_compression_policy(
type_info['hpe3par_keys'])
@ -2144,6 +2149,21 @@ class HPE3PARCommon(object):
tdvv=type_info['tdvv'],
compression=compression_val)
if qos or vvs_name or flash_cache is not None:
try:
self._add_volume_to_volume_set(
volume, vol_name, cpg, vvs_name, qos, flash_cache)
except exception.InvalidInput as ex:
# Delete volume if unable to add it to the volume set
self.client.deleteVolume(vol_name)
dbg = {'volume': vol_name,
'vvs_name': vvs_name,
'err': six.text_type(ex)}
msg = _("Failed to add volume '%(volume)s' to vvset "
"'%(vvs_name)s' because '%(err)s'") % dbg
LOG.error(msg)
raise exception.CinderException(msg)
# v2 replication check
replication_flag = False
if self._volume_of_replicated_type(volume) and (