diff --git a/nova/tests/unit/volume/test_cinder.py b/nova/tests/unit/volume/test_cinder.py index 081025dfc083..06712e715ed2 100644 --- a/nova/tests/unit/volume/test_cinder.py +++ b/nova/tests/unit/volume/test_cinder.py @@ -1062,11 +1062,15 @@ class CinderClientTestCase(test.NoDBTestCase): get_volume_api.assert_called_once_with( self.mock_session.get_endpoint.return_value) + @mock.patch('nova.volume.cinder.LOG.error') @mock.patch.object(ks_loading, 'load_auth_from_conf_options') - def test_load_auth_plugin_failed(self, mock_load_from_conf): + def test_load_auth_plugin_failed(self, mock_load_from_conf, mock_log_err): mock_load_from_conf.return_value = None self.assertRaises(cinder_exception.Unauthorized, cinder._load_auth_plugin, CONF) + mock_log_err.assert_called() + self.assertIn('The [cinder] section of your nova configuration file', + mock_log_err.call_args[0][0]) @mock.patch('nova.volume.cinder._ADMIN_AUTH') def test_admin_context_without_token(self, diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index cd513f71914b..8f0b2a8c3596 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -70,6 +70,10 @@ def _load_auth_plugin(conf): if auth_plugin: return auth_plugin + if conf.cinder.auth_type is None: + LOG.error('The [cinder] section of your nova configuration file ' + 'must be configured for authentication with the ' + 'block-storage service endpoint.') err_msg = _('Unknown auth type: %s') % conf.cinder.auth_type raise cinder_exception.Unauthorized(401, message=err_msg)