Use pbr wsgi_scripts feature to build ceilometer-api
Change-Id: I8812ea1a92d6dc7f41a490e971bb7a09dee9b304
This commit is contained in:
parent
6d301dd952
commit
2d09bce4da
|
@ -1,36 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright 2012 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
|
|
||||||
|
|
||||||
# Register options for the service
|
|
||||||
OPTS = [
|
|
||||||
cfg.PortOpt('port',
|
|
||||||
default=8777,
|
|
||||||
deprecated_name='metering_api_port',
|
|
||||||
deprecated_group='DEFAULT',
|
|
||||||
help='The port for the ceilometer API server.',
|
|
||||||
),
|
|
||||||
cfg.StrOpt('host',
|
|
||||||
default='0.0.0.0',
|
|
||||||
help='The listen IP for the ceilometer API server.',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
|
||||||
opt_group = cfg.OptGroup(name='api',
|
|
||||||
title='Options for the ceilometer-api service')
|
|
||||||
CONF.register_group(opt_group)
|
|
||||||
CONF.register_opts(OPTS, opt_group)
|
|
|
@ -1,5 +1,6 @@
|
||||||
#
|
#
|
||||||
# Copyright 2012 New Dream Network, LLC (DreamHost)
|
# Copyright 2012 New Dream Network, LLC (DreamHost)
|
||||||
|
# Copyright 2015-2016 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
@ -19,11 +20,9 @@ from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from paste import deploy
|
from paste import deploy
|
||||||
import pecan
|
import pecan
|
||||||
from werkzeug import serving
|
|
||||||
|
|
||||||
from ceilometer.api import hooks
|
from ceilometer.api import hooks
|
||||||
from ceilometer.api import middleware
|
from ceilometer.api import middleware
|
||||||
from ceilometer.i18n import _LI, _LW
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -67,16 +66,9 @@ def setup_app(pecan_config=None):
|
||||||
|
|
||||||
pecan.configuration.set_config(dict(pecan_config), overwrite=True)
|
pecan.configuration.set_config(dict(pecan_config), overwrite=True)
|
||||||
|
|
||||||
# NOTE(sileht): pecan debug won't work in multi-process environment
|
|
||||||
pecan_debug = CONF.api.pecan_debug
|
|
||||||
if CONF.api.workers and CONF.api.workers != 1 and pecan_debug:
|
|
||||||
pecan_debug = False
|
|
||||||
LOG.warning(_LW('pecan_debug cannot be enabled, if workers is > 1, '
|
|
||||||
'the value is overrided with False'))
|
|
||||||
|
|
||||||
app = pecan.make_app(
|
app = pecan.make_app(
|
||||||
pecan_config['app']['root'],
|
pecan_config['app']['root'],
|
||||||
debug=pecan_debug,
|
debug=CONF.api.pecan_debug,
|
||||||
hooks=app_hooks,
|
hooks=app_hooks,
|
||||||
wrap_app=middleware.ParsableErrorMiddleware,
|
wrap_app=middleware.ParsableErrorMiddleware,
|
||||||
guess_content_type_from_ext=False
|
guess_content_type_from_ext=False
|
||||||
|
@ -100,26 +92,5 @@ def load_app():
|
||||||
return deploy.loadapp("config:" + cfg_file)
|
return deploy.loadapp("config:" + cfg_file)
|
||||||
|
|
||||||
|
|
||||||
def build_server():
|
|
||||||
app = load_app()
|
|
||||||
# Create the WSGI server and start it
|
|
||||||
host, port = cfg.CONF.api.host, cfg.CONF.api.port
|
|
||||||
|
|
||||||
LOG.info(_LI('Starting server in PID %s'), os.getpid())
|
|
||||||
LOG.info(_LI("Configuration:"))
|
|
||||||
cfg.CONF.log_opt_values(LOG, log.INFO)
|
|
||||||
|
|
||||||
if host == '0.0.0.0':
|
|
||||||
LOG.info(_LI(
|
|
||||||
'serving on 0.0.0.0:%(sport)s, view at http://127.0.0.1:%(vport)s')
|
|
||||||
% ({'sport': port, 'vport': port}))
|
|
||||||
else:
|
|
||||||
LOG.info(_LI("serving on http://%(host)s:%(port)s") % (
|
|
||||||
{'host': host, 'port': port}))
|
|
||||||
|
|
||||||
serving.run_simple(cfg.CONF.api.host, cfg.CONF.api.port,
|
|
||||||
app, processes=CONF.api.workers)
|
|
||||||
|
|
||||||
|
|
||||||
def app_factory(global_config, **local_conf):
|
def app_factory(global_config, **local_conf):
|
||||||
return setup_app()
|
return setup_app()
|
||||||
|
|
|
@ -16,7 +16,6 @@ import itertools
|
||||||
from keystoneauth1 import loading
|
from keystoneauth1 import loading
|
||||||
|
|
||||||
import ceilometer.agent.manager
|
import ceilometer.agent.manager
|
||||||
import ceilometer.api
|
|
||||||
import ceilometer.api.app
|
import ceilometer.api.app
|
||||||
import ceilometer.cmd.polling
|
import ceilometer.cmd.polling
|
||||||
import ceilometer.collector
|
import ceilometer.collector
|
||||||
|
@ -76,10 +75,7 @@ def list_opts():
|
||||||
ceilometer.sample.OPTS,
|
ceilometer.sample.OPTS,
|
||||||
ceilometer.service.OPTS,
|
ceilometer.service.OPTS,
|
||||||
ceilometer.utils.OPTS,)),
|
ceilometer.utils.OPTS,)),
|
||||||
('api',
|
('api', ceilometer.api.app.API_OPTS),
|
||||||
itertools.chain(ceilometer.api.OPTS,
|
|
||||||
ceilometer.api.app.API_OPTS,
|
|
||||||
[ceilometer.service.API_OPT])),
|
|
||||||
('collector',
|
('collector',
|
||||||
itertools.chain(ceilometer.collector.OPTS,
|
itertools.chain(ceilometer.collector.OPTS,
|
||||||
[ceilometer.service.COLL_OPT])),
|
[ceilometer.service.COLL_OPT])),
|
||||||
|
|
|
@ -40,14 +40,6 @@ OPTS = [
|
||||||
]
|
]
|
||||||
cfg.CONF.register_opts(OPTS)
|
cfg.CONF.register_opts(OPTS)
|
||||||
|
|
||||||
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',
|
NOTI_OPT = cfg.IntOpt('workers',
|
||||||
default=1,
|
default=1,
|
||||||
min=1,
|
min=1,
|
||||||
|
|
|
@ -34,25 +34,3 @@ class TestApp(base.BaseTestCase):
|
||||||
with mock.patch.object(self.CONF, 'find_file') as ff:
|
with mock.patch.object(self.CONF, 'find_file') as ff:
|
||||||
ff.return_value = None
|
ff.return_value = None
|
||||||
self.assertRaises(cfg.ConfigFilesNotFoundError, app.load_app)
|
self.assertRaises(cfg.ConfigFilesNotFoundError, app.load_app)
|
||||||
|
|
||||||
@mock.patch('ceilometer.storage.get_connection_from_config',
|
|
||||||
mock.MagicMock())
|
|
||||||
@mock.patch('pecan.make_app')
|
|
||||||
def test_pecan_debug(self, mocked):
|
|
||||||
def _check_pecan_debug(g_debug, p_debug, expected, workers=1):
|
|
||||||
self.CONF.set_override('debug', g_debug)
|
|
||||||
if p_debug is not None:
|
|
||||||
self.CONF.set_override('pecan_debug', p_debug, group='api')
|
|
||||||
self.CONF.set_override('workers', workers, group='api')
|
|
||||||
app.setup_app()
|
|
||||||
args, kwargs = mocked.call_args
|
|
||||||
self.assertEqual(expected, kwargs.get('debug'))
|
|
||||||
|
|
||||||
_check_pecan_debug(g_debug=False, p_debug=None, expected=False)
|
|
||||||
_check_pecan_debug(g_debug=True, p_debug=None, expected=False)
|
|
||||||
_check_pecan_debug(g_debug=True, p_debug=False, expected=False)
|
|
||||||
_check_pecan_debug(g_debug=False, p_debug=True, expected=True)
|
|
||||||
_check_pecan_debug(g_debug=True, p_debug=None, expected=False,
|
|
||||||
workers=5)
|
|
||||||
_check_pecan_debug(g_debug=False, p_debug=True, expected=False,
|
|
||||||
workers=5)
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ SQLAlchemy<1.1.0,>=1.0.10 # MIT
|
||||||
sqlalchemy-migrate>=0.9.6 # Apache-2.0
|
sqlalchemy-migrate>=0.9.6 # Apache-2.0
|
||||||
stevedore>=1.9.0 # Apache-2.0
|
stevedore>=1.9.0 # Apache-2.0
|
||||||
tooz>=1.28.0 # Apache-2.0
|
tooz>=1.28.0 # Apache-2.0
|
||||||
Werkzeug>=0.7 # BSD License
|
|
||||||
WebOb>=1.2.3 # MIT
|
WebOb>=1.2.3 # MIT
|
||||||
WSME>=0.8 # MIT
|
WSME>=0.8 # MIT
|
||||||
# NOTE(jd) We do not import it directly, but WSME datetime string parsing
|
# NOTE(jd) We do not import it directly, but WSME datetime string parsing
|
||||||
|
|
|
@ -252,6 +252,8 @@ ceilometer.event.trait_plugin =
|
||||||
bitfield = ceilometer.event.trait_plugins:BitfieldTraitPlugin
|
bitfield = ceilometer.event.trait_plugins:BitfieldTraitPlugin
|
||||||
timedelta = ceilometer.event.trait_plugins:TimedeltaPlugin
|
timedelta = ceilometer.event.trait_plugins:TimedeltaPlugin
|
||||||
|
|
||||||
|
wsgi_scripts =
|
||||||
|
ceilometer-api = ceilometer.api.app:load_app
|
||||||
|
|
||||||
console_scripts =
|
console_scripts =
|
||||||
ceilometer-api = ceilometer.cmd.api:main
|
ceilometer-api = ceilometer.cmd.api:main
|
||||||
|
|
Loading…
Reference in New Issue