From 284ba2b074eecf9cc46867b317d46ab95445b18e Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Thu, 1 Jun 2017 16:17:51 +0200 Subject: [PATCH] fix son-emu-cli network/monitor CLI --- src/emuvim/api/rest/network.py | 13 ++++++++----- src/emuvim/cli/rest/monitor.py | 8 ++++---- src/emuvim/cli/rest/network.py | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) 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 @@ 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") 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 @@ 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): 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 @@ 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): -- 2.25.1