]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
BigSwitch: Fix cfg.Error format in exception
authorKevin Benton <blak111@gmail.com>
Fri, 7 Mar 2014 18:41:24 +0000 (10:41 -0800)
committerKevin Benton <blak111@gmail.com>
Fri, 7 Mar 2014 18:43:49 +0000 (10:43 -0800)
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
neutron/tests/unit/bigswitch/test_servermanager.py

index a886849fe5709063c1e2edb60493dbf13616dbf4..2ef0da162f38ff34bce0b87fc3283129dcc832d7 100644 (file)
@@ -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,
index f313141ec040877872359bfb22492573bc0e5017..569a98bf21650d52a04a0f8770c1d97622021765 100644 (file)
 #
 # @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))])