From: stevenvanrossem Date: Wed, 3 May 2017 22:01:52 +0000 (+0200) Subject: update dashboard, to display placement, colored by node type X-Git-Tag: v3.1~30^2~7 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f371201f8a205911398ee81359b30afcba526038;p=osm%2Fvim-emu.git update dashboard, to display placement, colored by node type --- diff --git a/src/emuvim/api/rest/network.py b/src/emuvim/api/rest/network.py index 65dddc4..84db87e 100755 --- a/src/emuvim/api/rest/network.py +++ b/src/emuvim/api/rest/network.py @@ -36,6 +36,7 @@ import logging from flask_restful import Resource from flask import request import json +import networkx logging.basicConfig(level=logging.INFO) @@ -132,11 +133,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 diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index a7f0a6c..a57a6b9 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -259,7 +259,7 @@ class Service(object): # last step: remove the instance from the list of all instances del self.instances[instance_uuid] - def _start_vnfd(self, vnfd, vnf_id): + def _start_vnfd(self, vnfd, vnf_id, **kwargs): """ Start a single VNFD of this service :param vnfd: vnfd descriptor dict @@ -352,7 +352,8 @@ class Service(object): cpu_period=cpu_period, cpuset=cpu_list, mem_limit=mem_lim, - volumes=volumes) + volumes=volumes, + type=kwargs.get('type','docker')) # rename the docker0 interfaces (eth0) to the management port name defined in the VNFD if USE_DOCKER_MGMT: @@ -546,7 +547,7 @@ class Service(object): if sap["type"] == "internal": vnfi = None if not GK_STANDALONE_MODE: - vnfi = self._start_vnfd(sap, sap['name']) + vnfi = self._start_vnfd(sap, sap['name'], type='sap_int') self.instances[instance_uuid]["vnf_instances"].append(vnfi) elif sap["type"] == "external": diff --git a/src/emuvim/dashboard/index_upb.html b/src/emuvim/dashboard/index_upb.html index c5224bf..485a6b1 100755 --- a/src/emuvim/dashboard/index_upb.html +++ b/src/emuvim/dashboard/index_upb.html @@ -100,11 +100,6 @@ -
- - -
- diff --git a/src/emuvim/dashboard/js/d3.v3.min.js b/src/emuvim/dashboard/js/d3.v3.min.js old mode 100644 new mode 100755 diff --git a/src/emuvim/dashboard/js/graph.js b/src/emuvim/dashboard/js/graph.js old mode 100644 new mode 100755 index bc10d39..9b28e11 --- a/src/emuvim/dashboard/js/graph.js +++ b/src/emuvim/dashboard/js/graph.js @@ -1,6 +1,6 @@ var width = 960, height = 500, - color = d3.scale.category20c(); + color = d3.scale.category10(); var svg = d3.select("#table_graph").append("svg") .attr("width", width) @@ -40,7 +40,7 @@ d3.json("http://127.0.0.1:5001/restapi/network/d3jsgraph", function(error, json) // .attr("height", 16); node.append("circle") .attr("r", 10) - .style("fill", function(d) { return color(d.name); }); + .style("fill", function(d) { return color(d.group); }); node.append("text") .attr("dx", 12) diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index 418ab20..faae0e3 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -240,16 +240,33 @@ class DCNetwork(Containernet): """ Wrapper for addDocker method to use custom container class. """ - self.DCNetwork_graph.add_node(label) + self.DCNetwork_graph.add_node(label, type=params.get('type', 'docker')) return Containernet.addDocker(self, label, cls=EmulatorCompute, **params) - def removeDocker( self, label, **params ): + def removeDocker( self, label, **params): """ Wrapper for removeDocker method to update graph. """ self.DCNetwork_graph.remove_node(label) return Containernet.removeDocker(self, label, **params) + def addExtSAP(self, sap_name, sap_ip, **params): + """ + Wrapper for addExtSAP method to store SAP also in graph. + """ + # make sure that 'type' is set + params['type'] = params.get('type','sap_ext') + self.DCNetwork_graph.add_node(sap_name, type=params['type']) + LOG.info('add ext sap: {0}'.format(sap_name)) + return Containernet.addExtSAP(self, sap_name, sap_ip, **params) + + def removeExtSAP(self, sap_name, **params): + """ + Wrapper for removeExtSAP method to remove SAP also from graph. + """ + self.DCNetwork_graph.remove_node(sap_name) + return Containernet.removeExtSAP(self, sap_name) + def addSwitch( self, name, add_to_graph=True, **params ): """ Wrapper for addSwitch method to store switch also in graph. @@ -257,7 +274,8 @@ class DCNetwork(Containernet): # add this switch to the global topology overview if add_to_graph: - self.DCNetwork_graph.add_node(name) + self.DCNetwork_graph.add_node(name, type=params.get('type','switch')) + LOG.info('*** **** *** add switch: {0} type: {1}'.format(name, params.get('type'))) # set the learning switch behavior if 'failMode' in params : @@ -267,12 +285,6 @@ class DCNetwork(Containernet): s = Containernet.addSwitch(self, name, protocols='OpenFlow10,OpenFlow12,OpenFlow13', failMode=failMode, **params) - # set flow entry that enables learning switch behavior (needed to enable E-LAN functionality) - #LOG.info('failmode {0}'.format(failMode)) - #if failMode == 'standalone' : - # LOG.info('add NORMAL') - # s.dpctl('add-flow', 'actions=NORMAL') - return s def getAllContainers(self):