Refactoring agent metadata config
Refactoring neutron agent metadata config opts to be in neutron/conf/agent/metadata so that all the configurations options reside in a centralized location. This simplifies the process of looking up the config opts and provides an easy way to import. Change-Id: I8bae1facc58a4f9e21196f625478532403651545 Partial-Bug: #1563069
This commit is contained in:

committed by
Kevin Benton

parent
cffe2cd1ac
commit
fcc13b5f8f
@ -21,10 +21,10 @@ from oslo_service import service
|
||||
|
||||
from neutron.agent.common import config
|
||||
from neutron.agent.linux import interface
|
||||
from neutron.agent.metadata import config as metadata_config
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common import topics
|
||||
from neutron.conf.agent import dhcp as dhcp_config
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron import service as neutron_service
|
||||
|
||||
|
||||
@ -33,8 +33,8 @@ def register_options(conf):
|
||||
config.register_agent_state_opts_helper(conf)
|
||||
config.register_availability_zone_opts_helper(conf)
|
||||
dhcp_config.register_agent_dhcp_opts(conf)
|
||||
conf.register_opts(metadata_config.DRIVER_OPTS)
|
||||
conf.register_opts(metadata_config.SHARED_OPTS)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.DRIVER_OPTS, conf)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf)
|
||||
conf.register_opts(interface.OPTS)
|
||||
|
||||
|
||||
|
@ -24,19 +24,19 @@ from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import interface
|
||||
from neutron.agent.linux import pd
|
||||
from neutron.agent.linux import ra
|
||||
from neutron.agent.metadata import config as metadata_config
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common import topics
|
||||
from neutron.conf.agent.l3 import config as l3_config
|
||||
from neutron.conf.agent.l3 import ha as ha_conf
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron import service as neutron_service
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
l3_config.register_l3_agent_config_opts(l3_config.OPTS, conf)
|
||||
conf.register_opts(metadata_config.DRIVER_OPTS)
|
||||
conf.register_opts(metadata_config.SHARED_OPTS)
|
||||
ha_conf.register_l3_agent_ha_opts(conf)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.DRIVER_OPTS, conf)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, conf)
|
||||
config.register_interface_driver_opts_helper(conf)
|
||||
config.register_agent_state_opts_helper(conf)
|
||||
conf.register_opts(interface.OPTS)
|
||||
|
@ -28,12 +28,12 @@ import webob
|
||||
|
||||
from neutron._i18n import _, _LE, _LW
|
||||
from neutron.agent.linux import utils as agent_utils
|
||||
from neutron.agent.metadata import config
|
||||
from neutron.agent import rpc as agent_rpc
|
||||
from neutron.common import cache_utils as cache
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.conf.agent.metadata import config
|
||||
from neutron import context
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -27,6 +27,7 @@ from neutron.agent.linux import utils as agent_utils
|
||||
from neutron.common import config
|
||||
from neutron.common import exceptions
|
||||
from neutron.common import utils
|
||||
from neutron.conf.agent.metadata import namespace_proxy as namespace
|
||||
from neutron import wsgi
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -137,40 +138,7 @@ class ProxyDaemon(daemon.Daemon):
|
||||
|
||||
|
||||
def main():
|
||||
opts = [
|
||||
cfg.StrOpt('network_id',
|
||||
help=_('Network that will have instance metadata '
|
||||
'proxied.')),
|
||||
cfg.StrOpt('router_id',
|
||||
help=_('Router that will have connected instances\' '
|
||||
'metadata proxied.')),
|
||||
cfg.StrOpt('pid_file',
|
||||
help=_('Location of pid file of this process.')),
|
||||
cfg.BoolOpt('daemonize',
|
||||
default=True,
|
||||
help=_('Run as daemon.')),
|
||||
cfg.PortOpt('metadata_port',
|
||||
default=9697,
|
||||
help=_("TCP Port to listen for metadata server "
|
||||
"requests.")),
|
||||
cfg.StrOpt('metadata_proxy_socket',
|
||||
default='$state_path/metadata_proxy',
|
||||
help=_('Location of Metadata Proxy UNIX domain '
|
||||
'socket')),
|
||||
cfg.StrOpt('metadata_proxy_user',
|
||||
help=_("User (uid or name) running metadata proxy after "
|
||||
"its initialization")),
|
||||
cfg.StrOpt('metadata_proxy_group',
|
||||
help=_("Group (gid or name) running metadata proxy after "
|
||||
"its initialization")),
|
||||
cfg.BoolOpt('metadata_proxy_watch_log',
|
||||
default=True,
|
||||
help=_("Watch file log. Log watch should be disabled when "
|
||||
"metadata_proxy_user/group has no read/write "
|
||||
"permissions on metadata proxy log file.")),
|
||||
]
|
||||
|
||||
cfg.CONF.register_cli_opts(opts)
|
||||
namespace.register_namespace_proxy_opts(cfg.CONF)
|
||||
# Don't get the default configuration file
|
||||
cfg.CONF(project='neutron', default_config_files=[])
|
||||
config.setup_logging()
|
||||
|
@ -19,18 +19,18 @@ from oslo_log import log as logging
|
||||
|
||||
from neutron.agent.common import config as agent_conf
|
||||
from neutron.agent.metadata import agent
|
||||
from neutron.agent.metadata import config as metadata_conf
|
||||
from neutron.common import cache_utils as cache
|
||||
from neutron.common import config
|
||||
from neutron.common import utils
|
||||
from neutron.conf.agent.metadata import config as meta
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
cfg.CONF.register_opts(metadata_conf.SHARED_OPTS)
|
||||
cfg.CONF.register_opts(metadata_conf.UNIX_DOMAIN_METADATA_PROXY_OPTS)
|
||||
cfg.CONF.register_opts(metadata_conf.METADATA_PROXY_HANDLER_OPTS)
|
||||
meta.register_meta_conf_opts(meta.SHARED_OPTS)
|
||||
meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS)
|
||||
meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS)
|
||||
cache.register_oslo_configs(cfg.CONF)
|
||||
cfg.CONF.set_default(name='cache_url', default='memory://?default_ttl=5')
|
||||
agent_conf.register_agent_state_opts_helper(cfg.CONF)
|
||||
|
0
neutron/conf/agent/metadata/__init__.py
Normal file
0
neutron/conf/agent/metadata/__init__.py
Normal file
@ -17,6 +17,11 @@ from oslo_config import cfg
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
DEDUCE_MODE = 'deduce'
|
||||
USER_MODE = 'user'
|
||||
GROUP_MODE = 'group'
|
||||
ALL_MODE = 'all'
|
||||
SOCKET_MODES = (DEDUCE_MODE, USER_MODE, GROUP_MODE, ALL_MODE)
|
||||
|
||||
SHARED_OPTS = [
|
||||
cfg.StrOpt('metadata_proxy_socket',
|
||||
@ -82,12 +87,6 @@ METADATA_PROXY_HANDLER_OPTS = [
|
||||
help=_("Private key of client certificate."))
|
||||
]
|
||||
|
||||
DEDUCE_MODE = 'deduce'
|
||||
USER_MODE = 'user'
|
||||
GROUP_MODE = 'group'
|
||||
ALL_MODE = 'all'
|
||||
SOCKET_MODES = (DEDUCE_MODE, USER_MODE, GROUP_MODE, ALL_MODE)
|
||||
|
||||
|
||||
UNIX_DOMAIN_METADATA_PROXY_OPTS = [
|
||||
cfg.StrOpt('metadata_proxy_socket_mode',
|
||||
@ -114,3 +113,7 @@ UNIX_DOMAIN_METADATA_PROXY_OPTS = [
|
||||
help=_('Number of backlog requests to configure the '
|
||||
'metadata server socket with'))
|
||||
]
|
||||
|
||||
|
||||
def register_meta_conf_opts(opts, cfg=cfg.CONF):
|
||||
cfg.register_opts(opts)
|
54
neutron/conf/agent/metadata/namespace_proxy.py
Normal file
54
neutron/conf/agent/metadata/namespace_proxy.py
Normal file
@ -0,0 +1,54 @@
|
||||
# Copyright 2016 New Dream Network, LLC (DreamHost)
|
||||
#
|
||||
# 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 _
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('network_id',
|
||||
help=_('Network that will have instance metadata '
|
||||
'proxied.')),
|
||||
cfg.StrOpt('router_id',
|
||||
help=_('Router that will have connected instances\' '
|
||||
'metadata proxied.')),
|
||||
cfg.StrOpt('pid_file',
|
||||
help=_('Location of pid file of this process.')),
|
||||
cfg.BoolOpt('daemonize',
|
||||
default=True,
|
||||
help=_('Run as daemon.')),
|
||||
cfg.PortOpt('metadata_port',
|
||||
default=9697,
|
||||
help=_('TCP Port to listen for metadata server'
|
||||
'requests.')),
|
||||
cfg.StrOpt('metadata_proxy_socket',
|
||||
default='$state_path/metadata_proxy',
|
||||
help=_('Location of Metadata Proxy UNIX domain '
|
||||
'socket')),
|
||||
cfg.StrOpt('metadata_proxy_user',
|
||||
help=_('User (uid or name) running metadata proxy after '
|
||||
'its initialization')),
|
||||
cfg.StrOpt('metadata_proxy_group',
|
||||
help=_('Group (gid or name) running metadata proxy after '
|
||||
'its initialization')),
|
||||
cfg.BoolOpt('metadata_proxy_watch_log',
|
||||
default=True,
|
||||
help=_('Watch file log. Log watch should be disabled when '
|
||||
'metadata_proxy_user/group has no read/write '
|
||||
'permissions on metadata proxy log file.')),
|
||||
]
|
||||
|
||||
|
||||
def register_namespace_proxy_opts(cfg=cfg.CONF):
|
||||
cfg.register_cli_opts(OPTS)
|
@ -22,12 +22,12 @@ import neutron.agent.common.config
|
||||
import neutron.agent.linux.interface
|
||||
import neutron.agent.linux.pd
|
||||
import neutron.agent.linux.ra
|
||||
import neutron.agent.metadata.config
|
||||
import neutron.agent.ovsdb.api
|
||||
import neutron.agent.securitygroups_rpc
|
||||
import neutron.conf.agent.dhcp
|
||||
import neutron.conf.agent.l3.config
|
||||
import neutron.conf.agent.l3.ha
|
||||
import neutron.conf.agent.metadata.config as meta_conf
|
||||
import neutron.conf.agent.ovs_conf
|
||||
import neutron.conf.cache_utils
|
||||
import neutron.conf.common
|
||||
@ -86,8 +86,8 @@ def list_agent_opts():
|
||||
('DEFAULT',
|
||||
itertools.chain(
|
||||
neutron.agent.common.config.INTERFACE_DRIVER_OPTS,
|
||||
neutron.agent.metadata.config.SHARED_OPTS,
|
||||
neutron.agent.metadata.config.DRIVER_OPTS)
|
||||
neutron.conf.agent.metadata.config.SHARED_OPTS,
|
||||
neutron.conf.agent.metadata.config.DRIVER_OPTS)
|
||||
)
|
||||
]
|
||||
|
||||
@ -218,9 +218,9 @@ def list_metadata_agent_opts():
|
||||
return [
|
||||
('DEFAULT',
|
||||
itertools.chain(
|
||||
neutron.agent.metadata.config.SHARED_OPTS,
|
||||
neutron.agent.metadata.config.METADATA_PROXY_HANDLER_OPTS,
|
||||
neutron.agent.metadata.config.UNIX_DOMAIN_METADATA_PROXY_OPTS,
|
||||
meta_conf.SHARED_OPTS,
|
||||
meta_conf.METADATA_PROXY_HANDLER_OPTS,
|
||||
meta_conf.UNIX_DOMAIN_METADATA_PROXY_OPTS,
|
||||
neutron.conf.cache_utils.cache_opts)
|
||||
),
|
||||
('AGENT', neutron.agent.common.config.AGENT_STATE_OPTS)
|
||||
|
@ -23,17 +23,18 @@ from oslo_utils import fileutils
|
||||
|
||||
from neutron.agent.linux import utils as agent_utils
|
||||
from neutron.agent.metadata import agent
|
||||
from neutron.agent.metadata import config
|
||||
from neutron.agent import metadata_agent
|
||||
from neutron.common import cache_utils as cache
|
||||
from neutron.common import utils
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class ConfFixture(config_fixture.Config):
|
||||
def setUp(self):
|
||||
super(ConfFixture, self).setUp()
|
||||
self.conf.register_opts(config.METADATA_PROXY_HANDLER_OPTS)
|
||||
meta_conf.register_meta_conf_opts(
|
||||
meta_conf.METADATA_PROXY_HANDLER_OPTS, self.conf)
|
||||
self.config(auth_ca_cert=None,
|
||||
nova_metadata_ip='9.9.9.9',
|
||||
nova_metadata_port=8775,
|
||||
@ -458,7 +459,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase):
|
||||
self.cfg.CONF.metadata_proxy_socket = '/the/path'
|
||||
self.cfg.CONF.metadata_workers = 0
|
||||
self.cfg.CONF.metadata_backlog = 128
|
||||
self.cfg.CONF.metadata_proxy_socket_mode = config.USER_MODE
|
||||
self.cfg.CONF.metadata_proxy_socket_mode = meta_conf.USER_MODE
|
||||
|
||||
@mock.patch.object(fileutils, 'ensure_tree')
|
||||
def test_init_doesnot_exists(self, ensure_dir):
|
||||
|
@ -20,11 +20,11 @@ from oslo_utils import uuidutils
|
||||
from neutron.agent.common import config as agent_config
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.l3 import router_info
|
||||
from neutron.agent.metadata import config
|
||||
from neutron.agent.metadata import driver as metadata_driver
|
||||
from neutron.common import constants
|
||||
from neutron.conf.agent.l3 import config as l3_config
|
||||
from neutron.conf.agent.l3 import ha as ha_conf
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
@ -77,8 +77,8 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
||||
|
||||
l3_config.register_l3_agent_config_opts(l3_config.OPTS, cfg.CONF)
|
||||
ha_conf.register_l3_agent_ha_opts()
|
||||
cfg.CONF.register_opts(config.SHARED_OPTS)
|
||||
cfg.CONF.register_opts(config.DRIVER_OPTS)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.SHARED_OPTS, cfg.CONF)
|
||||
meta_conf.register_meta_conf_opts(meta_conf.DRIVER_OPTS, cfg.CONF)
|
||||
|
||||
def test_after_router_updated_called_on_agent_process_update(self):
|
||||
with mock.patch.object(metadata_driver, 'after_router_updated') as f,\
|
||||
|
Reference in New Issue
Block a user