TVD: Do not crash in case the project is not found
When the different service plugins filter the list results by the project id of the current requestor, the code should not raise an error if one of the objects project was not found. Instead that object will be skipped, and a message will be logged. Change-Id: Ia78f059e1334a23cd9cda07a8981d1f74ae2c430
This commit is contained in:
parent
af3dbf97b3
commit
f6241f4ef8
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib import exceptions
|
||||
@ -21,6 +22,8 @@ from neutron_lib.plugins import directory
|
||||
|
||||
from vmware_nsx.db import db as nsx_db
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def is_tvd_core_plugin():
|
||||
core_plugin = cfg.CONF.core_plugin
|
||||
@ -63,14 +66,22 @@ def filter_plugins(cls):
|
||||
by the project id of the context
|
||||
"""
|
||||
entries = orig_method(self, context, **kwargs)
|
||||
if not context.project_id:
|
||||
if not context.project_id or not entries:
|
||||
return entries
|
||||
req_p = get_project_mapping(context, context.project_id)
|
||||
for entry in entries[:]:
|
||||
if entry.get('tenant_id'):
|
||||
p = get_project_mapping(context, entry['tenant_id'])
|
||||
if p != req_p:
|
||||
try:
|
||||
p = get_project_mapping(context, entry['tenant_id'])
|
||||
except exceptions.ObjectNotFound:
|
||||
# This could be a project that was already deleted
|
||||
LOG.info("Project %s is not associated with any "
|
||||
"plugin and will be ignored",
|
||||
entry['tenant_id'])
|
||||
entries.remove(entry)
|
||||
else:
|
||||
if p != req_p:
|
||||
entries.remove(entry)
|
||||
|
||||
return entries
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user