move 3par exception

This patch moves the 3par driver exception to the hpe_3par_common file.

Change-Id: I5c7aeb6cc663d7157d7bb14442fc4f8df5e60754
This commit is contained in:
Walter A. Boring IV 2019-05-09 19:10:39 +00:00
parent 22e09a4bf3
commit 73adbf564c
3 changed files with 10 additions and 11 deletions

View File

@ -972,11 +972,6 @@ class RBDDriverException(VolumeDriverException):
message = _("RBD Cinder driver failure: %(reason)s")
# HP 3Par
class Invalid3PARDomain(VolumeDriverException):
message = _("Invalid 3PAR Domain: %(err)s")
# RemoteFS drivers
class RemoteFSException(VolumeDriverException):
message = _("Unknown RemoteFS exception")

View File

@ -1748,7 +1748,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
self.assertRaises(exception.Invalid3PARDomain,
self.assertRaises(hpecommon.Invalid3PARDomain,
self.driver.retype,
self.ctxt,
self.RETYPE_VOLUME_INFO_0,
@ -1784,7 +1784,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
mock_create_client.return_value = mock_client
self.assertRaises(exception.Invalid3PARDomain,
self.assertRaises(hpecommon.Invalid3PARDomain,
self.driver.retype,
self.ctxt,
self.RETYPE_VOLUME_INFO_0,
@ -4519,7 +4519,7 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
existing_ref = {'source-name': unm_matcher}
self.assertRaises(exception.Invalid3PARDomain,
self.assertRaises(hpecommon.Invalid3PARDomain,
self.driver.manage_existing,
volume=volume,
existing_ref=existing_ref)

View File

@ -138,6 +138,10 @@ QUEUE_LENGTH = 'queue_length'
AVG_BUSY_PERC = 'avg_busy_perc'
class Invalid3PARDomain(exception.VolumeDriverException):
message = _("Invalid 3PAR Domain: %(err)s")
class HPE3PARCommon(object):
"""Class that contains common code for the 3PAR drivers.
@ -1414,7 +1418,7 @@ class HPE3PARCommon(object):
except hpeexceptions.HTTPBadRequest as e:
if 'must be in the same domain' in e.get_description():
LOG.error(e.get_description())
raise exception.Invalid3PARDomain(err=e.get_description())
raise Invalid3PARDomain(err=e.get_description())
else:
raise exception.VolumeBackendAPIException(
data=e.get_description())
@ -3206,11 +3210,11 @@ class HPE3PARCommon(object):
domain = self.get_domain(old_cpg)
if domain != self.get_domain(new_cpg):
reason = (_('Cannot retype to a CPG in a different domain.'))
raise exception.Invalid3PARDomain(reason)
raise Invalid3PARDomain(reason)
if domain != self.get_domain(new_snap_cpg):
reason = (_('Cannot retype to a snap CPG in a different domain.'))
raise exception.Invalid3PARDomain(reason)
raise Invalid3PARDomain(reason)
def _retype(self, volume, volume_name, new_type_name, new_type_id, host,
new_persona, old_cpg, new_cpg, old_snap_cpg, new_snap_cpg,