fix son-emu-cli monitor CLI
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:45:42 +0000 (16:45 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:45:42 +0000 (16:45 +0200)
src/emuvim/api/rest/monitor.py
src/emuvim/api/rest/network.py
src/emuvim/cli/rest/monitor.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 f68507c..bce10fc 100755 (executable)
@@ -81,10 +81,9 @@ class NetworkAction(Resource):
         # no check if vnfs are really connected to this datacenter...
         try:
             # check json payload
-            logging.info("json: {}".format(request.json))
-            logging.info("args: {}".format(request.args))
+            logging.debug("json: {}".format(request.json))
+            logging.debug("args: {}".format(request.args))
 
-            # when called directly with curl via REST
             data = request.json
             if data is None:
                 data = request.args
index 3f95884..8be1e7f 100755 (executable)
@@ -53,7 +53,7 @@ class RestApiClient():
             metric = args.get("metric"))
 
         url = "{0}/restapi/monitor/interface".format(args.get("endpoint"))
-        response = put(url, json=params)
+        response = put(url, params=params)
         pp.pprint(response.text)
 
     def stop_metric(self, args):
@@ -63,7 +63,7 @@ class RestApiClient():
             metric=args.get("metric"))
 
         url = "{0}/restapi/monitor/interface".format(args.get("endpoint"))
-        response = put(url, json=params)
+        response = put(url, params=params)
         pp.pprint(response.text)
 
     def setup_flow(self, args):
@@ -74,7 +74,7 @@ class RestApiClient():
             cookie=args.get("cookie"))
 
         url = "{0}/restapi/monitor/flow".format(args.get("endpoint"))
-        response = put(url, json=params)
+        response = put(url, params=params)
         pp.pprint(response.text)
 
     def stop_flow(self, args):
@@ -85,7 +85,7 @@ class RestApiClient():
             cookie=args.get("cookie"))
 
         url = "{0}/restapi/monitor/flow".format(args.get("endpoint"))
-        response = put(url, json=params)
+        response = put(url, params=params)
         pp.pprint(response.text)
 
     def prometheus(self, args):