From b3774a4460c18802e87a0bf13e0166c51a709934 Mon Sep 17 00:00:00 2001 From: Macartur Sousa Date: Fri, 9 Mar 2018 15:40:12 -0300 Subject: [PATCH] Update to support new version of napps endpoints --- src/components/kytos/map/Map.vue | 4 ++-- src/components/kytos/switch/Interface.vue | 2 +- src/components/kytos/topology/Topology.vue | 26 +++++++++++++--------- src/kytos/switchInfo.vue | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/components/kytos/map/Map.vue b/src/components/kytos/map/Map.vue index 3443a1a..6d8cf8d 100644 --- a/src/components/kytos/map/Map.vue +++ b/src/components/kytos/map/Map.vue @@ -19,7 +19,7 @@ export default { map_zoom: 2, extraComponent: undefined, topology: { - url: this.$kytos_server_api + "kytos/topology/v2/", + url: this.$kytos_server_api + "kytos/topology/v3/", graph: null } } @@ -81,7 +81,7 @@ export default { this.$kytos.$emit("statusMessage", msg, true) throw error } else { - this.topology.graph = graph + this.topology.graph = graph.topology this.extraComponent = KytosTopology } }) diff --git a/src/components/kytos/switch/Interface.vue b/src/components/kytos/switch/Interface.vue index 632172d..56e7b56 100644 --- a/src/components/kytos/switch/Interface.vue +++ b/src/components/kytos/switch/Interface.vue @@ -62,7 +62,7 @@ export default { }, endpoint () { let url = this.$kytos_server_api + "kytos/of_stats/v1/" - return url + this.dpid + "/ports/" + this.port_number + return url + this.dpid + "/ports/" + Number(this.port_number) }, utilization_color_class: function () { if (this.speed === null) return '' diff --git a/src/components/kytos/topology/Topology.vue b/src/components/kytos/topology/Topology.vue index 573dc18..1c1c8eb 100644 --- a/src/components/kytos/topology/Topology.vue +++ b/src/components/kytos/topology/Topology.vue @@ -10,7 +10,7 @@ export default { props: ["map", "original_graph"], data () { return { - topology_url: this.$kytos_server_api + "kytos/topology/v2/", + topology_url: this.$kytos_server_api + "kytos/topology/v3/", map_container: undefined, graph: {}, svg: undefined, @@ -190,8 +190,8 @@ export default { b: "00:24:38:af:17:00:00:00:290" // Miami Pacific } } - - this.graph.links.forEach((link, index) => { + /** + $.each(this.graph.links,function( link_id, link) { if (link.a == atlantic_link.id || link.b == atlantic_link.id) { this.graph.links.splice(index, 1, atlantic_link.link1, atlantic_link.link2) } @@ -202,6 +202,7 @@ export default { this.graph.links.splice(index, 1, pacific_link.link1, pacific_link.link2) } }) + **/ }, update_graph_data () { this.graph = JSON.parse(JSON.stringify(this.original_graph)) // Make a copy @@ -211,16 +212,19 @@ export default { // have a link attached to it. let interfaces_with_links = [] - this.graph.links.forEach((link) => { - link.source = link.a - interfaces_with_links.push(link.a) - link.target= link.b - interfaces_with_links.push(link.b) + $.each(this.graph.links , function(link_id, link ){ + link.source = link.endpoint_a.id + interfaces_with_links.push(link.endpoint_a.id) + link.target= link.endpoint_b.id + interfaces_with_links.push(link.endpoint_b.id) link.type = "link" - link.id = this.fix_name(link.a) + "___" + this.fix_name(link.b) - }) + link.id = this.fix_name(link.endpoint_a.id) + "___" + + this.fix_name(link.endpoint_b.id) + }.bind(this)) + + this.graph.links = Object.values(this.graph.links) + this.graph.nodes = Object.values(this.graph.switches) - this.graph.nodes = Object.values(this.graph.devices) this.graph.nodes.forEach((node) => { if (node.type == "host"){ node.name = node.mac diff --git a/src/kytos/switchInfo.vue b/src/kytos/switchInfo.vue index 084bbcc..46e6aaa 100644 --- a/src/kytos/switchInfo.vue +++ b/src/kytos/switchInfo.vue @@ -69,7 +69,7 @@ export default { }, get_flows() { var dpid = this.metadata.dpid - var endpoint = this.$kytos_server_api + "kytos/flow_manager/v1/flows/" + dpid + var endpoint = this.$kytos_server_api + "kytos/flow_manager/v2/flows/" + dpid var self = this d3.json(endpoint, function(error, result) { self.flows = result[dpid].flows