Skip to content
Snippets Groups Projects
Commit 0168c006 authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

[Not working commit] Migrate Invoker and Provider Management

parent 221d7369
1 merge request!61Ocf70 upgrade flask library to latest version
Pipeline #7590 passed with stages
in 4 minutes and 32 seconds
Showing
with 56 additions and 46 deletions
......@@ -2,10 +2,10 @@
import connexion
import logging
import encoder
import api_invoker_management.encoder
from flask_jwt_extended import JWTManager, jwt_required, create_access_token
from config import Config
from core.consumer_messager import Subscriber
from .config import Config
from .core.consumer_messager import Subscriber
from logging.handlers import RotatingFileHandler
import os
from fluent import sender
......@@ -116,11 +116,12 @@ def verbose_formatter():
with open("/usr/src/app/api_invoker_management/pubkey.pem", "rb") as pub_file:
pub_data = pub_file.read()
app = connexion.App(__name__, specification_dir='./openapi/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('openapi.yaml',
arguments={'title': 'CAPIF_API_Invoker_Management_API'},
pythonic_params=True)
# app = connexion.App(__name__, specification_dir='./openapi/')
app = connexion.App(__name__)
app.app.json_encoder = api_invoker_management.encoder.JSONEncoder
# app.add_api('openapi.yaml',
# arguments={'title': 'CAPIF_API_Invoker_Management_API'},
# pythonic_params=True)
app.app.config['JWT_ALGORITHM'] = 'RS256'
app.app.config['JWT_PUBLIC_KEY'] = pub_data
......@@ -138,6 +139,8 @@ if monitoring_value == "true":
executor = Executor(app.app)
subscriber = Subscriber()
@app.app.before_first_request
# @app.app.before_first_request
def create_listener_message():
executor.submit(subscriber.listen)
\ No newline at end of file
with app.app.app_context():
executor.submit(subscriber.listen)
\ No newline at end of file
from app import app
from .app import app
if __name__ == "__main__":
app.run()
......@@ -5,7 +5,7 @@ import os
class Config:
def __init__(self):
self.cached = 0
self.file="../config.yaml"
self.file="./config.yaml"
self.my_config = {}
stamp = os.stat(self.file).st_mtime
......
from abc import ABC, abstractmethod
from db.db import MongoDatabse
from api_invoker_management.db.db import MongoDatabse
class Resource(ABC):
......
import time
from pymongo import MongoClient
from pymongo.errors import AutoReconnect
from config import Config
from api_invoker_management.config import Config
from bson.codec_options import CodecOptions
import os
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
......
from connexion.apps.flask_app import FlaskJSONEncoder
# from connexion.apps.flask_app import FlaskJSONEncoder
from connexion.frameworks.flask import FlaskJSONProvider
import six
from models.base_model_ import Model
from .models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder):
class JSONEncoder(FlaskJSONProvider):
include_nulls = False
def default(self, o):
......@@ -17,4 +18,4 @@ class JSONEncoder(FlaskJSONEncoder):
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)
return FlaskJSONProvider.default(self, o)
import datetime
import six
import typing_utils
import api_invoker_management.typing_utils
def serialize_clean_camel_case(obj):
......
......@@ -14,5 +14,6 @@ curl -vv -k -retry 30 \
--request GET "$VAULT_ADDR/v1/secret/data/server_cert/pub" 2>/dev/null | jq -r '.data.data.pub_key' -j > /usr/src/app/api_invoker_management/pubkey.pem
gunicorn --bind 0.0.0.0:8080 \
--chdir /usr/src/app/api_invoker_management wsgi:app
\ No newline at end of file
#uvicorn --host 0.0.0.0:8080 \
# --root-path /usr/src/app/api_invoker_management asgi:app
uvicorn api_invoker_management.asgi:app --host 0.0.0.0 --port 8080 --reload
\ No newline at end of file
connexion[swagger-ui] == 2.14.2; python_version>="3.6"
connexion[flask] == 3.1.0; python_version>="3.6"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools == 68.2.2
Flask == 2.0.3
Flask == 3.0.3
pymongo == 4.7.3
flask_jwt_extended == 4.4.4
flask_jwt_extended == 4.6.0
cryptography == 42.0.8
rfc3987 == 1.3.8
redis == 4.5.4
......@@ -19,6 +19,6 @@ fluent-logger == 0.10.0
opentelemetry-api == 1.19.0
opentelemetry-sdk == 1.19.0
flask_executor == 1.0.0
Werkzeug == 2.2.3
gunicorn == 22.0.0
Werkzeug == 3.0.0
uvicorn == 0.30.3
packaging == 24.0
......@@ -2,11 +2,11 @@
import connexion
import logging
import api_provider_management.encoder
import encoder
from flask_jwt_extended import JWTManager
from logging.handlers import RotatingFileHandler
from config import Config
from .config import Config
import os
import sys
from fluent import sender
......@@ -114,10 +114,10 @@ with open("/usr/src/app/api_provider_management/pubkey.pem", "rb") as pub_file:
pub_data = pub_file.read()
app = connexion.App(__name__, specification_dir='./openapi/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('openapi.yaml',
arguments={'title': 'CAPIF_API_Provider_Management_API'},
pythonic_params=True)
app.app.json_encoder = api_provider_management.encoder.JSONEncoder
# app.add_api('openapi.yaml',
# arguments={'title': 'CAPIF_API_Provider_Management_API'},
# pythonic_params=True)
config = Config()
configure_logging(app.app)
......
from app import app
from api_provider_management.app import app
if __name__ == "__main__":
app.run()
......@@ -5,7 +5,7 @@ import os
class Config:
def __init__(self):
self.cached = 0
self.file="../config.yaml"
self.file="./config.yaml"
self.my_config = {}
stamp = os.stat(self.file).st_mtime
if stamp != self.cached:
......
from connexion.apps.flask_app import FlaskJSONEncoder
# from connexion.apps.flask_app import FlaskJSONEncoder
from connexion.frameworks.flask import FlaskJSONProvider
import six
from models.base_model_ import Model
from .models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder):
class JSONEncoder(FlaskJSONProvider):
include_nulls = False
def default(self, o):
......@@ -16,4 +17,4 @@ class JSONEncoder(FlaskJSONEncoder):
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)
return FlaskJSONProvider.default(self, o)
import datetime
import six
import typing_utils
import api_provider_management.typing_utils
def serialize_clean_camel_case(obj):
......
......@@ -13,7 +13,7 @@ curl -vv -k -retry 30 \
--request GET "$VAULT_ADDR/v1/secret/data/server_cert/pub" 2>/dev/null | jq -r '.data.data.pub_key' -j > /usr/src/app/api_provider_management/pubkey.pem
gunicorn --bind 0.0.0.0:8080 \
--chdir /usr/src/app/api_provider_management wsgi:app
#uvicorn --host 0.0.0.0:8080 \
# --root-path /usr/src/app/api_provider_management asgi:app
uvicorn api_provider_management.asgi:app --host 0.0.0.0 --port 8080 --reload
connexion[swagger-ui] == 2.14.2; python_version>="3.6"
connexion[flask] == 3.1.0; python_version>="3.6"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools == 68.2.2
Flask == 2.0.3
Flask == 3.0.3
pymongo == 4.7.3
redis == 4.5.4
flask_jwt_extended == 4.4.4
flask_jwt_extended == 4.6.0
cryptography == 42.0.8
rfc3987 == 1.3.8
opentelemetry-instrumentation == 0.38b0
......@@ -18,6 +18,6 @@ fluent-logger == 0.10.0
opentelemetry-api == 1.17.0
opentelemetry-sdk == 1.17.0
flask_executor == 1.0.0
Werkzeug == 2.2.3
gunicorn == 22.0.0
Werkzeug == 3.0.0
uvicorn == 0.30.3
packaging == 24.0
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment