support bidirectional links

Change-Id: I6c5d092abf7629b28ea0b1928ee6cf63f99de962
diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
index cfdeb1f..285e4a5 100644
--- a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
+++ b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
@@ -290,6 +290,17 @@
             linkProviderService.linkDetected(linkDescription);
             log.info(String.format("WDM link: %s : %s",
                     linkDescription.src().toString(), linkDescription.dst().toString()));
+
+
+            DefaultLinkDescription linkDescriptionReverse =
+                    new DefaultLinkDescription(snkPoint,
+                                                 srcPoint,
+                                                 Link.Type.OPTICAL,
+                                                 extendedAttributes);
+
+            linkProviderService.linkDetected(linkDescriptionReverse);
+            log.info(String.format("WDM link: %s : %s",
+                    linkDescriptionReverse.src().toString(), linkDescriptionReverse.dst().toString()));
         }
 
         // Discover the packet optical link objects
@@ -321,6 +332,16 @@
             linkProviderService.linkDetected(linkDescription);
             log.info(String.format("Packet-optical link: %s : %s",
                     linkDescription.src().toString(), linkDescription.dst().toString()));
+
+            DefaultLinkDescription linkDescriptionReverse =
+                    new DefaultLinkDescription(snkPoint,
+                                                 srcPoint,
+                                                 Link.Type.OPTICAL,
+                                                 extendedAttributes);
+
+            linkProviderService.linkDetected(linkDescriptionReverse);
+            log.info(String.format("Packet-optical link: %s : %s",
+                    linkDescriptionReverse.src().toString(), linkDescriptionReverse.dst().toString()));
         }
 
     }
diff --git a/apps/optical/src/main/resources/demo-3-roadm-2-ps.json b/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
index 20b7db2..d4f4a14 100644
--- a/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
+++ b/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
@@ -47,42 +47,14 @@
                 "nodeName1": "ROADM1",
                 "nodeName2": "ROADM3",
                 "numWaves": 80,
-                "port1": 10,
+                "port1": 20,
                 "port2": 30
             },
             "type": "wdmLink"
         },
-        {
-            "allowed": true,
-            "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
-            "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01",
-            "params": {
-                "distKms": 1000,
-                "nodeName1": "ROADM3",
-                "nodeName2": "ROADM1",
-                "numWaves": 80,
-                "port1": 30,
-                "port2": 10
-            },
-            "type": "wdmLink"
-        },
 
         {
             "allowed": true,
-            "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
-            "nodeDpid2": "00:00:ff:ff:ff:ff:ff:03",
-            "params": {
-                "distKms": 2000,
-                "nodeName1": "ROADM2",
-                "nodeName2": "ROADM3",
-                "numWaves": 80,
-                "port1": 20,
-                "port2": 31
-            },
-            "type": "wdmLink"
-        },
-        {
-            "allowed": true,
             "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
             "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
             "params": {
@@ -91,7 +63,7 @@
                 "nodeName2": "ROADM2",
                 "numWaves": 80,
                 "port1": 31,
-                "port2": 20
+                "port2": 21
             },
             "type": "wdmLink"
         },
@@ -104,20 +76,7 @@
                 "nodeName1": "ROUTER1",
                 "nodeName2": "ROADM1",
                 "bandWidth": 100000,
-                "port1": 10,
-                "port2": 11
-            },
-            "type": "pktOptLink"
-        },
-        {
-            "allowed": true,
-            "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01",
-            "nodeDpid2": "00:00:ff:ff:ff:ff:00:01",
-            "params": {
-                "nodeName1": "ROADM1",
-                "nodeName2": "ROUTER1",
-                "bandWidth": 100000,
-                "port1": 11,
+                "port1": 1,
                 "port2": 10
             },
             "type": "pktOptLink"
@@ -131,24 +90,11 @@
                 "nodeName1": "ROUTER2",
                 "nodeName2": "ROADM2",
                 "bandWidth": 100000,
-                "port1": 10,
-                "port2": 21
+                "port1": 1,
+                "port2": 11
             },
             "type": "pktOptLink"
         },
-        {
-            "allowed": true,
-            "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
-            "nodeDpid2": "00:00:ff:ff:ff:ff:00:02",
-            "params": {
-                "nodeName1": "ROADM2",
-                "nodeName2": "ROUTER2",
-                "bandWidth": 100000,
-                "port1": 21,
-                "port2": 10
-            },
-            "type": "pktOptLink"
-        }
 
     ]
 }
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
index 58586dc..b76cc3b 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
@@ -70,6 +70,7 @@
     public List<Intent> compile(OpticalConnectivityIntent intent) {
         // TODO: compute multiple paths using the K-shortest path algorithm
         List<Intent> retList = new ArrayList<>();
+        log.info("The system is comipling the OpticalConnectivityIntent:" + intent.toString());
         Path path = calculatePath(intent.getSrcConnectPoint(), intent.getDst());
         if (path == null) {
             return retList;
@@ -88,6 +89,8 @@
                 intent.getDst(),
                 path);
 
+        log.info("a new OpticalPathIntent was created: " + newIntent.toString());
+
         retList.add(newIntent);
 
         return retList;
@@ -123,6 +126,7 @@
         Iterator<Path> itr = paths.iterator();
         while (itr.hasNext()) {
             Path path = itr.next();
+            // log.info(String.format("total link number.:%d", path.links().size()));
             if (path.cost() >= 10000) {
                 itr.remove();
             }
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
index 64ac3ea..5557b05 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
@@ -116,6 +116,7 @@
                     appId,
                     100,
                     true);
+
             rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule));
 
             prev = link.dst();