From cd6643d79ae6aaa7c6d928650f97101213118f9c Mon Sep 17 00:00:00 2001 From: Simon Dodsley Date: Wed, 2 Oct 2019 11:59:49 -0400 Subject: [PATCH] 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 --- cinder/volume/drivers/pure.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 5eb4d3ce534..ea6a2d676a9 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -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: