Simon Hunt

GUI - Fixed reverse-link-id lookup issue for 'showTraffic'.

- removed obsolete 'showPath' code.

Change-Id: I5b7bdf9156b18022838b8f7ebc0e6d0846f9b20f
{
"event": "showPath",
"sid": 15,
"payload": {
"links": [
"62:4F:65:BF:FF:B3/-1/0-of:000000000000000b/1",
"of:000000000000000b/4-of:000000000000000a/1",
"of:000000000000000a/4-of:0000000000000001/3",
"of:0000000000000001/1-of:0000000000000002/4",
"of:0000000000000002/1-of:0000000000000003/4",
"of:0000000000000003/1-CA:4B:EE:A4:B0:33/-1/0"
],
"intentId": "0x52a914f9"
}
}
{
"event": "showPath",
"sid": 3,
"payload": {
"ids": [
"of:0000000000000007"
],
"traffic": true
}
}
// what is the client supposed to do with this?
{
"event": "showTraffic",
"sid": 11,
"payload": {
"paths": []
}
}
{
"event": "showTraffic",
"sid":62,
"payload": {
"paths": [
{
"class": "primary",
"traffic": false,
"links": [
"0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1",
"of:0000ffffffff0008/20-of:0000ffffffff0007/10",
"of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0"
],
"labels": [
"Load{rate=98, latest=38080}",
"Load{rate=98, latest=38080}",
"Load{rate=98, latest=38080}"
]
}
]
}
}
{
"event": "showTraffic",
"sid":63,
"payload": {
"paths": [
{
"class": "primary animated",
"traffic": true,
"links": [
"0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1",
"of:0000ffffffff0008/20-of:0000ffffffff0007/10",
"of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0"
],
"labels": [
"Load{rate=98, latest=38080}",
"Load{rate=98, latest=38080}",
"Load{rate=98, latest=38080}"
]
}
]
}
}
{
"event": "showTraffic",
"sid": 64,
"payload": {
"paths": []
}
}
......@@ -145,7 +145,8 @@
view: null, // view token reference
nodes: [],
links: [],
lookup: {}
lookup: {},
revLinkToKey: {}
},
scenario = {
evDir: 'json/ev/',
......@@ -423,6 +424,12 @@
return one + '-' + two;
}
function findLinkById(id) {
// check to see if this is a reverse lookup, else default to given id
var key = network.revLinkToKey[id] || id;
return key && network.lookup[key];
}
function findLink(linkData, op) {
var key = makeLinkKey(linkData),
keyrev = makeLinkKey(linkData, 1),
......@@ -476,10 +483,12 @@
ldata.key = keyrev;
delete network.lookup[key];
network.lookup[keyrev] = ldata;
delete network.revLinkToKey[keyrev];
}
} else {
// remove fromTarget
ldata.fromTarget = null;
delete network.revLinkToKey[keyrev];
}
if (ldata.fromSource) {
restyleLinkElement(ldata);
......@@ -496,6 +505,7 @@
function addLinkUpdate(ldata, link) {
// add link event, but we already have the reverse link installed
ldata.fromTarget = link;
network.revLinkToKey[link.id] = ldata.key;
restyleLinkElement(ldata);
}
......@@ -548,7 +558,6 @@
removeHost: removeHost,
showDetails: showDetails,
showPath: showPath,
showTraffic: showTraffic
};
......@@ -693,24 +702,6 @@
detailPane.show();
}
function showPath(data) {
// TODO: review - making sure we are handling the payload correctly.
evTrace(data);
var links = data.payload.links,
s = [ data.event + "\n" + links.length ];
links.forEach(function (d, i) {
s.push(d);
});
network.view.alert(s.join('\n'));
links.forEach(function (d, i) {
var link = network.lookup[d];
if (link) {
link.el.classed('showPath', true);
}
});
}
function showTraffic(data) {
evTrace(data);
var paths = data.payload.paths;
......@@ -722,7 +713,7 @@
paths.forEach(function (p) {
var cls = p.class;
p.links.forEach(function (id) {
var lnk = network.lookup[id];
var lnk = findLinkById(id);
if (lnk) {
lnk.el.classed(cls, true);
}
......