summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 21:25:03 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 21:25:03 +0000
commit6255254d65c173a55580d74539532060f6722b80 (patch)
treec394d40b8fd5d9ed686b091a123dc3865cc890ce
parente9cf9a4144aeff872dbfa82c33453812963984eb (diff)
parent5e260055faada3849340e4cd31227e6244c3af06 (diff)
Merge "Add pbr wsgi script entrypoint to glance"
-rw-r--r--glance/common/wsgi_app.py55
-rw-r--r--setup.cfg2
2 files changed, 57 insertions, 0 deletions
diff --git a/glance/common/wsgi_app.py b/glance/common/wsgi_app.py
new file mode 100644
index 0000000..7b621c5
--- /dev/null
+++ b/glance/common/wsgi_app.py
@@ -0,0 +1,55 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import os
14
15import glance_store
16from oslo_config import cfg
17from oslo_log import log as logging
18import osprofiler.initializer
19
20from glance.common import config
21from glance import notifier
22
23CONF = cfg.CONF
24CONF.import_group("profiler", "glance.common.wsgi")
25logging.register_options(CONF)
26
27CONFIG_FILES = ['glance-api-paste.ini', 'glance-api.conf']
28
29
30def _get_config_files(env=None):
31 if env is None:
32 env = os.environ
33 dirname = env.get('OS_GLANCE_CONFIG_DIR', '/etc/glance').strip()
34 return [os.path.join(dirname, config_file) for config_file in CONFIG_FILES]
35
36
37def _setup_os_profiler():
38 notifier.set_defaults()
39 if CONF.profiler.enabled:
40 osprofiler.initializer.init_from_conf(conf=CONF,
41 context={},
42 project='glance',
43 service='api',
44 host=CONF.bind_host)
45
46
47def init_app():
48 config_files = _get_config_files()
49 CONF([], project='glance', default_config_files=config_files)
50 logging.setup(CONF, "glance")
51 glance_store.register_opts(CONF)
52 glance_store.create_stores(CONF)
53 glance_store.verify_default_store()
54 _setup_os_profiler()
55 return config.load_paste_app('glance-api')
diff --git a/setup.cfg b/setup.cfg
index c8d6605..dab829f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -34,6 +34,8 @@ console_scripts =
34 glance-registry = glance.cmd.registry:main 34 glance-registry = glance.cmd.registry:main
35 glance-replicator = glance.cmd.replicator:main 35 glance-replicator = glance.cmd.replicator:main
36 glance-scrubber = glance.cmd.scrubber:main 36 glance-scrubber = glance.cmd.scrubber:main
37wsgi_scripts =
38 glance-wsgi-api = glance.common.wsgi_app:init_app
37glance.common.image_location_strategy.modules = 39glance.common.image_location_strategy.modules =
38 location_order_strategy = glance.common.location_strategy.location_order 40 location_order_strategy = glance.common.location_strategy.location_order
39 store_type_strategy = glance.common.location_strategy.store_type 41 store_type_strategy = glance.common.location_strategy.store_type