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': '*'}
# 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")
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
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