Jonathan Hart

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

Fixes ONOS-2463.

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