Handle exception case with only target_portals
Prior to this if a backend had reported only target_portals and left out the target_portal option the exception handling would break. To support this we will just check first and then use a more tailored exception. Change-Id: I528e05ae88938a3acc6715e25cb4719dca3eed10 Closes-Bug: #1577601
This commit is contained in:
parent
9640b73cc4
commit
0e75bf6bda
@ -114,6 +114,10 @@ class TargetPortalNotFound(BrickException):
|
||||
message = _("Unable to find target portal %(target_portal)s.")
|
||||
|
||||
|
||||
class TargetPortalsNotFound(BrickException):
|
||||
message = _("Unable to find target portal in %(target_portals)s.")
|
||||
|
||||
|
||||
class FailedISCSITargetPortalLogin(BrickException):
|
||||
message = _("Unable to login to iSCSI Target Portal")
|
||||
|
||||
|
@ -615,8 +615,14 @@ class ISCSIConnector(InitiatorConnector):
|
||||
try:
|
||||
ips_iqns = self._discover_iscsi_portals(connection_properties)
|
||||
except Exception:
|
||||
raise exception.TargetPortalNotFound(
|
||||
target_portal=connection_properties['target_portal'])
|
||||
if 'target_portals' in connection_properties:
|
||||
raise exception.TargetPortalsNotFound(
|
||||
target_portal=connection_properties['target_portals'])
|
||||
elif 'target_portal' in connection_properties:
|
||||
raise exception.TargetPortalNotFound(
|
||||
target_portal=connection_properties['target_portal'])
|
||||
else:
|
||||
raise
|
||||
|
||||
if not connection_properties.get('target_iqns'):
|
||||
# There are two types of iSCSI multipath devices. One which
|
||||
|
@ -1110,6 +1110,30 @@ Setting up iSCSI targets: unused
|
||||
actual = self.connector.get_all_available_volumes()
|
||||
self.assertItemsEqual(expected, actual)
|
||||
|
||||
@mock.patch.object(connector.ISCSIConnector, '_discover_iscsi_portals')
|
||||
def test_get_potential_paths_failure_mpath_single_target(self,
|
||||
mock_discover):
|
||||
connection_properties = {
|
||||
'target_portal': '10.0.2.15:3260'
|
||||
}
|
||||
self.connector.use_multipath = True
|
||||
mock_discover.side_effect = exception.BrickException()
|
||||
self.assertRaises(exception.TargetPortalNotFound,
|
||||
self.connector._get_potential_volume_paths,
|
||||
connection_properties)
|
||||
|
||||
@mock.patch.object(connector.ISCSIConnector, '_discover_iscsi_portals')
|
||||
def test_get_potential_paths_failure_mpath_multi_target(self,
|
||||
mock_discover):
|
||||
connection_properties = {
|
||||
'target_portals': ['10.0.2.15:3260', '10.0.3.15:3260']
|
||||
}
|
||||
self.connector.use_multipath = True
|
||||
mock_discover.side_effect = exception.BrickException()
|
||||
self.assertRaises(exception.TargetPortalsNotFound,
|
||||
self.connector._get_potential_volume_paths,
|
||||
connection_properties)
|
||||
|
||||
|
||||
class FibreChannelConnectorTestCase(ConnectorTestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user