]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Validate that context exists
authorGary Kotton <gkotton@vmware.com>
Sat, 18 Jul 2015 07:33:10 +0000 (00:33 -0700)
committerGary Kotton <gkotton@vmware.com>
Sat, 18 Jul 2015 12:21:51 +0000 (05:21 -0700)
Commit 3e0328b992d8a90213a56ec5a4144677279bea66 broke external
decomposed plugins due to the fact that it assumes that the
context is set.

This patch validates that the context is set.

Co-Authored-By: Kevin Benton <blak111@gmail.com>
Change-Id: I3320f27be7b0fed1d3b37a5c5459d91b2bc4f13b
Closes-bug: #1475837

neutron/db/db_base_plugin_common.py

index 8661ec589505c8b2049efdb6c1177dc255716748..54257ed971cc1030d2c88c22e1169edcd50e4748 100644 (file)
@@ -223,9 +223,10 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin):
         # The shared attribute for a network now reflects if the network
         # is shared to the calling tenant via an RBAC entry.
         shared = False
+        matches = ('*',) + ((context.tenant_id,) if context else ())
         for entry in network.rbac_entries:
             if (entry.action == 'access_as_shared' and
-                    entry.target_tenant in ('*', context.tenant_id)):
+                    entry.target_tenant in matches):
                 shared = True
                 break
         res['shared'] = shared