| 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 provconfig |
| 17 |
from neutron_lib.exceptions import vpn as vpn_exception |
| 18 |
from oslo_log import log as logging |
| 19 |
from oslo_utils import importutils |
| 20 |
|
| 21 |
LOG = logging.getLogger(__name__) |
| 22 |
|
| 23 |
DEVICE_DRIVERS = 'device_drivers' |
| 24 |
|
| 25 |
|
| 26 |
class VPNService: |
| 27 |
"""VPN Service observer.""" |
| 28 |
|
| 29 |
def __init__(self, l3_agent): |
| 30 |
self.conf = l3_agent.conf |
| 31 |
|
| 32 |
def load_device_drivers(self, host): |
| 33 |
"""Loads one or more device drivers for VPNaaS.""" |
| 34 |
drivers = [] |
| 35 |
for device_driver in self.conf.vpnagent.vpn_device_driver: |
| 36 |
device_driver = provconfig.get_provider_driver_class( |
| 37 |
device_driver, DEVICE_DRIVERS) |
| 38 |
try: |
| 39 |
drivers.append(importutils.import_object(device_driver, |
| 40 |
self, |
| 41 |
host)) |
| 42 |
LOG.debug('Loaded VPNaaS device driver: %s', device_driver) |
| 43 |
except ImportError: |
| 44 |
raise vpn_exception.DeviceDriverImportError( |
| 45 |
device_driver=device_driver) |
| 46 |
return drivers |