Changed trivial core behaviour to claim switch as a master by default and to apply role to the switch.
diff --git a/net/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java b/net/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
new file mode 100644
index 0000000..fe2d34a
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/DefaultEdgeLink.java
@@ -0,0 +1,43 @@
+package org.onlab.onos.net;
+
+import org.onlab.onos.net.provider.ProviderId;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Default edge link model implementation.
+ */
+public class DefaultEdgeLink extends DefaultLink implements EdgeLink {
+
+ private final HostId hostId;
+ private final HostLocation hostLocation;
+
+ /**
+ * Creates an edge link using the supplied information.
+ *
+ * @param providerId provider identity
+ * @param hostPoint host-side connection point
+ * @param hostLocation location where host attaches to the network
+ * @param isIngress true to indicated host-to-network direction; false
+ * for network-to-host direction
+ */
+ public DefaultEdgeLink(ProviderId providerId, ConnectPoint hostPoint,
+ HostLocation hostLocation, boolean isIngress) {
+ super(providerId, isIngress ? hostLocation : hostPoint,
+ isIngress ? hostPoint : hostLocation, Type.EDGE);
+ checkArgument(hostPoint.elementId() instanceof HostId,
+ "Host point does not refer to a host ID");
+ this.hostId = (HostId) hostPoint.elementId();
+ this.hostLocation = hostLocation;
+ }
+
+ @Override
+ public HostId hostId() {
+ return hostId;
+ }
+
+ @Override
+ public ConnectPoint connectPoint() {
+ return hostLocation;
+ }
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/HostLinks.java b/net/api/src/main/java/org/onlab/onos/net/EdgeLink.java
similarity index 86%
rename from net/api/src/main/java/org/onlab/onos/net/HostLinks.java
rename to net/api/src/main/java/org/onlab/onos/net/EdgeLink.java
index eabbeb1..356592d3 100644
--- a/net/api/src/main/java/org/onlab/onos/net/HostLinks.java
+++ b/net/api/src/main/java/org/onlab/onos/net/EdgeLink.java
@@ -4,14 +4,14 @@
* Abstraction of a link between an end-station host and the network
* infrastructure.
*/
-public interface HostLinks extends Link {
+public interface EdgeLink extends Link {
/**
* Returns the host identification.
*
* @return host identifier
*/
- ElementId hostId();
+ HostId hostId();
/**
* Returns the connection point where the host attaches to the
diff --git a/net/api/src/main/java/org/onlab/onos/net/HostId.java b/net/api/src/main/java/org/onlab/onos/net/HostId.java
new file mode 100644
index 0000000..a7f550b
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/HostId.java
@@ -0,0 +1,33 @@
+package org.onlab.onos.net;
+
+import java.net.URI;
+
+/**
+ * Immutable representation of a host identity.
+ */
+public final class HostId extends ElementId {
+
+ // Public construction is prohibited
+ private HostId(URI uri) {
+ super(uri);
+ }
+
+ /**
+ * Creates a device id using the supplied URI.
+ *
+ * @param uri device URI
+ */
+ public static HostId hostId(URI uri) {
+ return new HostId(uri);
+ }
+
+ /**
+ * Creates a device id using the supplied URI string.
+ *
+ * @param string device URI string
+ */
+ public static HostId hostId(String string) {
+ return new HostId(URI.create(string));
+ }
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/Link.java b/net/api/src/main/java/org/onlab/onos/net/Link.java
index 0f4275e..0b60b9c 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Link.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Link.java
@@ -20,7 +20,12 @@
* links traversing optical paths, tunnels or intervening 'dark'
* switches.
*/
- INDIRECT
+ INDIRECT,
+
+ /**
+ * Signifies that this link is an edge, i.e. host link.
+ */
+ EDGE
}
/**