X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Femuvim%2Fapi%2Frest%2Fnetwork.py;h=9aab1e606eda51ad56788f8ca2170866c8599b51;hb=c9abfbec5b0e0ae589c8ad66426e207fbe2385b1;hp=65dddc43ab53c07a14759ff2a6558c81954ca790;hpb=2542bfaa225f20272df99f1ccab5236326f16070;p=osm%2Fvim-emu.git diff --git a/src/emuvim/api/rest/network.py b/src/emuvim/api/rest/network.py index 65dddc4..9aab1e6 100755 --- a/src/emuvim/api/rest/network.py +++ b/src/emuvim/api/rest/network.py @@ -36,8 +36,9 @@ import logging from flask_restful import Resource from flask import request import json +import networkx -logging.basicConfig(level=logging.INFO) +logging.basicConfig() CORS_HEADER = {'Access-Control-Allow-Origin': '*'} @@ -79,16 +80,15 @@ 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)) + + data = request.json if data is None: - data = request.json - # then no data + data = request.args if data is None: data = {} - elif type(data) is not dict: - data = json.loads(request.json) vnf_src_name = data.get("vnf_src_name") vnf_dst_name = data.get("vnf_dst_name") @@ -132,11 +132,12 @@ class DrawD3jsgraph(Resource): nodes2 = list() links = list() # add all DCs - #for dc in net.dcs: + node_attr = networkx.get_node_attributes(net.DCNetwork_graph, 'type') for node_name in net.DCNetwork_graph.nodes(): nodes2.append(node_name) node_index = nodes2.index(node_name) - node_dict = {"name":node_name,"group":node_index} + type = node_attr[node_name] + node_dict = {"name":node_name,"group":type} nodes.append(node_dict) # add links between other DCs @@ -148,4 +149,4 @@ class DrawD3jsgraph(Resource): links.append(edge_dict) json = {"nodes":nodes, "links":links} - return json, 200, CORS_HEADER \ No newline at end of file + return json, 200, CORS_HEADER