Config options: Centralize servicegroup options

This change moves the config options in servicegroup/api.py
to a central location "nova/conf/servicegroup.py".

Change-Id: I894adfe97fbce41435b510caa8b8514cd2fa8166
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Sujitha 2016-04-07 20:22:26 +00:00
parent a3a1a89829
commit 31276a49b3
4 changed files with 36 additions and 12 deletions

View File

@ -73,6 +73,7 @@ from nova.conf import scheduler
# from nova.conf import security
from nova.conf import serial_console
from nova.conf import service
from nova.conf import servicegroup
from nova.conf import spice
from nova.conf import ssl
# from nova.conf import trusted_computing
@ -142,6 +143,7 @@ scheduler.register_opts(CONF)
# security.register_opts(CONF)
serial_console.register_opts(CONF)
service.register_opts(CONF)
servicegroup.register_opts(CONF)
spice.register_opts(CONF)
ssl.register_opts(CONF)
# trusted_computing.register_opts(CONF)

32
nova/conf/servicegroup.py Normal file
View File

@ -0,0 +1,32 @@
# Copyright (c) 2016 OpenStack Foundation
# 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
servicegroup_driver = cfg.StrOpt('servicegroup_driver',
default='db',
help='The driver for servicegroup '
'service.',
choices=['db', 'mc'])
SERVICEGROUP_OPTS = [servicegroup_driver]
def register_opts(conf):
conf.register_opts(SERVICEGROUP_OPTS)
def list_opts():
return {'DEFAULT': SERVICEGROUP_OPTS}

View File

@ -26,7 +26,6 @@ import nova.db.base
import nova.db.sqlalchemy.api
import nova.exception
import nova.image.download.file
import nova.servicegroup.api
import nova.volume
@ -35,7 +34,6 @@ def list_opts():
('DEFAULT',
itertools.chain(
[nova.db.base.db_driver_opt],
[nova.servicegroup.api.servicegroup_driver_opt],
nova.db.api.db_opts,
nova.db.sqlalchemy.api.db_opts,
nova.exception.exc_log_opts,

View File

@ -16,10 +16,10 @@
"""Define APIs for the servicegroup access."""
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
import nova.conf
from nova.i18n import _LW
LOG = logging.getLogger(__name__)
@ -28,16 +28,8 @@ _driver_name_class_mapping = {
'db': 'nova.servicegroup.drivers.db.DbDriver',
'mc': 'nova.servicegroup.drivers.mc.MemcachedDriver'
}
_default_driver = 'db'
servicegroup_driver_opt = cfg.StrOpt('servicegroup_driver',
default=_default_driver,
help='The driver for servicegroup '
'service.',
choices=sorted(
_driver_name_class_mapping.keys()))
CONF = cfg.CONF
CONF.register_opt(servicegroup_driver_opt)
CONF = nova.conf.CONF
# NOTE(geekinutah): By default drivers wait 5 seconds before reporting
INITIAL_REPORTING_DELAY = 5