Fixed issue with pushing topo JSON after devices are in the system.
Fixes ONOS-2463.
Ported from onos-1.2 branch.
Change-Id: I9ce7a11e50d8fd6c344be2f90dc046dcba65fe46
(cherry picked from commit 914c35212fd8af0b923ff560f9aa00deaf37ce3a)
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
index 13516bd..cc05bff 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
@@ -447,20 +447,26 @@
// Adds any missing device ports.
private void addMissingPorts(Device device) {
- List<Port> ports = deviceService.getPorts(device.id());
- Set<ConnectPoint> existing = ports.stream()
- .map(p -> new ConnectPoint(device.id(), p.number()))
- .collect(Collectors.toSet());
- Set<ConnectPoint> missing = connectPoints.stream()
- .filter(cp -> cp.deviceId().equals(device.id()))
- .filter(cp -> !existing.contains(cp))
- .collect(Collectors.toSet());
+ try {
+ List<Port> ports = deviceService.getPorts(device.id());
+ Set<ConnectPoint> existing = ports.stream()
+ .map(p -> new ConnectPoint(device.id(), p.number()))
+ .collect(Collectors.toSet());
+ Set<ConnectPoint> missing = connectPoints.stream()
+ .filter(cp -> cp.deviceId().equals(device.id()))
+ .filter(cp -> !existing.contains(cp))
+ .collect(Collectors.toSet());
- List<PortDescription> newPorts = Stream.concat(
- ports.stream().map(this::description),
- missing.stream().map(this::description)
- ).collect(Collectors.toList());
- deviceProviderService.updatePorts(device.id(), newPorts);
+ if (!missing.isEmpty()) {
+ List<PortDescription> newPorts = Stream.concat(
+ ports.stream().map(this::description),
+ missing.stream().map(this::description)
+ ).collect(Collectors.toList());
+ deviceProviderService.updatePorts(device.id(), newPorts);
+ }
+ } catch (IllegalArgumentException e) {
+ log.warn("Error pushing ports: {}", e.getMessage());
+ }
}
// Creates a port description from the specified port.