[ONOS-7948] Netconf driver for Lumentum ROADM-20.
Added support for flowrules coming from the compilation of an OpticalConnectivityIntent.
FlowRules coming from ROADM app are still supported.
Minor updates to DeviceDiscovery and PowerConfig.

Patch 2: Driver and OpticalPathIntent support for partner-ports.
Now bidirectional intents can be configured also in presence of unidirectional links.
ROADM app visualizes devices of type TERMINAL_DEVICE and partner port details.
Checkstyle.

Patch 3: [ONOS-7974] [ONOS-79076] partner-port renamed to reverse-port. Bug fix.
Addressed comments by Ramon Casellas and Andrea Campanella. Checkstyles.

Patch 4: documentation.

Patch 5: addressed comments by Andrea Campanella.

Patch 6: checkstyle.

Change-Id: Ie5ca41eee6cb6f8f87f076f2af19c99cadd6d851
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
index d269843..f2a20fa 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
@@ -17,6 +17,12 @@
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.Port;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
@@ -24,11 +30,7 @@
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
 import org.onosproject.net.Device.Type;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.device.DeviceServiceAdapter;
 import org.onosproject.net.flow.DefaultFlowRule;
@@ -204,7 +206,7 @@
      */
     private List<FlowRule> createReverseRules(OpticalPathIntent intent) {
         TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-        selectorBuilder.matchInPort(intent.dst().port());
+        selectorBuilder.matchInPort(reversePort(intent.dst().deviceId(), intent.dst().port()));
 
         List<FlowRule> rules = new LinkedList<>();
 
@@ -219,7 +221,7 @@
             if (!isTransparent(intent.src().deviceId())) {
                 treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
             }
-            treatmentBuilder.setOutput(intent.src().port());
+            treatmentBuilder.setOutput(reversePort(intent.src().deviceId(), intent.src().port()));
 
             FlowRule rule = DefaultFlowRule.builder()
                     .forDevice(intent.src().deviceId())
@@ -240,7 +242,7 @@
             if (!isTransparent(current.deviceId())) {
                 treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
             }
-            treatmentBuilder.setOutput(link.dst().port());
+            treatmentBuilder.setOutput(reversePort(link.dst().deviceId(), link.dst().port()));
 
             FlowRule rule = DefaultFlowRule.builder()
                     .forDevice(current.deviceId())
@@ -257,7 +259,7 @@
             }
 
             current = link.src();
-            selectorBuilder.matchInPort(link.src().port());
+            selectorBuilder.matchInPort(reversePort(link.src().deviceId(), link.src().port()));
             if (!isTransparent(current.deviceId())) {
                 selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
                 selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
@@ -266,7 +268,7 @@
 
         // Build the egress ROADM rule
         TrafficTreatment.Builder treatmentLast = DefaultTrafficTreatment.builder();
-        treatmentLast.setOutput(intent.src().port());
+        treatmentLast.setOutput(reversePort(intent.src().deviceId(), intent.src().port()));
 
         FlowRule rule = new DefaultFlowRule.Builder()
                 .forDevice(intent.src().deviceId())
@@ -285,6 +287,25 @@
     }
 
     /**
+     * Returns the PortNum of reverse port if annotation is present, otherwise return PortNum of the port itself.
+     * In the OpenROADM YANG models it is used the term "partner-port.
+     *
+     * @param portNumber the port
+     * @return the PortNum of reverse port if annotation is present, otherwise PortNum of the port itself.
+     */
+    private PortNumber reversePort(DeviceId deviceId, PortNumber portNumber) {
+        Port port = deviceService.getPort(deviceId, portNumber);
+
+        String reversePort = port.annotations().value(OpticalPathIntent.REVERSE_PORT_ANNOTATION_KEY);
+        if (reversePort != null) {
+            PortNumber reversePortNumber = PortNumber.portNumber(reversePort);
+            return reversePortNumber;
+        } else {
+            return portNumber;
+        }
+    }
+
+    /**
      * Returns true if device does not accept flow rules, false otherwise.
      *
      * @param deviceId the device