Change and move the workers options to corresponding service section

Currently, the workers options of collector, api and notification services
are all located in [DEFAULT] section. This change unify the options name
and move them to corresponding service configure section.
Additionally, this change will remove the "workers set by cpu number"
functionality, because it has no effect if the workers options has default
value.

Closes-Bug: #1481254

Change-Id: Idde86762ab6520d3adcbdd2b86d0f4de3a8517cd
This commit is contained in:
liu-sheng
2015-08-05 10:48:40 +08:00
committed by LiuSheng
parent 5edd2b4825
commit 717bd7d064
7 changed files with 41 additions and 45 deletions

View File

@@ -22,9 +22,7 @@ from oslo_config import cfg
import oslo_i18n
from oslo_log import log
from ceilometer.i18n import _
from ceilometer import messaging
from ceilometer import utils
OPTS = [
@@ -33,14 +31,6 @@ OPTS = [
help='Name of this node, which must be valid in an AMQP '
'key. Can be an opaque identifier. For ZeroMQ only, must '
'be a valid host name, FQDN, or IP address.'),
cfg.IntOpt('collector_workers',
default=1,
help='Number of workers for collector service. A single '
'collector is enabled by default.'),
cfg.IntOpt('notification_workers',
default=1,
help='Number of workers for notification service. A single '
'notification agent is enabled by default.'),
cfg.IntOpt('http_timeout',
default=600,
help='Timeout seconds for HTTP requests. Set it to None to '
@@ -87,26 +77,39 @@ CLI_OPTS = [
help='Disables X.509 certificate validation when an '
'SSL connection to Identity Service is established.'),
]
cfg.CONF.register_cli_opts(CLI_OPTS, group="service_credentials")
API_OPT = cfg.IntOpt('workers',
default=1,
min=1,
deprecated_group='DEFAULT',
deprecated_name='api_workers',
help='Number of workers for api, default value is 1.')
cfg.CONF.register_opt(API_OPT, 'api')
NOTI_OPT = cfg.IntOpt('workers',
default=1,
min=1,
deprecated_group='DEFAULT',
deprecated_name='notification_workers',
help='Number of workers for notification service, '
'default value is 1.')
cfg.CONF.register_opt(NOTI_OPT, 'notification')
COLL_OPT = cfg.IntOpt('workers',
default=1,
min=1,
deprecated_group='DEFAULT',
deprecated_name='collector_workers',
help='Number of workers for collector service. '
'default value is 1.')
cfg.CONF.register_opt(COLL_OPT, 'collector')
LOG = log.getLogger(__name__)
class WorkerException(Exception):
"""Exception for errors relating to service workers."""
def get_workers(name):
workers = (cfg.CONF.get('%s_workers' % name) or
utils.cpu_count())
if workers and workers < 1:
msg = (_("%(worker_name)s value of %(workers)s is invalid, "
"must be greater than 0") %
{'worker_name': '%s_workers' % name, 'workers': str(workers)})
raise WorkerException(msg)
return workers
def prepare_service(argv=None):
oslo_i18n.enable_lazy()
log.register_options(cfg.CONF)