fix son-emu-cli network/monitor CLI
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:17:51 +0000 (16:17 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 1 Jun 2017 14:17:51 +0000 (16:17 +0200)
src/emuvim/api/rest/network.py
src/emuvim/cli/rest/monitor.py
src/emuvim/cli/rest/network.py

index 1374373..28b5c66 100755 (executable)
@@ -38,7 +38,7 @@ from flask import request
 import json
 import networkx
 
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.INFO)
 
 CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
 
@@ -80,16 +80,19 @@ 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))
+
+            # when called directly with curl via REST
             data = request.json
-            # then no data
             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")
             vnf_dst_name = data.get("vnf_dst_name")
             vnf_src_interface = data.get("vnf_src_interface")
index 8be1e7f..3f95884 100755 (executable)
@@ -53,7 +53,7 @@ class RestApiClient():
             metric = args.get("metric"))
 
         url = "{0}/restapi/monitor/interface".format(args.get("endpoint"))
-        response = put(url, params=params)
+        response = put(url, json=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, params=params)
+        response = put(url, json=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, params=params)
+        response = put(url, json=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, params=params)
+        response = put(url, json=params)
         pp.pprint(response.text)
 
     def prometheus(self, args):
index 44cba60..ac9f5fd 100755 (executable)
@@ -56,7 +56,7 @@ class RestApiClient():
             priority=args.get("priority"))
 
         response = put("{0}/restapi/network".format(args.get("endpoint")),
-                       params=params)
+                       json=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")),
-                       params=params)
+                       json=params)
         pp.pprint(response.text)
 
     def _parse_vnf_name(self, vnf_name_str):