From 4307eaa7d2cf3dbcf1eb25c7b2636aeaef13b6c7 Mon Sep 17 00:00:00 2001 From: Angie Wang Date: Wed, 15 Feb 2017 15:59:26 -0500 Subject: [PATCH 1/2] modify-aodh-api --- aodh/api/aodh-api.py | 7 +++++++ aodh/api/app.py | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 aodh/api/aodh-api.py diff --git a/aodh/api/aodh-api.py b/aodh/api/aodh-api.py new file mode 100644 index 0000000..565f2e3 --- /dev/null +++ b/aodh/api/aodh-api.py @@ -0,0 +1,7 @@ +from aodh.api import app as build_wsgi_app +import sys + +sys.argv = sys.argv[:1] +args = {'config_file' : 'etc/aodh/aodh.conf', } +application = build_wsgi_app.build_wsgi_app(None, args) + diff --git a/aodh/api/app.py b/aodh/api/app.py index b7c0900..ba0a438 100644 --- a/aodh/api/app.py +++ b/aodh/api/app.py @@ -53,7 +53,7 @@ def setup_app(root, conf): ) -def load_app(conf): +def load_app(conf, args): global APPCONFIGS # Build the WSGI app @@ -64,6 +64,12 @@ def load_app(conf): if cfg_path is None or not os.path.exists(cfg_path): raise cfg.ConfigFilesNotFoundError([conf.api.paste_config]) + config = dict([(key, value) for key, value in args.iteritems() + if key in conf and value is not None]) + for key, value in config.iteritems(): + if key == 'config_file': + conf.config_file = value + config = dict(conf=conf) configkey = str(uuid.uuid4()) APPCONFIGS[configkey] = config @@ -83,5 +89,5 @@ def app_factory(global_config, **local_conf): return setup_app(root=local_conf.get('root'), **appconfig) -def build_wsgi_app(argv=None): - return load_app(service.prepare_service(argv=argv)) +def build_wsgi_app(argv=None, args=None): + return load_app(service.prepare_service(argv=argv), args) -- 2.7.4