fix son-emu-cli compatibility with son-emu REST API
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:37:52 +0000 (16:37 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:37:52 +0000 (16:37 +0200)
src/emuvim/api/rest/network.py
src/emuvim/cli/rest/network.py

index 28b5c66..f68507c 100755 (executable)
@@ -38,7 +38,7 @@ from flask import request
 import json
 import networkx
 
-logging.basicConfig(level=logging.INFO)
+logging.basicConfig(level=logging.DEBUG)
 
 CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
 
@@ -81,16 +81,15 @@ class NetworkAction(Resource):
         # no check if vnfs are really connected to this datacenter...
         try:
             # check json payload
-            logging.debug("json: {}".format(request.json))
-            logging.debug("args: {}".format(request.args))
+            logging.info("json: {}".format(request.json))
+            logging.info("args: {}".format(request.args))
 
             # when called directly with curl via REST
             data = request.json
+            if data is None:
+                data = request.args
             if data is None:
                 data = {}
-            # check if json data is a dict
-            elif type(data) is not dict:
-                data = json.loads(request.json)
 
             logging.info("data: {}".format(data))
             vnf_src_name = data.get("vnf_src_name")
index ac9f5fd..b4a1a89 100755 (executable)
@@ -56,7 +56,7 @@ class RestApiClient():
             priority=args.get("priority"))
 
         response = put("{0}/restapi/network".format(args.get("endpoint")),
-                       json=params)
+                       params=params)
         pp.pprint(response.text)
 
     def remove(self, args):
@@ -72,7 +72,7 @@ class RestApiClient():
             priority=args.get("priority"))
 
         response = delete("{0}/restapi/network".format(args.get("endpoint")),
-                       json=params)
+                          params=params)
         pp.pprint(response.text)
 
     def _parse_vnf_name(self, vnf_name_str):