From 28d31345833b2af163fa6391258e72dd2b0df626 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 7 Aug 2019 09:16:12 -0400 Subject: [PATCH] Initalize pool_executor so close works The close method, called by the context manager, blows up if the Connection hasn't been used to upload any large swift objects, because the pool executor object hasn't been created. Initialize the variable so that the context manager works again. Change-Id: I2647b211a02e4fbc8f4850c420249398eaee9e74 --- openstack/connection.py | 1 + openstack/tests/unit/cloud/test_shade.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/openstack/connection.py b/openstack/connection.py index c79d84587..f8f1d256d 100644 --- a/openstack/connection.py +++ b/openstack/connection.py @@ -356,6 +356,7 @@ class Connection(six.with_metaclass(_meta.ConnectionMeta, self._session = None self._proxies = {} + self.__pool_executor = None self.use_direct_get = use_direct_get self.strict_mode = strict # Call the _*CloudMixin constructors while we work on diff --git a/openstack/tests/unit/cloud/test_shade.py b/openstack/tests/unit/cloud/test_shade.py index d96b612b1..cbf640487 100644 --- a/openstack/tests/unit/cloud/test_shade.py +++ b/openstack/tests/unit/cloud/test_shade.py @@ -62,6 +62,15 @@ class TestShade(base.TestCase): # keystoneauth1.loading.base.BaseLoader.load_from_options self.cloud.connect_as(project_name='test_project') + def test_connect_as_context(self): + # Do initial auth/catalog steps + # TODO(mordred) This only tests the constructor steps. Discovery + # cache sharing is broken. We need to get discovery_cache option + # plumbed through + # keystoneauth1.loading.base.BaseLoader.load_from_options + with self.cloud.connect_as(project_name='test_project'): + pass + @mock.patch.object(connection.Connection, 'search_images') def test_get_images(self, mock_search): image1 = dict(id='123', name='mickey')