Centralize config option: api section
Centralize config option of API section. Replace oslo_conf cfg to magnum.conf. Change-Id: I0589014ab8eb70f0f6551bb23808d3b9edc580c1 Implements: blueprint centralize-config-magnum
This commit is contained in:
parent
8020245e18
commit
cfe5b4ed5c
|
@ -19,41 +19,10 @@ import pecan
|
|||
from magnum.api import config as api_config
|
||||
from magnum.api import middleware
|
||||
from magnum.common import config as common_config
|
||||
import magnum.conf
|
||||
from magnum.i18n import _LI
|
||||
|
||||
# Register options for the service
|
||||
API_SERVICE_OPTS = [
|
||||
cfg.PortOpt('port',
|
||||
default=9511,
|
||||
help='The port for the Magnum API server.'),
|
||||
cfg.IPOpt('host',
|
||||
default='127.0.0.1',
|
||||
help='The listen IP for the Magnum API server.'),
|
||||
cfg.IntOpt('max_limit',
|
||||
default=1000,
|
||||
help='The maximum number of items returned in a single '
|
||||
'response from a collection resource.'),
|
||||
cfg.StrOpt('api_paste_config',
|
||||
default="api-paste.ini",
|
||||
help="Configuration file for WSGI definition of API."
|
||||
),
|
||||
cfg.StrOpt('ssl_cert_file',
|
||||
help="This option allows setting path to the SSL certificate "
|
||||
"of API server. "),
|
||||
cfg.StrOpt('ssl_key_file',
|
||||
help="This option specifies the path to the file where SSL "
|
||||
"private key of API server is stored when SSL is in "
|
||||
"effect. "),
|
||||
cfg.BoolOpt('enabled_ssl',
|
||||
default=False,
|
||||
help='Enable SSL Magnum API service')
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
opt_group = cfg.OptGroup(name='api',
|
||||
title='Options for the magnum-api service')
|
||||
CONF.register_group(opt_group)
|
||||
CONF.register_opts(API_SERVICE_OPTS, opt_group)
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -83,14 +52,14 @@ def setup_app(config=None):
|
|||
|
||||
def load_app():
|
||||
cfg_file = None
|
||||
cfg_path = cfg.CONF.api.api_paste_config
|
||||
cfg_path = CONF.api.api_paste_config
|
||||
if not os.path.isabs(cfg_path):
|
||||
cfg_file = CONF.find_file(cfg_path)
|
||||
elif os.path.exists(cfg_path):
|
||||
cfg_file = cfg_path
|
||||
|
||||
if not cfg_file:
|
||||
raise cfg.ConfigFilesNotFoundError([cfg.CONF.api.api_paste_config])
|
||||
raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
|
||||
LOG.info(_LI("Full WSGI config used: %s"), cfg_file)
|
||||
return deploy.loadapp("config:" + cfg_file)
|
||||
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
# under the License.
|
||||
|
||||
import jsonpatch
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import pecan
|
||||
import wsme
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils
|
||||
import magnum.conf
|
||||
from magnum.i18n import _
|
||||
from magnum.i18n import _LE
|
||||
from magnum import objects
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException,
|
||||
|
|
|
@ -17,19 +17,20 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
from werkzeug import serving
|
||||
|
||||
from magnum.api import app as api_app
|
||||
from magnum.common import service
|
||||
import magnum.conf
|
||||
from magnum.i18n import _
|
||||
from magnum.i18n import _LI
|
||||
from magnum.objects import base
|
||||
from magnum import version
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
CONF = magnum.conf.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -65,11 +66,11 @@ def main():
|
|||
use_ssl = CONF.api.enabled_ssl
|
||||
|
||||
# Create the WSGI server and start it
|
||||
host, port = cfg.CONF.api.host, cfg.CONF.api.port
|
||||
host, port = CONF.api.host, CONF.api.port
|
||||
|
||||
LOG.info(_LI('Starting server in PID %s'), os.getpid())
|
||||
LOG.debug("Configuration:")
|
||||
cfg.CONF.log_opt_values(LOG, logging.DEBUG)
|
||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||
|
||||
LOG.info(_LI('Serving on %(proto)s://%(host)s:%(port)s'),
|
||||
dict(proto="https" if use_ssl else "http", host=host, port=port))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
# from magnum.conf import api
|
||||
from magnum.conf import api
|
||||
# from magnum.conf import barbican
|
||||
# from magnum.conf import certificates
|
||||
# from magnum.conf import cinder
|
||||
|
@ -34,7 +34,7 @@ from oslo_config import cfg
|
|||
|
||||
CONF = cfg.CONF
|
||||
|
||||
# api.register_opts(CONF)
|
||||
api.register_opts(CONF)
|
||||
# barbican.register_opts(CONF)
|
||||
# cluster.register_opts(CONF)
|
||||
# cluster_templates.register_opts(CONF)
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
# 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
|
||||
|
||||
api_group = cfg.OptGroup(name='api',
|
||||
title='Options for the magnum-api service')
|
||||
|
||||
api_service_opts = [
|
||||
cfg.PortOpt('port',
|
||||
default=9511,
|
||||
help='The port for the Magnum API server.'),
|
||||
cfg.IPOpt('host',
|
||||
default='127.0.0.1',
|
||||
help='The listen IP for the Magnum API server.'),
|
||||
cfg.IntOpt('max_limit',
|
||||
default=1000,
|
||||
help='The maximum number of items returned in a single '
|
||||
'response from a collection resource.'),
|
||||
cfg.StrOpt('api_paste_config',
|
||||
default="api-paste.ini",
|
||||
help="Configuration file for WSGI definition of API."
|
||||
),
|
||||
cfg.StrOpt('ssl_cert_file',
|
||||
help="This option allows setting path to the SSL certificate "
|
||||
"of API server. "),
|
||||
cfg.StrOpt('ssl_key_file',
|
||||
help="This option specifies the path to the file where SSL "
|
||||
"private key of API server is stored when SSL is in "
|
||||
"effect. "),
|
||||
cfg.BoolOpt('enabled_ssl',
|
||||
default=False,
|
||||
help='Enable SSL Magnum API service')
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(api_group)
|
||||
conf.register_opts(api_service_opts, group=api_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
api_group: api_service_opts
|
||||
}
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
import itertools
|
||||
|
||||
import magnum.api.app
|
||||
import magnum.api.validation
|
||||
import magnum.common.cert_manager
|
||||
from magnum.common.cert_manager import local_cert_manager
|
||||
import magnum.common.clients
|
||||
import magnum.common.exception
|
||||
import magnum.common.rpc_service
|
||||
import magnum.common.service
|
||||
import magnum.common.x509.config
|
||||
import magnum.conductor.config
|
||||
|
@ -37,7 +37,6 @@ def list_opts():
|
|||
magnum.common.rpc_service.periodic_opts,
|
||||
magnum.common.service.service_opts,
|
||||
)),
|
||||
('api', magnum.api.app.API_SERVICE_OPTS),
|
||||
('cluster', magnum.drivers.common.template_def.template_def_opts),
|
||||
('conductor', magnum.conductor.config.SERVICE_OPTS),
|
||||
('database', magnum.db.sql_opts),
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
|
||||
import jsonpatch
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import wsme
|
||||
|
||||
from magnum.api import utils
|
||||
from magnum.common import exception
|
||||
import magnum.conf
|
||||
from magnum.tests.unit.api import base
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF = magnum.conf.CONF
|
||||
|
||||
|
||||
class TestApiUtils(base.FunctionalTest):
|
||||
|
|
Loading…
Reference in New Issue