Ensure that default SG exists during list of SG rules API call

During processing of security group rule list API call Neutron will
now ensure that default security group for project given in the filters
or in the context exists.
It is similar to what is done for list of security groups or creation of
new network/port in the project.

Change-Id: Id6fee5a752968b356b884d939b708a420016c9bc
Closes-Bug: #1864171
This commit is contained in:
Slawek Kaplonski 2020-02-20 05:22:30 +01:00
parent f97ae3d6f8
commit 4739a4febb
1 changed files with 8 additions and 0 deletions

View File

@ -719,6 +719,14 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
pager = base_obj.Pager(
sorts=sorts, marker=marker, limit=limit, page_reverse=page_reverse)
project_id = filters.get('project_id') or filters.get('tenant_id')
if project_id:
project_id = project_id[0]
else:
project_id = context.project_id
if project_id:
self._ensure_default_security_group(context, project_id)
if not filters and context.project_id and not context.is_admin:
rule_ids = sg_obj.SecurityGroupRule.get_security_group_rule_ids(
context.project_id)