From d4a1da37762a7b6e240ee5e9696838057e491216 Mon Sep 17 00:00:00 2001 From: Sawan Choudhary Date: Thu, 17 Sep 2020 06:34:39 +0000 Subject: [PATCH] Support Cloudpulse with WSGI Change-Id: Ibbe56daa10fa81559bd7b39104f58649be91d3c7 (cherry picked from commit fe39d727d8ca8de3e8887080123180368c029cbb) --- cloudpulse.wsgi | 5 +++++ cloudpulse/api/app.py | 17 +++++++++++++++++ cloudpulse/config.py | 3 +++ 3 files changed, 25 insertions(+) create mode 100755 cloudpulse.wsgi diff --git a/cloudpulse.wsgi b/cloudpulse.wsgi new file mode 100755 index 0000000..e1d67f0 --- /dev/null +++ b/cloudpulse.wsgi @@ -0,0 +1,5 @@ +# With wsgi the default config file will be read from +# /docker/cloudpulse/cloudpulse.conf + +from pecan.deploy import deploy +application = deploy('/cloudpulse/cloudpulse/config.py') diff --git a/cloudpulse/api/app.py b/cloudpulse/api/app.py index 2a33110..445a327 100644 --- a/cloudpulse/api/app.py +++ b/cloudpulse/api/app.py @@ -9,12 +9,16 @@ # 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 eventlet +eventlet.monkey_patch() from oslo_config import cfg import pecan +import sys from cloudpulse.api import auth from cloudpulse.api import config as api_config +from cloudpulse.api import hooks from cloudpulse.api import middleware from cloudpulse.common.timerthread import cpulseTimer from cloudpulse.common.timerthread import timerfunc @@ -63,11 +67,24 @@ def get_pecan_config(): def setup_app(config=None): + # It is recomended to run cloudpulse with the config file + # However with wsgi the default config file will be read from + # /docker/cloudpulse/cloudpulse.conf + if len(sys.argv) == 1: + cfg.CONF(["--config-file", "/docker/cloudpulse/cloudpulse.conf"], + project='cloudpulse') + if not config: config = get_pecan_config() app_conf = dict(config.app) + app_conf["hooks"] = [ + hooks.ContextHook(), + hooks.RPCHook(), + hooks.NoExceptionTracebackHook(), + ] + app = pecan.make_app( app_conf.pop('root'), logging=getattr(config, 'logging', {}), diff --git a/cloudpulse/config.py b/cloudpulse/config.py index fabe5f1..48bb7cd 100644 --- a/cloudpulse/config.py +++ b/cloudpulse/config.py @@ -31,6 +31,9 @@ app = { 'static_root': '%(confdir)s/public', 'template_path': '%(confdir)s/api/templates', 'debug': True, + 'acl_public_routes': [ + '/' + ], 'errors': { 404: '/error/404', '__force_dict__': True