From 86866f9ba5655ada618be4ebdb4dd6d62dece314 Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Thu, 16 Mar 2017 11:28:10 -0400 Subject: [PATCH] pecan: Make admin context if no context was created Simlarly to legacy [1] this patch creates context in case environment doesn't have one. Closes-bug: #1673105 [1] https://git.openstack.org/cgit/openstack/neutron/tree/neutron/wsgi.py?id=fe4559f475757c7fc1314862eba4705a27c06c87#n276 Change-Id: I4bf17d115166a8b18b054da41e79914eab27f6d3 --- neutron/pecan_wsgi/hooks/context.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron/pecan_wsgi/hooks/context.py b/neutron/pecan_wsgi/hooks/context.py index 552f8fb886e..ef2ab62232f 100644 --- a/neutron/pecan_wsgi/hooks/context.py +++ b/neutron/pecan_wsgi/hooks/context.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import context from pecan import hooks @@ -21,5 +22,6 @@ class ContextHook(hooks.PecanHook): priority = 95 def before(self, state): - ctx = state.request.environ['neutron.context'] + ctx = (state.request.environ.get('neutron.context') or + context.get_admin_context()) state.request.context['neutron_context'] = ctx