summaryrefslogtreecommitdiffstats
path: root/osdfapp.py
diff options
context:
space:
mode:
authorvrvarma <vv8305@att.com>2019-11-05 20:35:54 -0500
committervrvarma <vv8305@att.com>2019-11-06 00:04:39 -0500
commit15a847b3bebd604113414938c1345fe47b2c51b5 (patch)
tree5dc392be5f19b794b3c4d3fcfc7eb3f611138a30 /osdfapp.py
parent20d6ef66c107f9c01c9594edfde6ac0ca5faf7f2 (diff)
Add onap log spec 1.2 for osdf
OPTFRA-319 OPTFRA-607 and OPTFRA-629 included in this fix Change-Id: Ieeeaa0417ffa41360d790c01b0ef1404960e6b6a Signed-off-by: vrvarma <vv8305@att.com> Issue-ID: OPTFRA-319
Diffstat (limited to 'osdfapp.py')
-rwxr-xr-xosdfapp.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/osdfapp.py b/osdfapp.py
index b8afbf4..1cfb8a3 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -23,15 +23,19 @@ OSDF Manager Main Flask Application
import json
import ssl
import sys
+import time
import traceback
from optparse import OptionParser
from threading import Thread # for scaling up, may need celery with RabbitMQ or redis
import pydevd
+import yaml
from flask import Flask, request, Response, g
from requests import RequestException
from schematics.exceptions import DataError
+yaml.warnings({'YAMLLoadWarning': False})
+
import osdf.adapters.aaf.sms as sms
import osdf.operation.responses
from osdf.adapters.policy.interface import get_policies
@@ -47,6 +51,7 @@ from osdf.optimizers.pciopt.pci_opt_processor import process_pci_optimation
from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt
from osdf.optimizers.routeopt.simple_route_opt import RouteOpt
from osdf.utils import api_data_utils
+from osdf.utils.mdc_utils import clear_mdc, mdc_from_json
from osdf.webapp.appcontroller import auth_basic
ERROR_TEMPLATE = osdf.ERROR_TEMPLATE
@@ -96,6 +101,20 @@ def handle_data_error(e):
return response
+@app.before_request
+def log_request():
+ g.request_start = time.clock()
+ request_json = request.get_json()
+ g.request_id = request_json['requestInfo']['requestId']
+ mdc_from_json(request_json)
+
+
+@app.after_request
+def log_response(response):
+ clear_mdc()
+ return response
+
+
@app.route("/api/oof/v1/healthcheck", methods=["GET"])
def do_osdf_health_check():
"""Simple health check"""