Added support for dual-homed hosts (on "classic" topo).
Change-Id: I47f4b3bf5756928452cbf99c4be2e3e1d6c8fa92
diff --git a/web/gui/src/main/webapp/app/view/topo/topoForce.js b/web/gui/src/main/webapp/app/view/topo/topoForce.js
index f3a2d0e..b4073a0 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoForce.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoForce.js
@@ -160,7 +160,7 @@
function addHost(data) {
var id = data.id,
- d, lnk;
+ d;
// although this is an add host event, if we already have the
// host, treat it as an update instead..
@@ -174,12 +174,28 @@
lu[id] = d;
updateNodes();
- lnk = tms.createHostLink(data);
- if (lnk) {
- d.linkData = lnk; // cache ref on its host
- network.links.push(lnk);
- lu[d.ingress] = lnk;
- lu[d.egress] = lnk;
+ function mkLinkKey(devId, devPort) {
+ return id + '/0-' + devId + '/' + devPort;
+ }
+
+ // need to handle possible multiple links (multi-homed host)
+ d.links = [];
+ data.allCps.forEach(function (cp) {
+ var linkData = {
+ key: mkLinkKey(cp.device, cp.port),
+ dst: cp.device,
+ dstPort: cp.port,
+ };
+ d.links.push(linkData);
+
+ var lnk = tms.createHostLink(id, cp.device, cp.port);
+ if (lnk) {
+ network.links.push(lnk);
+ lu[linkData.key] = lnk;
+ }
+ });
+
+ if (d.links.length) {
updateLinks();
}
fStart();
@@ -201,8 +217,10 @@
var id = data.id,
d = lu[id],
lnk;
+
if (d) {
// first remove the old host link
+ // FIXME: what if the host has multiple links??????
removeLinkElement(d.linkData);
// merge new data
@@ -212,12 +230,17 @@
}
// now create a new host link
- lnk = tms.createHostLink(data);
+ // TODO: verify this is the APPROPRIATE host link
+ lnk = tms.createHostLink(id, data.cp.device, data.cp.port);
if (lnk) {
- d.linkData = lnk;
network.links.push(lnk);
- lu[d.ingress] = lnk;
- lu[d.egress] = lnk;
+ lu[lnk.key] = lnk;
+
+ d.links.push({
+ key: id + '/0-' + cp.device + '/' + cp.port,
+ dst: data.cp.device,
+ dstPort: data.cp.port,
+ });
}
updateNodes();
diff --git a/web/gui/src/main/webapp/app/view/topo/topoModel.js b/web/gui/src/main/webapp/app/view/topo/topoModel.js
index caaf38b..2ef94a6 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoModel.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoModel.js
@@ -158,11 +158,9 @@
return node;
}
- function createHostLink(host) {
- var src = host.id,
- dst = host.cp.device,
- id = host.ingress,
- lnk = linkEndPoints(src, dst);
+ function createHostLink(hostId, devId, devPort) {
+ var linkKey = hostId + '/0-' + devId + '/' + devPort,
+ lnk = linkEndPoints(hostId, devId);
if (!lnk) {
return null;
@@ -170,10 +168,10 @@
// Synthesize link ...
angular.extend(lnk, {
- key: id,
+ key: linkKey,
class: 'link',
// NOTE: srcPort left undefined (host end of the link)
- tgtPort: host.cp.port,
+ tgtPort: devPort,
type: function () { return 'hostLink'; },
expected: function () { return true; },
diff --git a/web/gui/src/main/webapp/app/view/topo/topoSelect.js b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
index a0e8c31..d026e73 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoSelect.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
@@ -197,17 +197,15 @@
// special handling for links...
if (itemClass === 'link') {
payload.key = data.key;
+ payload.sourceId = data.source.id;
+ payload.targetId = data.target.id;
+ payload.targetPort = data.tgtPort;
+
if (data.source.class === 'host') {
payload.isEdgeLink = true;
- payload.sourceId = data.source.id;
- payload.targetId = data.source.cp.device;
- payload.targetPort = data.source.cp.port;
} else {
payload.isEdgeLink = false;
- payload.sourceId = data.source.id;
payload.sourcePort = data.srcPort;
- payload.targetId = data.target.id;
- payload.targetPort = data.tgtPort;
}
}