Merge "Refactoring config options of l3 agent keepalived"

This commit is contained in:
Jenkins 2016-08-12 18:02:07 +00:00 committed by Gerrit Code Review
commit fed5e76092
3 changed files with 52 additions and 35 deletions

View File

@ -26,6 +26,7 @@ from neutron.agent.linux import daemon
from neutron.agent.linux import ip_monitor
from neutron.agent.linux import utils as agent_utils
from neutron.common import config
from neutron.conf.agent.l3 import keepalived
LOG = logging.getLogger(__name__)
@ -97,32 +98,6 @@ class MonitorDaemon(daemon.Daemon):
LOG.debug('Notified agent router %s, state %s', self.router_id, state)
def register_opts(conf):
conf.register_cli_opt(
cfg.StrOpt('router_id', help=_('ID of the router')))
conf.register_cli_opt(
cfg.StrOpt('namespace', help=_('Namespace of the router')))
conf.register_cli_opt(
cfg.StrOpt('conf_dir', help=_('Path to the router directory')))
conf.register_cli_opt(
cfg.StrOpt('monitor_interface', help=_('Interface to monitor')))
conf.register_cli_opt(
cfg.StrOpt('monitor_cidr', help=_('CIDR to monitor')))
conf.register_cli_opt(
cfg.StrOpt('pid_file', help=_('Path to PID file for this process')))
conf.register_cli_opt(
cfg.StrOpt('user', help=_('User (uid or name) running this process '
'after its initialization')))
conf.register_cli_opt(
cfg.StrOpt('group', help=_('Group (gid or name) running this process '
'after its initialization')))
conf.register_opt(
cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy',
help=_('Location of Metadata Proxy UNIX domain '
'socket')))
def configure(conf):
config.init(sys.argv[1:])
conf.set_override('log_dir', cfg.CONF.conf_dir)
@ -131,7 +106,8 @@ def configure(conf):
def main():
register_opts(cfg.CONF)
keepalived.register_cli_l3_agent_keepalived_opts()
keepalived.register_l3_agent_keepalived_opts()
configure(cfg.CONF)
MonitorDaemon(cfg.CONF.pid_file,
cfg.CONF.router_id,

View File

@ -0,0 +1,47 @@
# Copyright (c) 2015 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from neutron._i18n import _
CLI_OPTS = [
cfg.StrOpt('router_id', help=_('ID of the router')),
cfg.StrOpt('namespace', help=_('Namespace of the router')),
cfg.StrOpt('conf_dir', help=_('Path to the router directory')),
cfg.StrOpt('monitor_interface', help=_('Interface to monitor')),
cfg.StrOpt('monitor_cidr', help=_('CIDR to monitor')),
cfg.StrOpt('pid_file', help=_('Path to PID file for this process')),
cfg.StrOpt('user', help=_('User (uid or name) running this process '
'after its initialization')),
cfg.StrOpt('group', help=_('Group (gid or name) running this process '
'after its initialization'))
]
OPTS = [
cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy',
help=_('Location of Metadata Proxy UNIX domain '
'socket'))
]
def register_cli_l3_agent_keepalived_opts(conf=cfg.CONF):
conf.register_cli_opts(CLI_OPTS)
def register_l3_agent_keepalived_opts(conf=cfg.CONF):
conf.register_opts(OPTS)

View File

@ -15,12 +15,11 @@
import os
import mock
from oslo_config import cfg
from oslo_config import fixture as fixture_config
from oslo_utils import uuidutils
from neutron._i18n import _
from neutron.agent.l3 import keepalived_state_change
from neutron.conf.agent.l3 import keepalived as kd
from neutron.tests.functional import base
@ -28,12 +27,7 @@ class TestKeepalivedStateChange(base.BaseSudoTestCase):
def setUp(self):
super(TestKeepalivedStateChange, self).setUp()
self.conf_fixture = self.useFixture(fixture_config.Config())
self.conf_fixture.register_opt(
cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy',
help=_('Location of Metadata Proxy UNIX domain '
'socket')))
kd.register_l3_agent_keepalived_opts(self.conf_fixture)
self.router_id = uuidutils.generate_uuid()
self.conf_dir = self.get_default_temp_dir().path
self.cidr = '169.254.128.1/24'