Merge "TVD: Do not crash in case the project is not found"
This commit is contained in:
commit
e21cebb78c
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
from neutron_lib import context as n_context
|
from neutron_lib import context as n_context
|
||||||
from neutron_lib import exceptions
|
from neutron_lib import exceptions
|
||||||
@ -21,6 +22,8 @@ from neutron_lib.plugins import directory
|
|||||||
|
|
||||||
from vmware_nsx.db import db as nsx_db
|
from vmware_nsx.db import db as nsx_db
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def is_tvd_core_plugin():
|
def is_tvd_core_plugin():
|
||||||
core_plugin = cfg.CONF.core_plugin
|
core_plugin = cfg.CONF.core_plugin
|
||||||
@ -63,12 +66,20 @@ def filter_plugins(cls):
|
|||||||
by the project id of the context
|
by the project id of the context
|
||||||
"""
|
"""
|
||||||
entries = orig_method(self, context, **kwargs)
|
entries = orig_method(self, context, **kwargs)
|
||||||
if not context.project_id:
|
if not context.project_id or not entries:
|
||||||
return entries
|
return entries
|
||||||
req_p = get_project_mapping(context, context.project_id)
|
req_p = get_project_mapping(context, context.project_id)
|
||||||
for entry in entries[:]:
|
for entry in entries[:]:
|
||||||
if entry.get('tenant_id'):
|
if entry.get('tenant_id'):
|
||||||
|
try:
|
||||||
p = get_project_mapping(context, entry['tenant_id'])
|
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:
|
if p != req_p:
|
||||||
entries.remove(entry)
|
entries.remove(entry)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user