fix son-emu-cli network/monitor CLI
diff --git a/src/emuvim/api/rest/network.py b/src/emuvim/api/rest/network.py
index 1374373..28b5c66 100755
--- a/src/emuvim/api/rest/network.py
+++ b/src/emuvim/api/rest/network.py
@@ -38,7 +38,7 @@
import json
import networkx
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.INFO)
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
@@ -80,16 +80,19 @@
# 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")
diff --git a/src/emuvim/cli/rest/monitor.py b/src/emuvim/cli/rest/monitor.py
index 8be1e7f..3f95884 100755
--- a/src/emuvim/cli/rest/monitor.py
+++ b/src/emuvim/cli/rest/monitor.py
@@ -53,7 +53,7 @@
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 @@
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 @@
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 @@
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):
diff --git a/src/emuvim/cli/rest/network.py b/src/emuvim/cli/rest/network.py
index 44cba60..ac9f5fd 100755
--- a/src/emuvim/cli/rest/network.py
+++ b/src/emuvim/cli/rest/network.py
@@ -56,7 +56,7 @@
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 @@
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):