diff --git a/os_brick/initiator/connector.py b/os_brick/initiator/connector.py index 46faa6544..caae03f86 100644 --- a/os_brick/initiator/connector.py +++ b/os_brick/initiator/connector.py @@ -464,15 +464,16 @@ class InitiatorConnector(executor.Executor): of the target volume attributes. :type connection_properties: dict """ + volumes = [] path = self.get_search_path() if path: # now find all entries in the search path if os.path.isdir(path): path_items = [path, '/*'] file_filter = ''.join(path_items) - return glob.glob(file_filter) - else: - return [] + volumes = glob.glob(file_filter) + + return volumes def check_IO_handle_valid(self, handle, data_type, protocol): """Check IO handle has correct data type.""" diff --git a/os_brick/tests/initiator/test_connector.py b/os_brick/tests/initiator/test_connector.py index 34ba89fc8..9b49c606f 100644 --- a/os_brick/tests/initiator/test_connector.py +++ b/os_brick/tests/initiator/test_connector.py @@ -1102,6 +1102,13 @@ Setting up iSCSI targets: unused new_size = self.connector.extend_volume(connection_info['data']) self.assertEqual(fake_new_size, new_size) + @mock.patch.object(os.path, 'isdir') + def test_get_all_available_volumes_path_not_dir(self, mock_isdir): + mock_isdir.return_value = False + expected = [] + actual = self.connector.get_all_available_volumes() + self.assertItemsEqual(expected, actual) + class FibreChannelConnectorTestCase(ConnectorTestCase): def setUp(self): @@ -1453,6 +1460,13 @@ class FibreChannelConnectorTestCase(ConnectorTestCase): new_size = self.connector.extend_volume(connection_info['data']) self.assertEqual(fake_new_size, new_size) + @mock.patch.object(os.path, 'isdir') + def test_get_all_available_volumes_path_not_dir(self, mock_isdir): + mock_isdir.return_value = False + expected = [] + actual = self.connector.get_all_available_volumes() + self.assertItemsEqual(expected, actual) + class FibreChannelConnectorS390XTestCase(ConnectorTestCase):