From 912d24e50a30732a1f4664a4201bd79628c99360 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Sat, 25 Feb 2023 21:40:08 +0000
Subject: [PATCH] Tools - Mock MW SDN Ctrl:

- Added logs to investigate issue (POST seems not to work)
---
 .../tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py   | 29 ++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/tests/tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py b/src/tests/tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py
index f002d2376..d4aabbe5b 100644
--- a/src/tests/tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py
+++ b/src/tests/tools/mock_mw_sdn_ctrl/MockMWSdnCtrl.py
@@ -91,22 +91,37 @@ class Services(Resource):
         return jsonify({'ietf-eth-tran-service:etht-svc': {'etht-svc-instances': services}})
 
     def post(self):
+        LOGGER.info('[post] begin')
         try:
-            json_request = request.json
-            if not json_request: abort(400)
-            if not isinstance(json_request, dict): abort(400)
-            if 'etht-svc-instances' not in json_request: abort(400)
+            json_request = request.get_json()
+            LOGGER.info('[post] json_request={:s}'.format(str(json_request)))
+            if not json_request:
+                LOGGER.info('[post] abort 1')
+                abort(400)
+            if not isinstance(json_request, dict):
+                LOGGER.info('[post] abort 2')
+                abort(400)
+            if 'etht-svc-instances' not in json_request:
+                LOGGER.info('[post] abort 3')
+                abort(400)
             json_services = json_request['etht-svc-instances']
-            if not isinstance(json_services, list): abort(400)
-            if len(json_services) != 1: abort(400)
+            LOGGER.info('[post] json_services={:s}'.format(str(json_services)))
+            if not isinstance(json_services, list):
+                LOGGER.info('[post] abort 4')
+                abort(400)
+            if len(json_services) != 1:
+                LOGGER.info('[post] abort 5')
+                abort(400)
             svc_data = json_services[0]
+            LOGGER.info('[post] svc_data={:s}'.format(str(svc_data)))
             etht_svc_name = svc_data['etht-svc-name']
+            LOGGER.info('[post] etht_svc_name={:s}'.format(str(etht_svc_name)))
             NETWORK_SERVICES[etht_svc_name] = svc_data
+            LOGGER.info('[post] done')
             return jsonify({}), 201
         except:
             LOGGER.exception('Exception in POST')
 
-
 class DelServices(Resource):
     def delete(self, service_uuid : str):
         NETWORK_SERVICES.pop(service_uuid, None)
-- 
GitLab