Fixing reconciling hosts to regions
Change-Id: Ib4b2ff52a7530a60c7933194bd35f2f2d2d4f552
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java
index 8259fb3..cbb82b8 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java
@@ -545,9 +545,7 @@
RegionId rid = r.id();
UiRegion region = uiTopology.findRegion(rid);
if (region != null) {
- reconcileDevicesWithRegion(allDevices, r, rid, region);
- reconcileHostsWithRegion(allHosts, r, rid, region);
-
+ reconcileDevicesAndHostsWithRegion(allDevices, allHosts, rid, region);
} else {
log.warn("No UiRegion in topology for ID {}", rid);
}
@@ -567,37 +565,41 @@
uiTopology.computeSynthLinks();
}
- private void reconcileHostsWithRegion(Set<UiHost> allHosts, Region r,
- RegionId rid, UiRegion region) {
- Set<HostId> hostIds = services.region().getRegionHosts(rid);
- region.reconcileHosts(hostIds);
-
- hostIds.forEach(hid -> {
- UiHost h = uiTopology.findHost(hid);
- if (h != null) {
- h.setRegionId(r.id());
- allHosts.remove(h);
- } else {
- log.warn("Region host ID {} but no UiHost in topology", hid);
- }
- });
- }
-
- private void reconcileDevicesWithRegion(Set<UiDevice> allDevices, Region r,
- RegionId rid, UiRegion region) {
+ private void reconcileDevicesAndHostsWithRegion(Set<UiDevice> allDevices,
+ Set<UiHost> allHosts,
+ RegionId rid,
+ UiRegion region) {
Set<DeviceId> deviceIds = services.region().getRegionDevices(rid);
+ Set<HostId> hostIds = new HashSet<>();
region.reconcileDevices(deviceIds);
deviceIds.forEach(devId -> {
UiDevice dev = uiTopology.findDevice(devId);
if (dev != null) {
- dev.setRegionId(r.id());
+ dev.setRegionId(rid);
allDevices.remove(dev);
} else {
log.warn("Region device ID {} but no UiDevice in topology",
devId);
}
+
+ Set<Host> hosts = services.host().getConnectedHosts(devId);
+ for (Host h : hosts) {
+ HostId hid = h.id();
+ hostIds.add(hid);
+ UiHost host = uiTopology.findHost(hid);
+
+ if (host != null) {
+ host.setRegionId(rid);
+ allHosts.remove(host);
+ } else {
+ log.warn("Region host ID {} but no UiHost in topology",
+ hid);
+ }
+ }
});
+
+ region.reconcileHosts(hostIds);
}
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Link.js b/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
index 66e3bb5..f8f331c 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Link.js
@@ -95,11 +95,11 @@
function linkEndPoints(srcId, dstId) {
var allNodes = this.region.nodes();
- var sourceNode = this.region.findNodeById(srcId);
- var targetNode = this.region.findNodeById(dstId);
+ var sourceNode = this.region.findNodeById(this, srcId);
+ var targetNode = this.region.findNodeById(this, dstId);
if (!sourceNode || !targetNode) {
- $log.error('Node(s) not on map for link:' + srcId + ':' + dstId);
+ $log.error('Node(s) not on map for link:' + srcId + '~' + dstId);
// logicError('Node(s) not on map for link:\n' + sMiss + dMiss);
return null;
}
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Region.js b/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
index 29a7e68..bd24bbb 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Region.js
@@ -84,11 +84,14 @@
$log.debug('Region: ', region);
}
- function findNodeById(id) {
+ function findNodeById(link, id) {
- // Remove /{port} from id if needed
- var regex = new RegExp('^[^/]*');
- id = regex.exec(id)[0];
+
+ if (link.get('type') !== 'UiEdgeLink') {
+ // Remove /{port} from id if needed
+ var regex = new RegExp('^[^/]*');
+ id = regex.exec(id)[0];
+ }
return region.get('devices').get(id) ||
region.get('hosts').get(id) ||