Debian Codegraph @

neutron_fwaas/services/firewall/service_drivers/agents/firewall_service.py

raw symbols SCIP
1 # Copyright 2014 OpenStack Foundation.
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 import provider_configuration as provconf
17 from oslo_config import cfg
18 from oslo_log import log as logging
19 from oslo_utils import importutils
20
21 from neutron_fwaas._i18n import _
22
23 LOG = logging.getLogger(__name__)
24
25 FIREWALL_DRIVERS = 'firewall_drivers'
26
27
28 class FirewallService:
29 """Firewall Service observer."""
30
31 def load_device_drivers(self):
32 """Loads a single device driver for FWaaS."""
33 device_driver = provconf.get_provider_driver_class(
34 cfg.CONF.fwaas.driver, FIREWALL_DRIVERS)
35 try:
36 driver = importutils.import_object(device_driver)
37 LOG.debug('Loaded FWaaS device driver: %s', device_driver)
38 return driver
39 except ImportError:
40 msg = _('Error importing FWaaS device driver: %s')
41 raise ImportError(msg % device_driver)
42 except ValueError:
43 msg = _('Configuration error - no FWaaS device_driver specified')
44 raise ValueError(msg)