CORD-2917 Should not push packet requests that target specific device to all devices
Change-Id: I1ee4c39c358d7ae0ac6bb0ecdc3ea471f5082ac1
diff --git a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
index 657ca48..6be6c54 100644
--- a/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
+++ b/core/net/src/main/java/org/onosproject/net/packet/impl/PacketManager.java
@@ -131,7 +131,18 @@
store.setDelegate(delegate);
deviceService.addListener(deviceListener);
defaultProvider.init(deviceService);
- store.existingRequests().forEach(this::pushToAllDevices);
+ store.existingRequests().forEach(request -> {
+ if (request.deviceId().isPresent()) {
+ Device device = deviceService.getDevice(request.deviceId().get());
+ if (device != null) {
+ pushRule(device, request);
+ } else {
+ log.info("Device is not ready yet. Skip processing packet requests {}", request);
+ }
+ } else {
+ pushToAllDevices(request);
+ }
+ });
log.info("Started");
}