From 1085e7ee76191892a00a1b26f87a68cc468034b2 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Thu, 1 Jun 2017 16:37:52 +0200 Subject: [PATCH] fix son-emu-cli compatibility with son-emu REST API --- src/emuvim/api/rest/network.py | 11 +++++------ src/emuvim/cli/rest/network.py | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/emuvim/api/rest/network.py b/src/emuvim/api/rest/network.py index 28b5c66..f68507c 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.INFO) +logging.basicConfig(level=logging.DEBUG) CORS_HEADER = {'Access-Control-Allow-Origin': '*'} @@ -81,16 +81,15 @@ class NetworkAction(Resource): # no check if vnfs are really connected to this datacenter... try: # check json payload - logging.debug("json: {}".format(request.json)) - logging.debug("args: {}".format(request.args)) + logging.info("json: {}".format(request.json)) + logging.info("args: {}".format(request.args)) # when called directly with curl via REST data = request.json + if data is None: + data = request.args 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") diff --git a/src/emuvim/cli/rest/network.py b/src/emuvim/cli/rest/network.py index ac9f5fd..b4a1a89 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")), - json=params) + params=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")), - json=params) + params=params) pp.pprint(response.text) def _parse_vnf_name(self, vnf_name_str): -- 2.25.1