[CORD-2856] Traffic on dual-homed hosts not properly highlighted
Change-Id: Iab6c99c7a6e8a33f1ffa0e31d52fd3e0d360676a
(cherry picked from commit 4f3236a9d3f5e595c29a1ba30da773d49078e64d)
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultEdgeLink.java b/core/api/src/main/java/org/onosproject/net/DefaultEdgeLink.java
index 3e1121e..7fe1ee3 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultEdgeLink.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultEdgeLink.java
@@ -15,8 +15,11 @@
*/
package org.onosproject.net;
+import com.google.common.collect.ImmutableSet;
import org.onosproject.net.provider.ProviderId;
+import java.util.Set;
+
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -95,4 +98,25 @@
host.location(), isIngress, host.annotations());
}
+ /**
+ * Creates edge links, to the specified end-station.
+ *
+ * The edge link inherits the target host annotations.
+ *
+ * @param host host
+ * @param isIngress true to indicate host-to-network direction; false
+ * for network-to-host direction
+ * @return new phantom edge link
+ */
+ public static Set<DefaultEdgeLink> createEdgeLinks(Host host, boolean isIngress) {
+ checkNotNull(host, "Host cannot be null");
+ ImmutableSet.Builder<DefaultEdgeLink> edgeLinksBuilder = ImmutableSet.builder();
+ host.locations().forEach(
+ location -> edgeLinksBuilder.add(new DefaultEdgeLink(ProviderId.NONE,
+ new ConnectPoint(host.id(), PortNumber.P0),
+ location, isIngress, host.annotations()))
+ );
+ return edgeLinksBuilder.build();
+ }
+
}