| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 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 |
|
| 64 |
importutils.import_module('neutron_fwaas.services.logapi.fwg_validate') |
| 65 |
|
| 66 |
manager.register( |
| 67 |
fwaas_constants.FIREWALL_GROUP, fwg_callback.FirewallGroupCallBack) |
| 68 |
|
| 69 |
manager.register(resources.PORT, port_callback.NeutronPortCallBack) |
| 70 |
|
| 71 |
LOG.debug('FWaaS L3 Logging driver based iptables registered') |