From 2647f91ae97844a73176fc1c8663d9b186bdec1a Mon Sep 17 00:00:00 2001 From: Wenzhi Yu Date: Tue, 26 Apr 2016 18:55:16 +0800 Subject: [PATCH] Fix NoSuchOptError when referring to conf.neutron.auth_plugin We already replaced 'auth_plugin' with 'auth_type'[1], now an oslo_config.cfg.NoSuchOptError will be threw up when referring to conf.neutron.auth_plugin. This commit replace the usage of conf.neutron.auth_plugin by conf.neutron.auth_type. [1]https://github.com/openstack/keystoneauth/commit/a56ed4218aef5a2e528aa682cea967e767dca923 Change-Id: I0b72f278ba8e28508274079ff284042fb9ea3d64 Closes-Bug: #1574988 --- nova/network/neutronv2/api.py | 2 +- nova/tests/unit/network/test_neutronv2.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 4163abcf26da..bc76efdf1ea7 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -104,7 +104,7 @@ def _load_auth_plugin(conf): if auth_plugin: return auth_plugin - err_msg = _('Unknown auth plugin: %s') % conf.neutron.auth_plugin + err_msg = _('Unknown auth type: %s') % conf.neutron.auth_type raise neutron_client_exc.Unauthorized(message=err_msg) diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py index 5a53f82e3262..72dcbec07866 100644 --- a/nova/tests/unit/network/test_neutronv2.py +++ b/nova/tests/unit/network/test_neutronv2.py @@ -181,6 +181,13 @@ class TestNeutronClient(test.NoDBTestCase): client1.list_networks(retrieve_all=False) self.assertEqual('new_token2', client1.httpclient.auth.get_token(None)) + @mock.patch.object(ks_loading, 'load_auth_from_conf_options') + def test_load_auth_plugin_failed(self, mock_load_from_conf): + mock_load_from_conf.return_value = None + from neutronclient.common import exceptions as neutron_client_exc + self.assertRaises(neutron_client_exc.Unauthorized, + neutronapi._load_auth_plugin, CONF) + class TestNeutronv2Base(test.TestCase):