Debian Codegraph @

neutron_fwaas/services/firewall/service_drivers/agents/drivers/conntrack_base.py

raw symbols SCIP
1 # Copyright (c) 2017 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 import abc
17
18
19 from neutron_lib.utils import runtime
20 from oslo_config import cfg
21 from oslo_log import log as logging
22 from oslo_utils import excutils
23
24 LOG = logging.getLogger(__name__)
25
26
27 def load_and_init_conntrack_driver(*args, **kwargs):
28 driver = cfg.CONF.fwaas.conntrack_driver
29 try:
30 conntrack_driver_cls = runtime.load_class_by_alias_or_classname(
31 'neutron.agent.l3.firewall_drivers', driver)
32 except ImportError:
33 with excutils.save_and_reraise_exception():
34 LOG.exception("Driver '%s' not found.", driver)
35 conntrack_driver = conntrack_driver_cls()
36 conntrack_driver.initialize(*args, **kwargs)
37 return conntrack_driver
38
39
40 class ConntrackDriverBase(metaclass=abc.ABCMeta):
41 """Base Driver for Conntrack"""
42
43 @abc.abstractmethod
44 def initialize(self, *args, **kwargs):
45 """Initialize the driver"""
46
47 @abc.abstractmethod
48 def delete_entries(self, rules, namespace):
49 """Delete conntrack entries specified by list of rules"""
50
51 @abc.abstractmethod
52 def flush_entries(self, namespace):
53 """Delete all conntrack entries within namespace"""