Merge "Refactoring config options for service"
This commit is contained in:
46
neutron/conf/service.py
Normal file
46
neutron/conf/service.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Copyright 2011 VMware, Inc
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 _
|
||||||
|
|
||||||
|
|
||||||
|
service_opts = [
|
||||||
|
cfg.IntOpt('periodic_interval',
|
||||||
|
default=40,
|
||||||
|
help=_('Seconds between running periodic tasks.')),
|
||||||
|
cfg.IntOpt('api_workers',
|
||||||
|
help=_('Number of separate API worker processes for service. '
|
||||||
|
'If not specified, the default is equal to the number '
|
||||||
|
'of CPUs available for best performance.')),
|
||||||
|
cfg.IntOpt('rpc_workers',
|
||||||
|
default=1,
|
||||||
|
help=_('Number of RPC worker processes for service.')),
|
||||||
|
cfg.IntOpt('rpc_state_report_workers',
|
||||||
|
default=1,
|
||||||
|
help=_('Number of RPC worker processes dedicated to state '
|
||||||
|
'reports queue.')),
|
||||||
|
cfg.IntOpt('periodic_fuzzy_delay',
|
||||||
|
default=5,
|
||||||
|
help=_('Range of seconds to randomly delay when starting the '
|
||||||
|
'periodic task scheduler to reduce stampeding. '
|
||||||
|
'(Disable by setting to 0)')),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def register_service_opts(opts, conf=cfg.CONF):
|
||||||
|
conf.register_opts(opts)
|
@@ -30,6 +30,7 @@ import neutron.agent.metadata.config
|
|||||||
import neutron.agent.ovsdb.api
|
import neutron.agent.ovsdb.api
|
||||||
import neutron.agent.securitygroups_rpc
|
import neutron.agent.securitygroups_rpc
|
||||||
import neutron.conf.quota
|
import neutron.conf.quota
|
||||||
|
import neutron.conf.service
|
||||||
import neutron.db.agents_db
|
import neutron.db.agents_db
|
||||||
import neutron.db.agentschedulers_db
|
import neutron.db.agentschedulers_db
|
||||||
import neutron.db.dvr_mac_db
|
import neutron.db.dvr_mac_db
|
||||||
@@ -55,7 +56,6 @@ import neutron.plugins.ml2.drivers.type_geneve
|
|||||||
import neutron.plugins.ml2.drivers.type_gre
|
import neutron.plugins.ml2.drivers.type_gre
|
||||||
import neutron.plugins.ml2.drivers.type_vlan
|
import neutron.plugins.ml2.drivers.type_vlan
|
||||||
import neutron.plugins.ml2.drivers.type_vxlan
|
import neutron.plugins.ml2.drivers.type_vxlan
|
||||||
import neutron.service
|
|
||||||
import neutron.services.metering.agents.metering_agent
|
import neutron.services.metering.agents.metering_agent
|
||||||
import neutron.services.qos.notification_drivers.manager
|
import neutron.services.qos.notification_drivers.manager
|
||||||
import neutron.wsgi
|
import neutron.wsgi
|
||||||
@@ -132,7 +132,7 @@ def list_opts():
|
|||||||
neutron.common.config.core_cli_opts,
|
neutron.common.config.core_cli_opts,
|
||||||
neutron.common.config.core_opts,
|
neutron.common.config.core_opts,
|
||||||
neutron.wsgi.socket_opts,
|
neutron.wsgi.socket_opts,
|
||||||
neutron.service.service_opts)
|
neutron.conf.service.service_opts)
|
||||||
),
|
),
|
||||||
(neutron.common.config.NOVA_CONF_SECTION,
|
(neutron.common.config.NOVA_CONF_SECTION,
|
||||||
itertools.chain(
|
itertools.chain(
|
||||||
@@ -192,7 +192,7 @@ def list_l3_agent_opts():
|
|||||||
('DEFAULT',
|
('DEFAULT',
|
||||||
itertools.chain(
|
itertools.chain(
|
||||||
neutron.agent.l3.config.OPTS,
|
neutron.agent.l3.config.OPTS,
|
||||||
neutron.service.service_opts,
|
neutron.conf.service.service_opts,
|
||||||
neutron.agent.l3.ha.OPTS,
|
neutron.agent.l3.ha.OPTS,
|
||||||
neutron.agent.linux.pd.OPTS,
|
neutron.agent.linux.pd.OPTS,
|
||||||
neutron.agent.linux.ra.OPTS)
|
neutron.agent.linux.ra.OPTS)
|
||||||
|
@@ -26,9 +26,10 @@ from oslo_service import service as common_service
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from neutron._i18n import _, _LE, _LI
|
from neutron._i18n import _LE, _LI
|
||||||
from neutron.common import config
|
from neutron.common import config
|
||||||
from neutron.common import rpc as n_rpc
|
from neutron.common import rpc as n_rpc
|
||||||
|
from neutron.conf import service
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.db import api as session
|
from neutron.db import api as session
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
@@ -36,29 +37,7 @@ from neutron import worker
|
|||||||
from neutron import wsgi
|
from neutron import wsgi
|
||||||
|
|
||||||
|
|
||||||
service_opts = [
|
service.register_service_opts(service.service_opts)
|
||||||
cfg.IntOpt('periodic_interval',
|
|
||||||
default=40,
|
|
||||||
help=_('Seconds between running periodic tasks')),
|
|
||||||
cfg.IntOpt('api_workers',
|
|
||||||
help=_('Number of separate API worker processes for service. '
|
|
||||||
'If not specified, the default is equal to the number '
|
|
||||||
'of CPUs available for best performance.')),
|
|
||||||
cfg.IntOpt('rpc_workers',
|
|
||||||
default=1,
|
|
||||||
help=_('Number of RPC worker processes for service')),
|
|
||||||
cfg.IntOpt('rpc_state_report_workers',
|
|
||||||
default=1,
|
|
||||||
help=_('Number of RPC worker processes dedicated to state '
|
|
||||||
'reports queue')),
|
|
||||||
cfg.IntOpt('periodic_fuzzy_delay',
|
|
||||||
default=5,
|
|
||||||
help=_('Range of seconds to randomly delay when starting the '
|
|
||||||
'periodic task scheduler to reduce stampeding. '
|
|
||||||
'(Disable by setting to 0)')),
|
|
||||||
]
|
|
||||||
CONF = cfg.CONF
|
|
||||||
CONF.register_opts(service_opts)
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -301,30 +280,30 @@ class Service(n_rpc.Service):
|
|||||||
periodic_fuzzy_delay=None):
|
periodic_fuzzy_delay=None):
|
||||||
"""Instantiates class and passes back application object.
|
"""Instantiates class and passes back application object.
|
||||||
|
|
||||||
:param host: defaults to CONF.host
|
:param host: defaults to cfg.CONF.host
|
||||||
:param binary: defaults to basename of executable
|
:param binary: defaults to basename of executable
|
||||||
:param topic: defaults to bin_name - 'neutron-' part
|
:param topic: defaults to bin_name - 'neutron-' part
|
||||||
:param manager: defaults to CONF.<topic>_manager
|
:param manager: defaults to cfg.CONF.<topic>_manager
|
||||||
:param report_interval: defaults to CONF.report_interval
|
:param report_interval: defaults to cfg.CONF.report_interval
|
||||||
:param periodic_interval: defaults to CONF.periodic_interval
|
:param periodic_interval: defaults to cfg.CONF.periodic_interval
|
||||||
:param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
|
:param periodic_fuzzy_delay: defaults to cfg.CONF.periodic_fuzzy_delay
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not host:
|
if not host:
|
||||||
host = CONF.host
|
host = cfg.CONF.host
|
||||||
if not binary:
|
if not binary:
|
||||||
binary = os.path.basename(inspect.stack()[-1][1])
|
binary = os.path.basename(inspect.stack()[-1][1])
|
||||||
if not topic:
|
if not topic:
|
||||||
topic = binary.rpartition('neutron-')[2]
|
topic = binary.rpartition('neutron-')[2]
|
||||||
topic = topic.replace("-", "_")
|
topic = topic.replace("-", "_")
|
||||||
if not manager:
|
if not manager:
|
||||||
manager = CONF.get('%s_manager' % topic, None)
|
manager = cfg.CONF.get('%s_manager' % topic, None)
|
||||||
if report_interval is None:
|
if report_interval is None:
|
||||||
report_interval = CONF.report_interval
|
report_interval = cfg.CONF.report_interval
|
||||||
if periodic_interval is None:
|
if periodic_interval is None:
|
||||||
periodic_interval = CONF.periodic_interval
|
periodic_interval = cfg.CONF.periodic_interval
|
||||||
if periodic_fuzzy_delay is None:
|
if periodic_fuzzy_delay is None:
|
||||||
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
|
periodic_fuzzy_delay = cfg.CONF.periodic_fuzzy_delay
|
||||||
service_obj = cls(host, binary, topic, manager,
|
service_obj = cls(host, binary, topic, manager,
|
||||||
report_interval=report_interval,
|
report_interval=report_interval,
|
||||||
periodic_interval=periodic_interval,
|
periodic_interval=periodic_interval,
|
||||||
|
Reference in New Issue
Block a user