projects
/
osm
/
vim-emu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix son-emu-cli compatibility with son-emu REST API
[osm/vim-emu.git]
/
src
/
emuvim
/
api
/
rest
/
network.py
diff --git
a/src/emuvim/api/rest/network.py
b/src/emuvim/api/rest/network.py
index
65dddc4
..
f68507c
100755
(executable)
--- 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
from flask_restful import Resource
from flask import request
import json
+import networkx
-logging.basicConfig(level=logging.
INFO
)
+logging.basicConfig(level=logging.
DEBUG
)
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
@@
-79,17
+80,18
@@
class NetworkAction(Resource):
# call DCNetwork method, not really datacenter specific API for now...
# no check if vnfs are really connected to this datacenter...
try:
# 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.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:
if data is None:
- data = request.json
- # then no data
+ data = request.args
if data is None:
data = {}
if data is None:
data = {}
- 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")
vnf_src_name = data.get("vnf_src_name")
vnf_dst_name = data.get("vnf_dst_name")
vnf_src_interface = data.get("vnf_src_interface")
@@
-132,11
+134,12
@@
class DrawD3jsgraph(Resource):
nodes2 = list()
links = list()
# add all DCs
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)
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
nodes.append(node_dict)
# add links between other DCs