move datera exception
This patch moves the datera exception to datera_common Change-Id: I4c6bee3d41e3d83c4d05d079e6d0f649587ecd98
This commit is contained in:
parent
779979789c
commit
12225b6c0a
@ -1156,11 +1156,6 @@ class InvalidGroupSnapshotStatus(Invalid):
|
||||
message = _("Invalid GroupSnapshot Status: %(reason)s")
|
||||
|
||||
|
||||
# Datera driver
|
||||
class DateraAPIException(VolumeBackendAPIException):
|
||||
message = _("Bad response from Datera API")
|
||||
|
||||
|
||||
# Target drivers
|
||||
class ISCSITargetCreateFailed(CinderException):
|
||||
message = _("Failed to create iscsi target for volume %(volume_id)s.")
|
||||
|
@ -80,8 +80,8 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.create_volume(self.volume))
|
||||
|
||||
def test_volume_create_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.create_volume, self.volume)
|
||||
|
||||
def test_volume_create_delay(self):
|
||||
@ -157,12 +157,12 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
cloned_volume, cloned_volume['size'])
|
||||
|
||||
def test_create_cloned_volume_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
source_volume = _stub_volume(
|
||||
id='7f91abfa-7964-41ed-88fc-207c3a290b4f',
|
||||
display_name='foo'
|
||||
)
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.create_cloned_volume, self.volume,
|
||||
source_volume)
|
||||
|
||||
@ -214,8 +214,8 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.delete_volume(self.volume))
|
||||
|
||||
def test_delete_volume_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.delete_volume, self.volume)
|
||||
|
||||
def test_ensure_export_success(self):
|
||||
@ -226,9 +226,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
None))
|
||||
|
||||
def test_ensure_export_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.ensure_export, ctxt, self.volume, None)
|
||||
|
||||
def test_create_export_target_does_not_exist_success(self):
|
||||
@ -240,9 +240,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
None))
|
||||
|
||||
def test_create_export_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.create_export,
|
||||
ctxt,
|
||||
self.volume,
|
||||
@ -267,9 +267,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
connector))
|
||||
|
||||
def test_initialize_connection_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
connector = {}
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.initialize_connection,
|
||||
self.volume,
|
||||
connector)
|
||||
@ -303,10 +303,10 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.detach_volume(ctxt, volume))
|
||||
|
||||
def test_detach_volume_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
ctxt = context.get_admin_context()
|
||||
volume = _stub_volume(status='in-use')
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.detach_volume, ctxt, volume)
|
||||
|
||||
def test_detach_volume_not_found(self):
|
||||
@ -334,9 +334,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.create_snapshot(snapshot))
|
||||
|
||||
def test_create_snapshot_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
snapshot = _stub_snapshot(volume_id=self.volume['id'])
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.create_snapshot, snapshot)
|
||||
|
||||
def test_delete_snapshot_success(self):
|
||||
@ -361,9 +361,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.delete_snapshot(snapshot))
|
||||
|
||||
def test_delete_snapshot_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
snapshot = _stub_snapshot(volume_id=self.volume['id'])
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.delete_snapshot, snapshot)
|
||||
|
||||
def test_create_volume_from_snapshot_success(self):
|
||||
@ -409,9 +409,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
extend_volume['size'])
|
||||
|
||||
def test_create_volume_from_snapshot_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
snapshot = _stub_snapshot(volume_id=self.volume['id'])
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.create_volume_from_snapshot, self.volume,
|
||||
snapshot)
|
||||
|
||||
@ -431,9 +431,9 @@ class DateraVolumeTestCasev2(test.TestCase):
|
||||
self.assertIsNone(self.driver.extend_volume(volume, 2))
|
||||
|
||||
def test_extend_volume_fails(self):
|
||||
self.mock_api.side_effect = exception.DateraAPIException
|
||||
self.mock_api.side_effect = datc.DateraAPIException
|
||||
volume = _stub_volume(size=1)
|
||||
self.assertRaises(exception.DateraAPIException,
|
||||
self.assertRaises(datc.DateraAPIException,
|
||||
self.driver.extend_volume, volume, 2)
|
||||
|
||||
def test_login_successful(self):
|
||||
|
@ -81,6 +81,10 @@ M_MANAGED = 'cinder_managed'
|
||||
M_KEYS = [M_TYPE, M_CALL, M_CLONE, M_MANAGED]
|
||||
|
||||
|
||||
class DateraAPIException(exception.VolumeBackendAPIException):
|
||||
message = _("Bad response from Datera API")
|
||||
|
||||
|
||||
def _get_name(name):
|
||||
return "".join((OS_PREFIX, name))
|
||||
|
||||
@ -157,7 +161,7 @@ def _api_lookup(func):
|
||||
msg = _("No compatible API version found for this product: "
|
||||
"api_versions -> %(api_version)s, %(func)s")
|
||||
LOG.error(msg, api_version=api_version, func=func)
|
||||
raise exception.DateraAPIException(msg % {
|
||||
raise DateraAPIException(msg % {
|
||||
'api_version': api_version, 'func': func})
|
||||
# Py27
|
||||
try:
|
||||
@ -190,7 +194,7 @@ def _api_lookup(func):
|
||||
else:
|
||||
LOG.info(e)
|
||||
index -= 1
|
||||
except exception.DateraAPIException as e:
|
||||
except DateraAPIException as e:
|
||||
if "UnsupportedVersionError" in six.text_type(e):
|
||||
index -= 1
|
||||
else:
|
||||
@ -221,7 +225,7 @@ def _get_supported_api_versions(driver):
|
||||
resp = driver._request(url, "get", None, header, cert_data)
|
||||
data = resp.json()
|
||||
results = [elem.strip("v") for elem in data['api_versions']]
|
||||
except (exception.DateraAPIException, KeyError):
|
||||
except (DateraAPIException, KeyError):
|
||||
# Fallback to pre-endpoint logic
|
||||
for version in API_VERSIONS[0:-1]:
|
||||
url = '%s://%s:%s/v%s' % (protocol, host, port, version)
|
||||
@ -311,7 +315,7 @@ def _request(driver, connection_string, method, payload, header, cert_data):
|
||||
'to the following reason: %s') % six.text_type(
|
||||
ex.message)
|
||||
LOG.error(msg)
|
||||
raise exception.DateraAPIException(msg)
|
||||
raise DateraAPIException(msg)
|
||||
|
||||
|
||||
def _raise_response(driver, response):
|
||||
@ -320,7 +324,7 @@ def _raise_response(driver, response):
|
||||
'status': response.status_code,
|
||||
'reason': response.reason}
|
||||
LOG.error(msg)
|
||||
raise exception.DateraAPIException(msg)
|
||||
raise DateraAPIException(msg)
|
||||
|
||||
|
||||
def _handle_bad_status(driver,
|
||||
@ -337,7 +341,7 @@ def _handle_bad_status(driver,
|
||||
# Raise the exception, but don't log any error. We'll just fall
|
||||
# back to the old style of determining API version. We make this
|
||||
# request a lot, so logging it is just noise
|
||||
raise exception.DateraAPIException
|
||||
raise DateraAPIException
|
||||
if response.status_code == http_client.NOT_FOUND:
|
||||
raise exception.NotFound(response.json()['message'])
|
||||
elif response.status_code in [http_client.FORBIDDEN,
|
||||
|
Loading…
Reference in New Issue
Block a user