NetApp SolidFire: Refactor DuplicateSfVolumeNames exception

This patch refactors the DuplicateSfvolumeNames exception to
address the following issues:

- Inherits from exception.Duplicate which inherits from
CinderException directly rather than from VolumeDriverException
- Naming pattern differs from the other SolidFire exceptions
- Exception message differs in parts of the code.

Change-Id: I29bd3b74e8864f7ae02904a5402db2afe2dbd94b
This commit is contained in:
Fernando Ferraz 2020-12-30 01:41:40 +00:00
parent 662bb58517
commit 5e2d30bd43
1 changed files with 7 additions and 9 deletions

View File

@ -132,10 +132,6 @@ xVolumeAccessGroupIDDoesNotExist = 'xVolumeAccessGroupIDDoesNotExist'
xNotInVolumeAccessGroup = 'xNotInVolumeAccessGroup'
class DuplicateSfVolumeNames(exception.Duplicate):
message = _("Detected more than one volume with name %(vol_name)s")
class SolidFireAPIException(exception.VolumeBackendAPIException):
message = _("Bad response from SolidFire API")
@ -170,6 +166,11 @@ class SolidFireDataSyncTimeoutError(exception.VolumeBackendAPIException):
message = _("Data sync volumes timed out")
class SolidFireDuplicateVolumeNames(SolidFireDriverException):
message = _("Volume name [%(vol_name)s] already exists "
"in the SolidFire backend.")
def retry(exc_tuple, tries=5, delay=1, backoff=2):
def retry_dec(f):
@six.wraps(f)
@ -1049,10 +1050,7 @@ class SolidFireDriver(san.SanISCSIDriver):
sf_volume_name = params['name']
volumes_found = self._list_volumes_by_name(sf_volume_name)
if volumes_found:
msg = ('Volume name [%s] already exists '
'in SolidFire backend.') % sf_volume_name
LOG.error(msg)
raise DuplicateSfVolumeNames(message=msg)
raise SolidFireDuplicateVolumeNames(vol_name=sf_volume_name)
sf_volid = None
try:
@ -1222,7 +1220,7 @@ class SolidFireDriver(san.SanISCSIDriver):
LOG.error("Found %(count)s volumes mapped to id: %(uuid)s.",
{'count': found_count,
'uuid': uuid})
raise DuplicateSfVolumeNames(vol_name=uuid)
raise SolidFireDuplicateVolumeNames(vol_name=uuid)
return sf_volref