Pure: Ensure generated volume name does not exceed 63 characters

Some OpenStack deployments create a volume.name, that when linked with
Pure's naming standard, the resulting volume name length exceeds the
63 character limit for Pure volumes.

This truncates the left (least unique) section of the volume name,
excluding the volume_name_template piece, to ensure the volume
name length never causes an error on creation.

Change-Id: I9398bb163089c9b6695299203a42423f39272581
(cherry picked from commit cd6643d79a)
This commit is contained in:
Simon Dodsley 2019-10-02 11:59:49 -04:00
parent 3028c3e1b3
commit 293910c8d8
1 changed files with 9 additions and 0 deletions

View File

@ -1547,6 +1547,15 @@ class PureBaseVolumeDriver(san.SanDriver):
"""
base_name = volume.name
# Some OpenStack deployments, eg PowerVC, create a volume.name that
# when appended with out '-cinder' string will exceed the maximum
# volume name length for Pure, so here we left truncate the true volume
# name before the opennstack volume_name_template affected it and
# then put back the template format
if len(base_name) > 56:
actual_name = base_name[7:]
base_name = "volume-" + actual_name[-52:]
repl_type = self._get_replication_type_from_vol_type(
volume.volume_type)
if repl_type == REPLICATION_TYPE_SYNC: