diff options
Diffstat (limited to 'cinder/volume/drivers/hpe/hpe_3par_common.py')
-rw-r--r-- | cinder/volume/drivers/hpe/hpe_3par_common.py | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 971fac3e8..2d9534a16 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -81,6 +81,7 @@ FLASH_CACHE_API_VERSION = 30201200 COMPRESSION_API_VERSION = 30301215 SRSTATLD_API_VERSION = 30201200 REMOTE_COPY_API_VERSION = 30202290 +API_VERSION_2023 = 100000000 hpe3par_opts = [ cfg.StrOpt('hpe3par_api_url', @@ -300,11 +301,14 @@ class HPE3PARCommon(object): 4.0.16 - In multi host env, fix multi-detach operation. Bug #1958122 4.0.17 - Added get_manageable_volumes and get_manageable_snapshots. Bug #1819903 + 4.0.18 - During conversion of volume to base volume, + error out if it has child snapshot(s). Bug #1994521 + 4.0.19 - Update code to work with new WSAPI (of 2023). Bug #2015746 """ - VERSION = "4.0.17" + VERSION = "4.0.19" stats = {} @@ -704,9 +708,12 @@ class HPE3PARCommon(object): compression = self.get_compression_policy( type_info['hpe3par_keys']) - optional = {'online': True, 'snapCPG': snapcpg, + optional = {'online': True, 'tpvv': tpvv, 'tdvv': tdvv} + if self.API_VERSION < API_VERSION_2023: + optional['snapCPG'] = snapcpg + if compression is not None: optional['compression'] = compression @@ -1004,7 +1011,7 @@ class HPE3PARCommon(object): 'comment': json.dumps(new_comment)} # Ensure that snapCPG is set - if 'snapCPG' not in vol: + if 'snapCPG' not in vol and self.API_VERSION < API_VERSION_2023: new_vals['snapCPG'] = vol['userCPG'] LOG.info("Virtual volume %(disp)s '%(new)s' snapCPG " "is empty so it will be set to: %(cpg)s", @@ -2393,9 +2400,14 @@ class HPE3PARCommon(object): comments['qos'] = qos extras = {'comment': json.dumps(comments), - 'snapCPG': snap_cpg, 'tpvv': tpvv} + LOG.debug("self.API_VERSION: %(version)s", + {'version': self.API_VERSION}) + + if self.API_VERSION < API_VERSION_2023: + extras['snapCPG'] = snap_cpg + # Only set the dedup option if the backend supports it. if self.API_VERSION >= DEDUP_API_VERSION: extras['tdvv'] = tdvv @@ -2466,7 +2478,7 @@ class HPE3PARCommon(object): {'src': src_name, 'dest': dest_name}) optional = {'tpvv': tpvv, 'online': True} - if snap_cpg is not None: + if snap_cpg is not None and self.API_VERSION < API_VERSION_2023: optional['snapCPG'] = snap_cpg if self.API_VERSION >= DEDUP_API_VERSION: @@ -3139,6 +3151,21 @@ class HPE3PARCommon(object): compression = self.get_compression_policy( type_info['hpe3par_keys']) + + # If volume (osv-) has snapshot, while converting the volume + # to base volume (omv-), snapshot cannot be transferred to + # new base volume (omv-) i.e it remain with volume (osv-). + # So error out for such volume. + snap_list = self.client.getVolumeSnapshots(volume_name) + if snap_list: + snap_str = ",".join(snap_list) + msg = (_("Volume %(name)s has dependent snapshots: %(snap)s." + " Either flatten or remove the dependent snapshots:" + " %(snap)s for the conversion of volume %(name)s to" + " succeed." % {'name': volume_name, + 'snap': snap_str})) + raise exception.VolumeIsBusy(message=msg) + # Create a physical copy of the volume task_id = self._copy_volume(volume_name, temp_vol_name, cpg, cpg, type_info['tpvv'], @@ -3162,16 +3189,18 @@ class HPE3PARCommon(object): comment = self._get_3par_vol_comment(volume_name) if comment: self.client.modifyVolume(temp_vol_name, {'comment': comment}) - LOG.debug('Volume rename completed: convert_to_base_volume: ' - 'id=%s.', volume['id']) + LOG.debug('Assigned the comment: convert_to_base_volume: ' + 'id=%s.', volume['id']) - # Delete source volume after the copy is complete + # Delete source volume (osv-) after the copy is complete self.client.deleteVolume(volume_name) LOG.debug('Delete src volume completed: convert_to_base_volume: ' 'id=%s.', volume['id']) - # Rename the new volume to the original name + # Rename the new volume (omv-) to the original name (osv-) self.client.modifyVolume(temp_vol_name, {'newName': volume_name}) + LOG.debug('Volume rename completed: convert_to_base_volume: ' + 'id=%s.', volume['id']) LOG.info('Completed: convert_to_base_volume: ' 'id=%s.', volume['id']) @@ -4358,15 +4387,17 @@ class HPE3PARCommon(object): local_cpg) rcg_target = {'targetName': target['backend_id'], 'mode': replication_mode_num, - 'snapCPG': cpg, 'userCPG': cpg} + if self.API_VERSION < API_VERSION_2023: + rcg_target['snapCPG'] = cpg rcg_targets.append(rcg_target) sync_target = {'targetName': target['backend_id'], 'syncPeriod': replication_sync_period} sync_targets.append(sync_target) - optional = {'localSnapCPG': vol_settings['snap_cpg'], - 'localUserCPG': local_cpg} + optional = {'localUserCPG': local_cpg} + if self.API_VERSION < API_VERSION_2023: + optional['localSnapCPG'] = vol_settings['snap_cpg'] pool = volume_utils.extract_host(volume['host'], level='pool') domain = self.get_domain(pool) if domain: @@ -4381,6 +4412,8 @@ class HPE3PARCommon(object): LOG.error(msg) raise exception.VolumeBackendAPIException(data=msg) + LOG.debug("created rcg %(name)s", {'name': rcg_name}) + # Add volume to remote copy group. rcg_targets = [] for target in self._replication_targets: @@ -5300,7 +5333,11 @@ class ModifyVolumeTask(flow_utils.CinderTask): comment_dict = self._get_new_comment( old_comment, new_vvs, new_qos, new_type_name, new_type_id) - if new_snap_cpg != old_snap_cpg: + LOG.debug("API_VERSION: %(ver_1)s, API_VERSION_2023: %(ver_2)s", + {'ver_1': common.API_VERSION, + 'ver_2': API_VERSION_2023}) + if (new_snap_cpg != old_snap_cpg and + common.API_VERSION < API_VERSION_2023): # Modify the snap_cpg. This will fail with snapshots. LOG.info("Modifying %(volume_name)s snap_cpg from " "%(old_snap_cpg)s to %(new_snap_cpg)s.", |