| 1 |
# Copyright 2013, Nachi Ueno, NTT I3, Inc. |
| 2 |
# Copyright 2023, SysEleven GmbH |
| 3 |
# All Rights Reserved. |
| 4 |
# |
| 5 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 |
# not use this file except in compliance with the License. You may obtain |
| 7 |
# a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, software |
| 12 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 |
# License for the specific language governing permissions and limitations |
| 15 |
# under the License. |
| 16 |
import sys |
| 17 |
|
| 18 |
from neutron.common import config as common_config |
| 19 |
from neutron.conf.agent import common as agent_config |
| 20 |
from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf |
| 21 |
from oslo_config import cfg |
| 22 |
from oslo_log import log as logging |
| 23 |
from oslo_service import service |
| 24 |
|
| 25 |
from neutron_vpnaas._i18n import _ |
| 26 |
from neutron_vpnaas.agent.ovn.vpn import agent |
| 27 |
|
| 28 |
LOG = logging.getLogger(__name__) |
| 29 |
|
| 30 |
|
| 31 |
VPN_AGENT_OPTS = [ |
| 32 |
cfg.MultiStrOpt( |
| 33 |
'vpn_device_driver', |
| 34 |
default=['neutron_vpnaas.services.vpn.device_drivers.' |
| 35 |
'ovn_ipsec.OvnStrongSwanDriver'], |
| 36 |
sample_default=['neutron_vpnaas.services.vpn.device_drivers.' |
| 37 |
'ovn_ipsec.OvnStrongSwanDriver'], |
| 38 |
help=_("The OVN VPN device drivers Neutron will use")), |
| 39 |
] |
| 40 |
|
| 41 |
OVS_OPTS = [ |
| 42 |
cfg.StrOpt('ovsdb_connection', |
| 43 |
default='unix:/usr/local/var/run/openvswitch/db.sock', |
| 44 |
regex=r'^(tcp|ssl|unix):.+', |
| 45 |
help=_('The connection string for the native OVSDB backend.\n' |
| 46 |
'Use tcp:IP:PORT for TCP connection.\n' |
| 47 |
'Use unix:FILE for unix domain socket connection.')), |
| 48 |
cfg.IntOpt('ovsdb_connection_timeout', |
| 49 |
default=180, |
| 50 |
help=_('Timeout in seconds for the OVSDB ' |
| 51 |
'connection transaction')) |
| 52 |
] |
| 53 |
|
| 54 |
|
| 55 |
def register_opts(conf): |
| 56 |
common_config.register_common_config_options() |
| 57 |
agent_config.register_interface_driver_opts_helper(conf) |
| 58 |
agent_config.register_interface_opts(conf) |
| 59 |
agent_config.register_availability_zone_opts_helper(conf) |
| 60 |
ovn_conf.register_opts() |
| 61 |
conf.register_opts(VPN_AGENT_OPTS, 'vpnagent') |
| 62 |
conf.register_opts(OVS_OPTS, 'ovs') |
| 63 |
|
| 64 |
|
| 65 |
def main(): |
| 66 |
register_opts(cfg.CONF) |
| 67 |
common_config.init(sys.argv[1:]) |
| 68 |
agent_config.setup_logging() |
| 69 |
agent_config.setup_privsep() |
| 70 |
|
| 71 |
agt = agent.OvnVpnAgent(cfg.CONF) |
| 72 |
service.launch(cfg.CONF, agt, restart_method='mutate').wait() |