Debian Codegraph @

neutron_fwaas/services/logapi/common/port_callback.py

raw symbols SCIP
1 # Copyright (c) 2018 Fujitsu Limited
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 from neutron.services.logapi.drivers import manager
17 from neutron_lib.callbacks import events
18 from neutron_lib import constants as nl_const
19 from neutron_lib.services.logapi import constants as log_const
20
21 from neutron_fwaas.services.logapi.common import log_db_api
22
23
24 class NeutronPortCallBack(manager.ResourceCallBackBase):
25
26 def handle_event(self, resource, event, trigger, payload):
27 if event == events.AFTER_UPDATE:
28 context = payload.context
29 original_port = payload.states[0]
30 port = payload.states[1]
31
32 if port['device_owner'] in nl_const.ROUTER_INTERFACE_OWNERS:
33 if original_port['status'] != port['status']:
34 self.trigger_logging(context, port)
35
36 def trigger_logging(self, context, port):
37 log_resources = log_db_api.get_logs_for_port(context, port['id'])
38 if log_resources:
39 self.resource_push_api(
40 log_const.RESOURCE_UPDATE, context, log_resources)