Fix latency constraint

1. Consider that the type "Duration" in the String is composed by
characters and numbers, it's not easy to convert it to double for
comparison, I modified the latency's annotation to
cfg.latency().toNanos().
2. Exclude two EdgeLinks for the calculation of the whole path's latency
3. The unit of latency in ONOS is not the same, so I set all the latency units to
nanoseconds.
4. Add the latency constraint option for ConnectivityIntentCommand.

Change-Id: Iddf5634880e43ed563db9978659db5eb9ee6c7f8
diff --git a/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
index 94ad04d..06959c4 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
@@ -62,7 +62,12 @@
     }
 
     private double cost(Link link) {
-        return getAnnotatedValue(link, LATENCY);
+        //Check only links, not EdgeLinks
+        if (link.type() != Link.Type.EDGE) {
+            return link.annotations().value(LATENCY) != null ? getAnnotatedValue(link, LATENCY) : 0;
+        } else {
+            return 0;
+        }
     }
 
     // doesn't use LinkResourceService
@@ -73,8 +78,9 @@
     }
 
     private boolean validate(Path path) {
+        //Guarantee all the latency units in ONOS is nanoseconds.
         double pathLatency = path.links().stream().mapToDouble(this::cost).sum();
-        return Duration.of((long) pathLatency, ChronoUnit.MICROS).compareTo(latency) <= 0;
+        return Duration.of((long) pathLatency, ChronoUnit.NANOS).compareTo(latency) <= 0;
     }
 
     @Override