Some corrections and enhancements for VOL-2620.

- getDeviceUplink method returns an optional. Result of the method
 was not treated as an Optional in some parts of IgmpManager service.
 These points are corrected.
- JSON device example is enriched.
- an obsolete method (provisionDefaultFlows) removed.

Change-Id: I60eb58c6f414c0935b743cb452b5da0e03d596f4
diff --git a/src/main/java/org/opencord/igmpproxy/IgmpManager.java b/src/main/java/org/opencord/igmpproxy/IgmpManager.java
index 1cdb55b..bb134d5 100644
--- a/src/main/java/org/opencord/igmpproxy/IgmpManager.java
+++ b/src/main/java/org/opencord/igmpproxy/IgmpManager.java
@@ -75,7 +75,6 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -480,10 +479,13 @@
                     }
 
                     IGMP igmp = (IGMP) ipv4Pkt.getPayload();
+
+                    Optional<PortNumber> deviceUpLinkOpt = getDeviceUplink(deviceId);
+                    PortNumber upLinkPort =  deviceUpLinkOpt.isPresent() ? deviceUpLinkOpt.get() : null;
                     switch (igmp.getIgmpType()) {
                         case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY:
                             //Discard Query from OLT’s non-uplink port’s
-                            if (!pkt.receivedFrom().port().equals(getDeviceUplink(deviceId))) {
+                            if (!pkt.receivedFrom().port().equals(upLinkPort)) {
                                 if (isConnectPoint(deviceId, pkt.receivedFrom().port())) {
                                     log.info("IGMP Picked up query from connectPoint");
                                     //OK to process packet
@@ -493,7 +495,7 @@
                                     break;
                                 } else {
                                     //Not OK to process packet
-                                    log.warn("IGMP Picked up query from non-uplink port");
+                                    log.warn("IGMP Picked up query from non-uplink port {}", upLinkPort);
                                     return;
                                 }
                             }
@@ -508,7 +510,7 @@
                         case IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT:
                         case IGMP.TYPE_IGMPV2_LEAVE_GROUP:
                             //Discard join/leave from OLT’s uplink port’s
-                            if (pkt.receivedFrom().port().equals(getDeviceUplink(deviceId)) ||
+                            if (pkt.receivedFrom().port().equals(upLinkPort) ||
                                     isConnectPoint(deviceId, pkt.receivedFrom().port())) {
                                 log.info("IGMP Picked up join/leave from uplink/connectPoint port");
                                 return;
@@ -625,8 +627,13 @@
             //port is not discovered by ONOS; so cannot validate it.
             return false;
         }
-        return port.annotations().value(AnnotationKeys.PORT_NAME) != null &&
+        boolean isValid = port.annotations().value(AnnotationKeys.PORT_NAME) != null &&
                 port.annotations().value(AnnotationKeys.PORT_NAME).startsWith(NNI_PREFIX);
+        if (!isValid) {
+            log.warn("Port cannot be validated; it is not configured as an NNI port." +
+                    "Device/port: {}/{}", deviceId, portNumber);
+        }
+        return isValid;
     }
 
     public static boolean isIgmpOnPodBasis() {
@@ -680,7 +687,11 @@
     }
 
     private boolean isUplink(DeviceId device, PortNumber port) {
-        return ((!connectPointMode) && getDeviceUplink(device).equals(port));
+        if (connectPointMode) {
+            return false;
+        }
+        Optional<PortNumber> upLinkPort = getDeviceUplink(device);
+        return upLinkPort.isPresent() && upLinkPort.get().equals(port);
     }
 
     /**
@@ -894,14 +905,6 @@
         }
     }
 
-    private void provisionDefaultFlows(DeviceId deviceId) {
-        List<Port> ports = deviceService.getPorts(deviceId);
-
-        ports.stream()
-                .filter(p -> (!getDeviceUplink(((Device) p.element()).id()).equals(p.number()) && p.isEnabled()))
-                .forEach(p -> processFilterObjective((DeviceId) p.element().id(), p.number(), false));
-    }
-
     private void provisionUplinkFlows(DeviceId deviceId) {
         if (connectPointMode) {
             return;