vfclcm upgrade from python2 to python3
[vfc/gvnfm/vnflcm.git] / lcm / lcm / middleware.py
index 7bf6868..5866deb 100644 (file)
@@ -19,6 +19,9 @@ from lcm.pub.config.config import FORWARDED_FOR_FIELDS, SERVICE_NAME
 class LogContextMiddleware(object):
     #  the last IP behind multiple proxies,  if no exist proxies
     #  get local host ip.
+    def __init__(self, get_response):
+        self.get_response = get_response
+
     def _getLastIp(self, request):
 
         ip = ""
@@ -41,10 +44,10 @@ class LogContextMiddleware(object):
 
     def process_request(self, request):
         # Fetch TRANSACTIONID Id and pass to plugin server
-        ReqeustID = request.META.get("HTTP_X_TRANSACTIONID", None)
+        ReqeustID = request.META.get("HTTP_X_ONAP-RequestID", None)
         if ReqeustID is None:
             ReqeustID = uuid.uuid3(uuid.NAMESPACE_URL, SERVICE_NAME)
-            request.META["HTTP_X_TRANSACTIONID"] = ReqeustID
+            request.META["HTTP_X_ONAP-RequestID"] = ReqeustID
         MDC.put("requestID", ReqeustID)
         # generate the unique  id
         InovocationID = uuid.uuid3(uuid.NAMESPACE_DNS, SERVICE_NAME)
@@ -58,3 +61,9 @@ class LogContextMiddleware(object):
     def process_response(self, request, response):
         MDC.clear()
         return response
+
+    def __call__(self, request):
+        self.process_request(request)
+        response = self.get_response(request)
+        self.process_response(request, response)
+        return response