Debian Codegraph @

neutron_fwaas/services/logapi/agents/drivers/iptables/driver.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 base
17 from neutron.services.logapi.drivers import manager
18 from neutron_lib.callbacks import resources
19 from neutron_lib.services.logapi import constants as log_const
20 from oslo_log import log as logging
21 from oslo_utils import importutils
22
23 from neutron_fwaas.common import fwaas_constants
24 from neutron_fwaas.services.logapi.common import fwg_callback
25 from neutron_fwaas.services.logapi.common import port_callback
26 from neutron_fwaas.services.logapi import constants as fw_const
27 from neutron_fwaas.services.logapi.rpc import log_server as rpc_server
28
29 LOG = logging.getLogger(__name__)
30
31 DRIVER = None
32
33 SUPPORTED_LOGGING_TYPES = [fw_const.FIREWALL_GROUP]
34
35
36 class IptablesLoggingDriver(base.DriverBase):
37
38 @staticmethod
39 def create():
40 return IptablesLoggingDriver(
41 name='iptables',
42 vif_types=[],
43 vnic_types=[],
44 supported_logging_types=SUPPORTED_LOGGING_TYPES,
45 requires_rpc=True)
46
47
48 def register():
49 """Register iptables-based logging driver for FWaaS."""
50
51 global DRIVER
52 if not DRIVER:
53 DRIVER = IptablesLoggingDriver.create()
54 # Register RPC methods
55 if DRIVER.requires_rpc:
56 rpc_methods = [
57 {resources.PORT: rpc_server.get_fwg_log_info_for_port},
58 {log_const.LOG_RESOURCE: rpc_server.
59 get_fwg_log_info_for_log_resources}
60 ]
61 DRIVER.register_rpc_methods(fw_const.FIREWALL_GROUP, rpc_methods)
62
63 # Trigger fwg validator
64 importutils.import_module('neutron_fwaas.services.logapi.fwg_validate')
65 # Register resource callback handler
66 manager.register(
67 fwaas_constants.FIREWALL_GROUP, fwg_callback.FirewallGroupCallBack)
68 # Register resource callback handler for Neutron ports
69 manager.register(resources.PORT, port_callback.NeutronPortCallBack)
70
71 LOG.debug('FWaaS L3 Logging driver based iptables registered')