Add pbr wsgi script entrypoint to glance
This commit adds a pbr entrypoint for the wsgi script file. This enables deploying glance as a proper wsgi application instead of a standalone service. Change-Id: I089a22a4be4227a551c32442dba27c426f54c87d
This commit is contained in:
parent
c09d157960
commit
5e260055fa
55
glance/common/wsgi_app.py
Normal file
55
glance/common/wsgi_app.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import glance_store
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
import osprofiler.initializer
|
||||||
|
|
||||||
|
from glance.common import config
|
||||||
|
from glance import notifier
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.import_group("profiler", "glance.common.wsgi")
|
||||||
|
logging.register_options(CONF)
|
||||||
|
|
||||||
|
CONFIG_FILES = ['glance-api-paste.ini', 'glance-api.conf']
|
||||||
|
|
||||||
|
|
||||||
|
def _get_config_files(env=None):
|
||||||
|
if env is None:
|
||||||
|
env = os.environ
|
||||||
|
dirname = env.get('OS_GLANCE_CONFIG_DIR', '/etc/glance').strip()
|
||||||
|
return [os.path.join(dirname, config_file) for config_file in CONFIG_FILES]
|
||||||
|
|
||||||
|
|
||||||
|
def _setup_os_profiler():
|
||||||
|
notifier.set_defaults()
|
||||||
|
if CONF.profiler.enabled:
|
||||||
|
osprofiler.initializer.init_from_conf(conf=CONF,
|
||||||
|
context={},
|
||||||
|
project='glance',
|
||||||
|
service='api',
|
||||||
|
host=CONF.bind_host)
|
||||||
|
|
||||||
|
|
||||||
|
def init_app():
|
||||||
|
config_files = _get_config_files()
|
||||||
|
CONF([], project='glance', default_config_files=config_files)
|
||||||
|
logging.setup(CONF, "glance")
|
||||||
|
glance_store.register_opts(CONF)
|
||||||
|
glance_store.create_stores(CONF)
|
||||||
|
glance_store.verify_default_store()
|
||||||
|
_setup_os_profiler()
|
||||||
|
return config.load_paste_app('glance-api')
|
@ -34,6 +34,8 @@ console_scripts =
|
|||||||
glance-registry = glance.cmd.registry:main
|
glance-registry = glance.cmd.registry:main
|
||||||
glance-replicator = glance.cmd.replicator:main
|
glance-replicator = glance.cmd.replicator:main
|
||||||
glance-scrubber = glance.cmd.scrubber:main
|
glance-scrubber = glance.cmd.scrubber:main
|
||||||
|
wsgi_scripts =
|
||||||
|
glance-wsgi-api = glance.common.wsgi_app:init_app
|
||||||
glance.common.image_location_strategy.modules =
|
glance.common.image_location_strategy.modules =
|
||||||
location_order_strategy = glance.common.location_strategy.location_order
|
location_order_strategy = glance.common.location_strategy.location_order
|
||||||
store_type_strategy = glance.common.location_strategy.store_type
|
store_type_strategy = glance.common.location_strategy.store_type
|
||||||
|
Loading…
Reference in New Issue
Block a user