Corrected the access layout to work even when there are no HAG spines.
Change-Id: Ic5a8d26974b78afc19d3fcc463150083706a64ae
diff --git a/apps/layout/src/main/java/org/onosproject/layout/AccessNetworkLayout.java b/apps/layout/src/main/java/org/onosproject/layout/AccessNetworkLayout.java
index 104861c..5aa7fcd 100644
--- a/apps/layout/src/main/java/org/onosproject/layout/AccessNetworkLayout.java
+++ b/apps/layout/src/main/java/org/onosproject/layout/AccessNetworkLayout.java
@@ -157,24 +157,30 @@
aggregation = 1;
accessLeaf = 1;
- spines.stream().sorted(Comparators.ELEMENT_ID_COMPARATOR).forEach(id -> {
- place(id, c(aggregation++, spines.size()), AGGREGATION_Y);
- linkService.getDeviceEgressLinks(id).stream()
- .map(l -> l.dst().deviceId())
- .filter(leaves::contains)
- .filter(lid -> !placed.contains(lid))
- .sorted(Comparators.ELEMENT_ID_COMPARATOR)
- .forEach(lid -> {
- double x = c(accessLeaf++, leaves.size());
- place(lid, x, ACCESS_Y);
- placed.add(lid);
- placeHostBlock(hostService.getConnectedHosts(lid).stream()
- .map(Host::id)
- .sorted(Comparators.ELEMENT_ID_COMPARATOR)
- .collect(Collectors.toList()), x, HOSTS_Y,
- HOSTS_PER_ROW, ROW_GAP, COL_GAP);
- });
- });
+ if (spines.isEmpty()) {
+ leaves.forEach(lid -> placeAccessLeafAndHosts(lid, leaves.size(), placed));
+ } else {
+ spines.stream().sorted(Comparators.ELEMENT_ID_COMPARATOR).forEach(id -> {
+ place(id, c(aggregation++, spines.size()), AGGREGATION_Y);
+ linkService.getDeviceEgressLinks(id).stream()
+ .map(l -> l.dst().deviceId())
+ .filter(leaves::contains)
+ .filter(lid -> !placed.contains(lid))
+ .sorted(Comparators.ELEMENT_ID_COMPARATOR)
+ .forEach(lid -> placeAccessLeafAndHosts(lid, leaves.size(), placed));
+ });
+ }
+ }
+
+ private void placeAccessLeafAndHosts(DeviceId leafId, int leafCount, Set<DeviceId> placed) {
+ double x = c(accessLeaf++, leafCount);
+ place(leafId, x, ACCESS_Y);
+ placed.add(leafId);
+ placeHostBlock(hostService.getConnectedHosts(leafId).stream()
+ .map(Host::id)
+ .sorted(Comparators.ELEMENT_ID_COMPARATOR)
+ .collect(Collectors.toList()), x, HOSTS_Y,
+ HOSTS_PER_ROW, ROW_GAP, COL_GAP);
}
}