]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix confusing exception message in NetApp iscsi driver
authorTom Barron <tbarron@netapp.com>
Thu, 28 Aug 2014 19:59:28 +0000 (15:59 -0400)
committerTom Barron <tpb@dyncloud.net>
Wed, 10 Sep 2014 09:05:56 +0000 (05:05 -0400)
Fix confusing exception message when no target details
are returned on volume attach.

Change-Id: Ib5fe15a4a6be14a20b1ae446b8b57737b50e9aeb
Closes-Bug: 1366816

cinder/tests/test_netapp.py
cinder/volume/drivers/netapp/iscsi.py

index 74ff95047c2662f46d8f66fc907f3845250eeb36..1bdce7619e0b079f1b7ff2056d0db421380ef9d2 100644 (file)
@@ -22,6 +22,7 @@ import BaseHTTPServer
 import httplib
 
 from lxml import etree
+import mock
 import six
 
 from cinder import exception
@@ -40,7 +41,6 @@ from cinder.volume.drivers.netapp.options import netapp_provisioning_opts
 from cinder.volume.drivers.netapp.options import netapp_transport_opts
 from cinder.volume.drivers.netapp import ssc_utils
 
-
 LOG = logging.getLogger("cinder.volume.driver")
 
 
@@ -658,6 +658,23 @@ class NetAppDirectCmodeISCSIDriverTestCase(test.TestCase):
         self.driver.create_volume(self.volume)
         self.driver.extend_volume(self.volume, 4)
 
+    def test_initialize_connection_no_target_details_found(self):
+        fake_volume = {'name': 'mock-vol'}
+        fake_connector = {'initiator': 'iqn.mock'}
+        self.driver._map_lun = mock.Mock(return_value='mocked-lun-id')
+        self.driver._get_iscsi_service_details = mock.Mock(
+            return_value='mocked-iqn')
+        self.driver._get_target_details = mock.Mock(return_value=[])
+        expected = (_('No iscsi target details were found for LUN %s')
+                    % fake_volume['name'])
+        try:
+            self.driver.initialize_connection(fake_volume, fake_connector)
+        except exception.VolumeBackendAPIException as exc:
+            if expected not in str(exc):
+                self.fail(_('Expected exception message is missing'))
+        else:
+            self.fail(_('VolumeBackendAPIException not raised'))
+
 
 class NetAppDriverNegativeTestCase(test.TestCase):
     """Test case for NetAppDriver"""
index 761c79d46e953a36bc8aa8e693dff109e3260edc..7b930100df69abdbb1b31b70384f7d99c235aa73 100644 (file)
@@ -236,7 +236,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
         LOG.debug(msg % msg_fmt)
 
         if not target_details_list:
-            msg = _('Failed to get LUN target details for the LUN %s')
+            msg = _('No iscsi target details were found for LUN %s')
             raise exception.VolumeBackendAPIException(data=msg % name)
         target_details = None
         for tgt_detail in target_details_list: