Merge pull request #225 from stevenvanrossem/master
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 2 Jun 2017 06:14:50 +0000 (08:14 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 2 Jun 2017 06:14:50 +0000 (08:14 +0200)
fix son-emu-cli network/monitor CLI

src/emuvim/api/rest/monitor.py
src/emuvim/api/rest/network.py
src/emuvim/cli/rest/network.py

index eac10ef..30422c1 100755 (executable)
@@ -199,13 +199,16 @@ class MonitorLinkAction(Resource):
         # no check if vnfs are really connected to this datacenter...
 
         try:
-            # get URL parameters
-            data = request.args
-            #then no data
+            # check json payload
+            logging.debug("json: {}".format(request.json))
+            logging.debug("args: {}".format(request.args))
+
+            data = request.json
+            if data is None:
+                data = request.args
             if data is None:
                 data = {}
 
-
             vnf_src_name = data.get("vnf_src_name")
             vnf_dst_name = data.get("vnf_dst_name")
             vnf_src_interface = data.get("vnf_src_interface")
index 1374373..bce10fc 100755 (executable)
@@ -80,16 +80,17 @@ class NetworkAction(Resource):
         # call DCNetwork method, not really datacenter specific API for now...
         # no check if vnfs are really connected to this datacenter...
         try:
-            # check if json data is a dict
-            data = request.args
-            # try json payload
+            # check json payload
+            logging.debug("json: {}".format(request.json))
+            logging.debug("args: {}".format(request.args))
+
             data = request.json
-            # then no data
+            if data is None:
+                data = request.args
             if data is None:
                 data = {}
-            elif type(data) is not dict:
-                data = json.loads(request.json)
 
+            logging.info("data: {}".format(data))
             vnf_src_name = data.get("vnf_src_name")
             vnf_dst_name = data.get("vnf_dst_name")
             vnf_src_interface = data.get("vnf_src_interface")
index 44cba60..b4a1a89 100755 (executable)
@@ -72,7 +72,7 @@ class RestApiClient():
             priority=args.get("priority"))
 
         response = delete("{0}/restapi/network".format(args.get("endpoint")),
-                       params=params)
+                          params=params)
         pp.pprint(response.text)
 
     def _parse_vnf_name(self, vnf_name_str):