[PMSH] Change Flask web server to Tornado web server 31/121331/1
authorantonys <antony.saputra@est.tech>
Wed, 12 May 2021 16:32:24 +0000 (17:32 +0100)
committerantonys <antony.saputra@est.tech>
Wed, 12 May 2021 16:32:32 +0000 (17:32 +0100)
  - Tornado is more suitable web server for production environment

Issue-ID: DCAEGEN2-2767
Change-Id: I81c65a3cc668cbd42132f23e908f12cec371ae66
Signed-off-by: antonys <antony.saputra@est.tech>
components/pm-subscription-handler/pmsh_service/mod/__init__.py
components/pm-subscription-handler/setup.py

index 505add0..5f78ca1 100644 (file)
@@ -1,5 +1,5 @@
 # ============LICENSE_START===================================================
-#  Copyright (C) 2019-2020 Nordix Foundation.
+#  Copyright (C) 2019-2021 Nordix Foundation.
 # ============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 # ============LICENSE_END=====================================================
 import logging as logging
 import os
+import ssl
 import pathlib
 from urllib.parse import quote
 
@@ -44,11 +45,13 @@ def launch_api_server(app_config):
     connex_app.add_api('api/pmsh_swagger.yml')
     if app_config.enable_tls:
         logger.info('Launching secure http API server')
+        ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
+        ssl_ctx.load_cert_chain(app_config.cert_params[0], app_config.cert_params[1])
         connex_app.run(port=os.environ.get('PMSH_API_PORT', '8443'),
-                       ssl_context=app_config.cert_params)
+                       ssl_options=ssl_ctx, server="tornado")
     else:
         logger.info('Launching unsecure http API server')
-        connex_app.run(port=os.environ.get('PMSH_API_PORT', '8443'))
+        connex_app.run(port=os.environ.get('PMSH_API_PORT', '8443'), server="tornado")
 
 
 def create_app():
index e4d3133..c11d133 100644 (file)
@@ -35,6 +35,7 @@ setup(
         "connexion==2.5.0",
         "flask_sqlalchemy==2.4.1",
         "Flask==1.1.1",
+        "tornado==6.1",
         "swagger-ui-bundle==0.0.6",
         "psycopg2-binary==2.8.6",
         "onap_dcae_cbs_docker_client==2.1.1",