Skip to content

Commit afc6ab7

Browse files
elvgarruiralonsoh
authored andcommitted
[SGL] Use admin context to retrieve log objs
Previously we tried to search which log objects existed based on the context of the user who is creating a change on a security group rule. This is not correct as only admin can fetch log objects. Closes-Bug: #2107446 Change-Id: Ia65e06c83ced9cde7618d4d7f3c7b0b3ae48c3fa Signed-off-by: Elvira Garcia <[email protected]> (cherry picked from commit 6e70cd4)
1 parent fe9795b commit afc6ab7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

neutron/services/logapi/common/sg_callback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# License for the specific language governing permissions and limitations
1414
# under the License.
1515

16+
from neutron_lib import context as n_context
1617
from neutron_lib.services.logapi import constants as log_const
1718

1819
from neutron.services.logapi.common import db_api
@@ -23,14 +24,16 @@ class SecurityGroupRuleCallBack(manager.ResourceCallBackBase):
2324

2425
def handle_event(self, resource, event, trigger, payload):
2526
context = payload.context
27+
admin_context = n_context.get_admin_context()
2628
sg_rule = payload.latest_state
2729
if sg_rule:
2830
sg_id = sg_rule.get('security_group_id')
2931
else:
3032
sg_id = payload.resource_id
3133

34+
# Log resources can only be fetched from admin context.
3235
log_resources = db_api.get_logs_bound_sg(
33-
context, sg_id=sg_id, project_id=context.project_id)
36+
admin_context, sg_id=sg_id, project_id=context.project_id)
3437
if log_resources:
3538
self.resource_push_api(
3639
log_const.RESOURCE_UPDATE, context, log_resources)

0 commit comments

Comments
 (0)