move dothill exceptions

This patch moves the dothill exceptions to the dothill module

Change-Id: I5658b377eb79c663037c595515125a16bd9f369c
This commit is contained in:
Walter A. Boring IV 2019-05-08 18:42:42 +00:00
parent 0101834659
commit ce7b86267c
7 changed files with 128 additions and 108 deletions

View File

@ -1100,35 +1100,6 @@ class BadResetResourceStatus(CinderException):
message = _("Bad reset resource status : %(reason)s")
# DOTHILL drivers
class DotHillInvalidBackend(VolumeDriverException):
message = _("Backend doesn't exist (%(backend)s)")
class DotHillConnectionError(VolumeDriverException):
message = "%(message)s"
class DotHillAuthenticationError(VolumeDriverException):
message = "%(message)s"
class DotHillNotEnoughSpace(VolumeDriverException):
message = _("Not enough space on backend (%(backend)s)")
class DotHillRequestError(VolumeDriverException):
message = "%(message)s"
class DotHillNotTargetPortal(VolumeDriverException):
message = _("No active iSCSI portals with supplied iSCSI IPs")
class DotHillDriverNotSupported(VolumeDriverException):
message = _("The Dot Hill driver is no longer supported.")
class MetadataAbsent(CinderException):
message = _("There is no metadata in DB object.")

View File

@ -27,6 +27,7 @@ from cinder.volume.drivers.dothill import dothill_client as dothill
from cinder.volume.drivers.dothill import dothill_common
from cinder.volume.drivers.dothill import dothill_fc
from cinder.volume.drivers.dothill import dothill_iscsi
from cinder.volume.drivers.dothill import exception as dh_exception
from cinder.zonemanager import utils as fczm_utils
session_key = '12a1626754554a21d85040760c81b'
@ -175,7 +176,7 @@ class TestDotHillClient(test.TestCase):
mock_requests_get.return_value = m
m.text.encode.side_effect = [resp_badlogin, resp_badlogin]
self.assertRaises(exception.DotHillAuthenticationError,
self.assertRaises(dh_exception.DotHillAuthenticationError,
self.client.login)
m.text.encode.side_effect = [resp_login, resp_fw, resp_system]
@ -208,10 +209,10 @@ class TestDotHillClient(test.TestCase):
mock_requests_get.return_value = m
ret = self.client._api_request('/path')
self.assertTrue(type(ret) == etree.RestrictedElement)
self.assertRaises(exception.DotHillConnectionError,
self.assertRaises(dh_exception.DotHillConnectionError,
self.client._api_request,
'/path')
self.assertRaises(exception.DotHillConnectionError,
self.assertRaises(dh_exception.DotHillConnectionError,
self.client._api_request,
'/path')
@ -221,15 +222,15 @@ class TestDotHillClient(test.TestCase):
invalid_tree = etree.XML(invalid_xml)
ret = self.client._assert_response_ok(ok_tree)
self.assertIsNone(ret)
self.assertRaises(exception.DotHillRequestError,
self.assertRaises(dh_exception.DotHillRequestError,
self.client._assert_response_ok,
not_ok_tree)
self.assertRaises(exception.DotHillRequestError,
self.assertRaises(dh_exception.DotHillRequestError,
self.client._assert_response_ok, invalid_tree)
@mock.patch.object(dothill.DotHillClient, '_request')
def test_backend_exists(self, mock_request):
mock_request.side_effect = [exception.DotHillRequestError,
mock_request.side_effect = [dh_exception.DotHillRequestError,
fake_xml]
self.assertFalse(self.client.backend_exists('backend_name',
'linear'))
@ -350,7 +351,7 @@ class TestFCDotHillCommon(test.TestCase):
mock_backend_exists.side_effect = [False, True]
mock_owner_info.return_value = "A"
mock_serial_number.return_value = "xxxxx"
self.assertRaises(exception.DotHillInvalidBackend,
self.assertRaises(dh_exception.DotHillInvalidBackend,
self.common.do_setup, None)
self.assertIsNone(self.common.do_setup(None))
mock_backend_exists.assert_called_with(self.common.backend_name,
@ -388,7 +389,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'backend_stats')
def test_update_volume_stats(self, mock_stats):
mock_stats.side_effect = [exception.DotHillRequestError,
mock_stats.side_effect = [dh_exception.DotHillRequestError,
stats_large_space]
self.assertRaises(exception.Invalid, self.common._update_volume_stats)
@ -411,7 +412,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'create_volume')
def test_create_volume(self, mock_create):
mock_create.side_effect = [exception.DotHillRequestError, None]
mock_create.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid, self.common.create_volume,
test_volume)
@ -424,9 +425,10 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'delete_volume')
def test_delete_volume(self, mock_delete):
not_found_e = exception.DotHillRequestError(
not_found_e = dh_exception.DotHillRequestError(
'The volume was not found on this system.')
mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
mock_delete.side_effect = [not_found_e,
dh_exception.DotHillRequestError,
None]
self.assertIsNone(self.common.delete_volume(test_volume))
self.assertRaises(exception.Invalid, self.common.delete_volume,
@ -440,12 +442,13 @@ class TestFCDotHillCommon(test.TestCase):
mock_stats.side_effect = [stats_low_space, stats_large_space,
stats_large_space]
self.assertRaises(exception.DotHillNotEnoughSpace,
self.common.create_cloned_volume,
dest_volume, detached_volume)
self.assertRaises(
dh_exception.DotHillNotEnoughSpace,
self.common.create_cloned_volume,
dest_volume, detached_volume)
self.assertFalse(mock_copy.called)
mock_copy.side_effect = [exception.DotHillRequestError, None]
mock_copy.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid,
self.common.create_cloned_volume,
dest_volume, detached_volume)
@ -466,12 +469,12 @@ class TestFCDotHillCommon(test.TestCase):
mock_stats.side_effect = [stats_low_space, stats_large_space,
stats_large_space]
self.assertRaises(exception.DotHillNotEnoughSpace,
self.assertRaises(dh_exception.DotHillNotEnoughSpace,
self.common.create_cloned_volume,
dest_volume_larger, detached_volume)
self.assertFalse(mock_copy.called)
mock_copy.side_effect = [exception.DotHillRequestError, None]
mock_copy.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid,
self.common.create_cloned_volume,
dest_volume_larger, detached_volume)
@ -495,11 +498,11 @@ class TestFCDotHillCommon(test.TestCase):
mock_stats.side_effect = [stats_low_space, stats_large_space,
stats_large_space]
self.assertRaises(exception.DotHillNotEnoughSpace,
self.assertRaises(dh_exception.DotHillNotEnoughSpace,
self.common.create_volume_from_snapshot,
dest_volume, test_snap)
mock_copy.side_effect = [exception.DotHillRequestError, None]
mock_copy.side_effect = [dh_exception.DotHillRequestError, None]
mock_get_size.return_value = test_snap['volume_size']
self.assertRaises(exception.Invalid,
self.common.create_volume_from_snapshot,
@ -517,7 +520,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'get_volume_size')
@mock.patch.object(dothill.DotHillClient, 'extend_volume')
def test_extend_volume(self, mock_extend, mock_size):
mock_extend.side_effect = [exception.DotHillRequestError, None]
mock_extend.side_effect = [dh_exception.DotHillRequestError, None]
mock_size.side_effect = [10, 10]
self.assertRaises(exception.Invalid, self.common.extend_volume,
test_volume, 20)
@ -527,7 +530,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'create_snapshot')
def test_create_snapshot(self, mock_create):
mock_create.side_effect = [exception.DotHillRequestError, None]
mock_create.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid, self.common.create_snapshot,
test_snap)
@ -537,9 +540,10 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'delete_snapshot')
def test_delete_snapshot(self, mock_delete):
not_found_e = exception.DotHillRequestError(
not_found_e = dh_exception.DotHillRequestError(
'The volume was not found on this system.')
mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
mock_delete.side_effect = [not_found_e,
dh_exception.DotHillRequestError,
None]
self.assertIsNone(self.common.delete_snapshot(test_snap))
@ -551,7 +555,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'map_volume')
def test_map_volume(self, mock_map):
mock_map.side_effect = [exception.DotHillRequestError, 10]
mock_map.side_effect = [dh_exception.DotHillRequestError, 10]
self.assertRaises(exception.Invalid, self.common.map_volume,
test_volume, connector, self.connector_element)
@ -563,7 +567,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'unmap_volume')
def test_unmap_volume(self, mock_unmap):
mock_unmap.side_effect = [exception.DotHillRequestError, None]
mock_unmap.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid, self.common.unmap_volume,
test_volume, connector, self.connector_element)
@ -577,7 +581,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'delete_volume')
@mock.patch.object(dothill.DotHillClient, 'modify_volume_name')
def test_retype(self, mock_modify, mock_delete, mock_copy):
mock_copy.side_effect = [exception.DotHillRequestError, None]
mock_copy.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid, self.common.migrate_volume,
test_retype_volume, test_host)
ret = self.common.migrate_volume(test_retype_volume, test_host)
@ -590,7 +594,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'modify_volume_name')
def test_manage_existing(self, mock_modify, mock_volume):
existing_ref = {'source-name': 'xxxx'}
mock_modify.side_effect = [exception.DotHillRequestError, None]
mock_modify.side_effect = [dh_exception.DotHillRequestError, None]
self.assertRaises(exception.Invalid, self.common.manage_existing,
test_volume, existing_ref)
ret = self.common.manage_existing(test_volume, existing_ref)
@ -599,7 +603,7 @@ class TestFCDotHillCommon(test.TestCase):
@mock.patch.object(dothill.DotHillClient, 'get_volume_size')
def test_manage_existing_get_size(self, mock_volume):
existing_ref = {'source-name': 'xxxx'}
mock_volume.side_effect = [exception.DotHillRequestError, 1]
mock_volume.side_effect = [dh_exception.DotHillRequestError, 1]
self.assertRaises(exception.Invalid,
self.common.manage_existing_get_size,
None, existing_ref)

View File

@ -27,8 +27,8 @@ import requests
import six
from cinder import coordination
from cinder import exception
from cinder.i18n import _
from cinder.volume.drivers.dothill import exception as dh_exception
LOG = logging.getLogger(__name__)
@ -64,7 +64,7 @@ class DotHillClient(object):
self._session_key = session_key
except Exception as e:
msg = _("Cannot parse session key: %s") % e.msg
raise exception.DotHillConnectionError(message=msg)
raise dh_exception.DotHillConnectionError(message=msg)
def login(self):
if self._session_key is None:
@ -85,7 +85,7 @@ class DotHillClient(object):
LOG.debug("Logged in to array %s at %s (session %s)",
self._array_name, self._base_url, self._session_key)
return
except exception.DotHillConnectionError:
except dh_exception.DotHillConnectionError:
not_responding = self._curr_ip_addr
LOG.exception('session_login failed to connect to %s',
self._curr_ip_addr)
@ -98,11 +98,11 @@ class DotHillClient(object):
try:
self._get_session_key()
return
except exception.DotHillConnectionError:
except dh_exception.DotHillConnectionError:
LOG.error('Failed to connect to %s',
self._curr_ip_addr)
continue
raise exception.DotHillConnectionError(
raise dh_exception.DotHillConnectionError(
message=_("Failed to log in to management controller"))
@coordination.synchronized('{self._driver_name}-{self._array_name}')
@ -122,12 +122,12 @@ class DotHillClient(object):
except requests.exceptions.RequestException:
msg = _("Failed to obtain MC session key")
LOG.exception(msg)
raise exception.DotHillConnectionError(message=msg)
raise dh_exception.DotHillConnectionError(message=msg)
self._get_auth_token(xml.text.encode('utf8'))
LOG.debug("session key = %s", self._session_key)
if self._session_key is None:
raise exception.DotHillAuthenticationError
raise dh_exception.DotHillAuthenticationError
def _assert_response_ok(self, tree):
"""Parses the XML returned by the device to check the return code.
@ -139,7 +139,7 @@ class DotHillClient(object):
# if it is not present.
return_code = tree.findtext(".//PROPERTY[@name='return-code']")
if not return_code:
raise exception.DotHillRequestError(message="No status found")
raise dh_exception.DotHillRequestError(message="No status found")
# If no error occurred, just return.
if return_code == '0':
@ -149,7 +149,7 @@ class DotHillClient(object):
msg = "%s (%s)" % (tree.findtext(".//PROPERTY[@name='response']"),
return_code)
raise exception.DotHillRequestError(message=msg)
raise dh_exception.DotHillRequestError(message=msg)
def _build_request_url(self, path, *args, **kargs):
url = self._base_url + path
@ -177,14 +177,14 @@ class DotHillClient(object):
while tries_left > 0:
try:
return self._api_request(path, *args, **kargs)
except exception.DotHillConnectionError as e:
except dh_exception.DotHillConnectionError as e:
if tries_left < 1:
LOG.error("Array Connection error: "
"%s (no more retries)", e.msg)
raise
# Retry on any network connection errors, SSL errors, etc
LOG.error("Array Connection error: %s (retrying)", e.msg)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
if tries_left < 1:
LOG.error("Array Request error: %s (no more retries)",
e.msg)
@ -220,7 +220,7 @@ class DotHillClient(object):
except Exception as e:
message = _("Exception handling URL %(url)s: %(msg)s") % {
'url': url, 'msg': e}
raise exception.DotHillConnectionError(message=message)
raise dh_exception.DotHillConnectionError(message=message)
if path == "/show/volumecopy-status":
return tree
@ -252,7 +252,7 @@ class DotHillClient(object):
try:
self._request("/create/volume", name, **path_dict)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10186 => The specified name is already in use.
# This can occur during controller failover.
if '(-10186)' in e.msg:
@ -265,7 +265,7 @@ class DotHillClient(object):
def delete_volume(self, name):
try:
self._request("/delete/volumes", name)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10075 => The specified volume was not found.
# This can occur during controller failover.
if '(-10075)' in e.msg:
@ -281,7 +281,7 @@ class DotHillClient(object):
def create_snapshot(self, volume_name, snap_name):
try:
self._request("/create/snapshots", snap_name, volumes=volume_name)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10186 => The specified name is already in use.
# This can occur during controller failover.
if '(-10186)' in e.msg:
@ -295,7 +295,7 @@ class DotHillClient(object):
self._request("/delete/snapshot", "cleanup", snap_name)
else:
self._request("/delete/snapshot", snap_name)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10050 => The volume was not found on this system.
# This can occur during controller failover.
if '(-10050)' in e.msg:
@ -311,7 +311,7 @@ class DotHillClient(object):
path = "/show/pools"
self._request(path, backend_name)
return True
except exception.DotHillRequestError:
except dh_exception.DotHillRequestError:
return False
def _get_size(self, size):
@ -377,7 +377,7 @@ class DotHillClient(object):
firsthost, lun)
return lun
lun += 1
raise exception.DotHillRequestError(
raise dh_exception.DotHillRequestError(
message=_("No LUNs available for mapping to host %s.") % host)
@coordination.synchronized('{self._driver_name}-{self._array_name}-map')
@ -392,7 +392,7 @@ class DotHillClient(object):
hostname = self._safe_hostname(connector['host'])
try:
self._request("/create/host", hostname, id=host)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10058: The host identifier or nickname is already in use
if '(-10058)' in e.msg:
LOG.error("While trying to create host nickname"
@ -411,7 +411,7 @@ class DotHillClient(object):
host=host,
access="rw")
return lun
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -3177 => "The specified LUN overlaps a previously defined LUN
if '(-3177)' in e.msg:
LOG.info("Unable to map volume"
@ -430,7 +430,7 @@ class DotHillClient(object):
e)
raise
raise exception.DotHillRequestError(
raise dh_exception.DotHillRequestError(
message=_("Failed to find a free LUN for host %s") % host)
def unmap_volume(self, volume_name, connector, connector_element):
@ -440,7 +440,7 @@ class DotHillClient(object):
host = connector['initiator']
try:
self._request("/unmap/volume", volume_name, host=host)
except exception.DotHillRequestError as e:
except dh_exception.DotHillRequestError as e:
# -10050 => The volume was not found on this system.
# This can occur during controller failover.
if '(-10050)' in e.msg:
@ -496,7 +496,7 @@ class DotHillClient(object):
else:
if count >= 5:
LOG.error('Error in copying volume: %s', src_name)
raise exception.DotHillRequestError
raise dh_exception.DotHillRequestError
time.sleep(1)
count += 1

View File

@ -29,6 +29,7 @@ from cinder import exception
from cinder.i18n import _
from cinder.objects import fields
from cinder.volume.drivers.dothill import dothill_client as dothill
from cinder.volume.drivers.dothill import exception as dh_exception
LOG = logging.getLogger(__name__)
@ -69,18 +70,18 @@ class DotHillCommon(object):
def client_login(self):
try:
self.client.login()
except exception.DotHillConnectionError as ex:
except dh_exception.DotHillConnectionError as ex:
msg = _("Failed to connect to %(vendor_name)s Array %(host)s: "
"%(err)s") % {'vendor_name': self.vendor_name,
'host': self.config.san_ip,
'err': six.text_type(ex)}
LOG.error(msg)
raise exception.DotHillConnectionError(message=msg)
except exception.DotHillAuthenticationError:
raise dh_exception.DotHillConnectionError(message=msg)
except dh_exception.DotHillAuthenticationError:
msg = _("Failed to log on %s Array "
"(invalid login?).") % self.vendor_name
LOG.error(msg)
raise exception.DotHillAuthenticationError(message=msg)
raise dh_exception.DotHillAuthenticationError(message=msg)
def _get_serial_number(self):
self.serialNumber = self.client.get_serial_number()
@ -93,7 +94,7 @@ class DotHillCommon(object):
if not self.client.backend_exists(self.backend_name,
self.backend_type):
self.client_logout()
raise exception.DotHillInvalidBackend(backend=self.backend_name)
raise dh_exception.DotHillInvalidBackend(backend=self.backend_name)
def client_logout(self):
self.client.logout()
@ -148,7 +149,7 @@ class DotHillCommon(object):
volume_size,
self.backend_name,
self.backend_type)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Creation of volume %s failed.", volume['id'])
raise exception.Invalid(ex)
@ -165,7 +166,7 @@ class DotHillCommon(object):
required_size = pool_size + volume_size
if required_size > self.stats['pools'][0]['free_capacity_gb']:
raise exception.DotHillNotEnoughSpace(backend=self.backend_name)
raise dh_exception.DotHillNotEnoughSpace(backend=self.backend_name)
def _assert_source_detached(self, volume):
"""The DotHill requires a volume to be dettached to clone it.
@ -195,7 +196,7 @@ class DotHillCommon(object):
try:
self.client.copy_volume(orig_name, dest_name,
self.backend_name, self.backend_type)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Cloning of volume %s failed.",
src_vref['id'])
raise exception.Invalid(ex)
@ -218,7 +219,7 @@ class DotHillCommon(object):
try:
self.client.copy_volume(orig_name, dest_name,
self.backend_name, self.backend_type)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Create volume failed from snapshot: %s",
snapshot['id'])
raise exception.Invalid(ex)
@ -238,7 +239,7 @@ class DotHillCommon(object):
self.client_login()
try:
self.client.delete_volume(volume_name)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
# if the volume wasn't found, ignore the error
if 'The volume was not found on this system.' in ex.args:
return
@ -278,7 +279,7 @@ class DotHillCommon(object):
self.backend_name,
self.owner))
pool['pool_name'] = self.backend_name
except exception.DotHillRequestError:
except dh_exception.DotHillRequestError:
err = (_("Unable to get stats for backend_name: %s") %
self.backend_name)
LOG.exception(err)
@ -304,7 +305,7 @@ class DotHillCommon(object):
connector,
connector_element)
return data
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error mapping volume: %s", volume_name)
raise exception.Invalid(ex)
@ -320,7 +321,7 @@ class DotHillCommon(object):
self.client.unmap_volume(volume_name,
connector,
connector_element)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error unmapping volume: %s", volume_name)
raise exception.Invalid(ex)
finally:
@ -329,21 +330,21 @@ class DotHillCommon(object):
def get_active_fc_target_ports(self):
try:
return self.client.get_active_fc_target_ports()
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error getting active FC target ports.")
raise exception.Invalid(ex)
def get_active_iscsi_target_iqns(self):
try:
return self.client.get_active_iscsi_target_iqns()
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error getting active ISCSI target iqns.")
raise exception.Invalid(ex)
def get_active_iscsi_target_portals(self):
try:
return self.client.get_active_iscsi_target_portals()
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error getting active ISCSI target portals.")
raise exception.Invalid(ex)
@ -360,7 +361,7 @@ class DotHillCommon(object):
self.client_login()
try:
self.client.create_snapshot(vol_name, snap_name)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Creation of snapshot failed for volume: %s",
snapshot['volume_id'])
raise exception.Invalid(ex)
@ -374,7 +375,7 @@ class DotHillCommon(object):
self.client_login()
try:
self.client.delete_snapshot(snap_name, self.backend_type)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
# if the volume wasn't found, ignore the error
if 'The volume was not found on this system.' in ex.args:
return
@ -401,7 +402,7 @@ class DotHillCommon(object):
self.client_login()
try:
self.client.extend_volume(volume_name, "%dGiB" % growth_size)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Extension of volume %s failed.", volume['id'])
raise exception.Invalid(ex)
finally:
@ -410,14 +411,14 @@ class DotHillCommon(object):
def get_chap_record(self, initiator_name):
try:
return self.client.get_chap_record(initiator_name)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error getting chap record.")
raise exception.Invalid(ex)
def create_chap_record(self, initiator_name, chap_secret):
try:
self.client.create_chap_record(initiator_name, chap_secret)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error creating chap record.")
raise exception.Invalid(ex)
@ -462,7 +463,7 @@ class DotHillCommon(object):
self.client.delete_volume(source_name)
self.client.modify_volume_name(dest_name, source_name)
return (True, None)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error migrating volume: %s", source_name)
raise exception.Invalid(ex)
finally:
@ -485,7 +486,7 @@ class DotHillCommon(object):
try:
self.client.modify_volume_name(target_vol_name,
modify_target_vol_name)
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error manage existing volume.")
raise exception.Invalid(ex)
finally:
@ -503,7 +504,7 @@ class DotHillCommon(object):
try:
size = self.client.get_volume_size(target_vol_name)
return size
except exception.DotHillRequestError as ex:
except dh_exception.DotHillRequestError as ex:
LOG.exception("Error manage existing get volume size.")
raise exception.Invalid(ex)
finally:

View File

@ -15,9 +15,9 @@
# under the License.
#
from cinder import exception
import cinder.volume.driver
from cinder.volume.drivers.dothill import dothill_common
from cinder.volume.drivers.dothill import exception as dh_exception
from cinder.volume.drivers.san import san
from cinder.zonemanager import utils as fczm_utils
@ -50,7 +50,7 @@ class DotHillFCDriver(cinder.volume.driver.FibreChannelDriver):
def __init__(self, *args, **kwargs):
# Make sure we're not invoked directly
if type(self) == DotHillFCDriver:
raise exception.DotHillDriverNotSupported
raise dh_exception.DotHillDriverNotSupported
super(DotHillFCDriver, self).__init__(*args, **kwargs)
self.common = None
self.configuration.append_config_values(san.san_opts)

View File

@ -21,6 +21,7 @@ from cinder import exception
from cinder.i18n import _
import cinder.volume.driver
from cinder.volume.drivers.dothill import dothill_common as dothillcommon
from cinder.volume.drivers.dothill import exception as dh_exception
from cinder.volume.drivers.san import san
@ -58,7 +59,7 @@ class DotHillISCSIDriver(cinder.volume.driver.ISCSIDriver):
def __init__(self, *args, **kwargs):
# Make sure we're not invoked directly
if type(self) == DotHillISCSIDriver:
raise exception.DotHillDriverNotSupported
raise dh_exception.DotHillDriverNotSupported
super(DotHillISCSIDriver, self).__init__(*args, **kwargs)
self.common = None
self.configuration.append_config_values(san.san_opts)
@ -129,7 +130,7 @@ class DotHillISCSIDriver(cinder.volume.driver.ISCSIDriver):
break
if 'target_portal' not in data:
raise exception.DotHillNotTargetPortal()
raise dh_exception.DotHillNotTargetPortal()
if self.configuration.use_chap_auth:
chap_secret = self.common.get_chap_record(

View File

@ -0,0 +1,43 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from cinder import exception
from cinder.i18n import _
class DotHillInvalidBackend(exception.VolumeDriverException):
message = _("Backend doesn't exist (%(backend)s)")
class DotHillConnectionError(exception.VolumeDriverException):
message = "%(message)s"
class DotHillAuthenticationError(exception.VolumeDriverException):
message = "%(message)s"
class DotHillNotEnoughSpace(exception.VolumeDriverException):
message = _("Not enough space on backend (%(backend)s)")
class DotHillRequestError(exception.VolumeDriverException):
message = "%(message)s"
class DotHillNotTargetPortal(exception.VolumeDriverException):
message = _("No active iSCSI portals with supplied iSCSI IPs")
class DotHillDriverNotSupported(exception.VolumeDriverException):
message = _("The Dot Hill driver is no longer supported.")