Jonathan Hart

Fixed issue with pushing topo JSON after devices are in the system.

Fixes ONOS-2463.

Change-Id: I9ce7a11e50d8fd6c344be2f90dc046dcba65fe46
......@@ -447,6 +447,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
// Adds any missing device ports.
private void addMissingPorts(Device device) {
try {
List<Port> ports = deviceService.getPorts(device.id());
Set<ConnectPoint> existing = ports.stream()
.map(p -> new ConnectPoint(device.id(), p.number()))
......@@ -456,12 +457,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
.filter(cp -> !existing.contains(cp))
.collect(Collectors.toSet());
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.
private PortDescription description(Port p) {
......