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 { ...@@ -447,6 +447,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
447 447
448 // Adds any missing device ports. 448 // Adds any missing device ports.
449 private void addMissingPorts(Device device) { 449 private void addMissingPorts(Device device) {
450 + try {
450 List<Port> ports = deviceService.getPorts(device.id()); 451 List<Port> ports = deviceService.getPorts(device.id());
451 Set<ConnectPoint> existing = ports.stream() 452 Set<ConnectPoint> existing = ports.stream()
452 .map(p -> new ConnectPoint(device.id(), p.number())) 453 .map(p -> new ConnectPoint(device.id(), p.number()))
...@@ -456,12 +457,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { ...@@ -456,12 +457,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
456 .filter(cp -> !existing.contains(cp)) 457 .filter(cp -> !existing.contains(cp))
457 .collect(Collectors.toSet()); 458 .collect(Collectors.toSet());
458 459
460 + if (!missing.isEmpty()) {
459 List<PortDescription> newPorts = Stream.concat( 461 List<PortDescription> newPorts = Stream.concat(
460 ports.stream().map(this::description), 462 ports.stream().map(this::description),
461 missing.stream().map(this::description) 463 missing.stream().map(this::description)
462 ).collect(Collectors.toList()); 464 ).collect(Collectors.toList());
463 deviceProviderService.updatePorts(device.id(), newPorts); 465 deviceProviderService.updatePorts(device.id(), newPorts);
464 } 466 }
467 + } catch (IllegalArgumentException e) {
468 + log.warn("Error pushing ports: {}", e.getMessage());
469 + }
470 + }
465 471
466 // Creates a port description from the specified port. 472 // Creates a port description from the specified port.
467 private PortDescription description(Port p) { 473 private PortDescription description(Port p) {
......