From 84368554d8a13a421297298de40693956af25fcd Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Fri, 7 Mar 2014 10:41:24 -0800 Subject: [PATCH] BigSwitch: Fix cfg.Error format in exception Fixes an incorrectly formatted call to cfg.Error in an exception handling routine in the Big Switch server manager module. Closes-Bug: #1289134 Change-Id: I9a1137d7395412ff6f061aacbe85f9b26269a1da --- neutron/plugins/bigswitch/servermanager.py | 4 ++-- .../tests/unit/bigswitch/test_servermanager.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py index a886849fe..2ef0da162 100644 --- a/neutron/plugins/bigswitch/servermanager.py +++ b/neutron/plugins/bigswitch/servermanager.py @@ -356,8 +356,8 @@ class ServerPool(object): except Exception as e: raise cfg.Error(_('Could not retrieve initial ' 'certificate from controller %(server)s. ' - 'Error details: %(error)s'), - {'server': server, 'error': e.strerror}) + 'Error details: %(error)s') % + {'server': server, 'error': str(e)}) LOG.warning(_("Storing to certificate for host %(server)s " "at %(path)s") % {'server': server, diff --git a/neutron/tests/unit/bigswitch/test_servermanager.py b/neutron/tests/unit/bigswitch/test_servermanager.py index f313141ec..569a98bf2 100644 --- a/neutron/tests/unit/bigswitch/test_servermanager.py +++ b/neutron/tests/unit/bigswitch/test_servermanager.py @@ -14,8 +14,10 @@ # # @author: Kevin Benton, kevin.benton@bigswitch.com # +import mock from oslo.config import cfg +from neutron.manager import NeutronManager from neutron.plugins.bigswitch import servermanager from neutron.tests.unit.bigswitch import test_restproxy_plugin as test_rp @@ -29,3 +31,17 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase): def test_malformed_servers(self): cfg.CONF.set_override('servers', ['a:b:c'], 'RESTPROXY') self.assertRaises(cfg.Error, servermanager.ServerPool) + + def test_sticky_cert_fetch_fail(self): + pl = NeutronManager.get_plugin() + pl.servers.ssl = True + with mock.patch( + 'ssl.get_server_certificate', + side_effect=Exception('There is no more entropy in the universe') + ) as sslgetmock: + self.assertRaises( + cfg.Error, + pl.servers._get_combined_cert_for_server, + *('example.org', 443) + ) + sslgetmock.assert_has_calls([mock.call(('example.org', 443))]) -- 2.45.2