Validate that context exists

Commit 3e0328b992 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
This commit is contained in:
Gary Kotton 2015-07-18 00:33:10 -07:00
parent 312bd47265
commit ce437729f9
1 changed files with 2 additions and 1 deletions

View 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