Generic Tunnel Subsystem (ONOS-1276) and L1/L0 (OTN/ROADM)extensions (ONOS-676):
1)Initial Work for ONOS-676: OTN/ROADM (L1/L0 NE) support in ONOS by extending the device/port modeling;
- extending device type to include L1 OTN NEs;
- extending port type to include ODUCLT port(T-port), OCH-port(L-port), OMS-port (WDM-port);
- more standard annotations related to OTN/ROADMs support will come from PCEP provider as well as TL1 providers;
2)Intial Work for ONOS-1276: generic Tunnel subsystem in ONOS for both packet (L3/L2) networks and optical (L1/L0) networks
- supporting PCEP framework, which is capable of interacting with the PCEP provider;
- supporting any other kind of tunnel provider;
- each Tunnel is associated with at least two Labels (abstracted logical entity/Id for virtualization of physical port);
- same type of Tunnels can be formed as a reachablity graph for other services and NB applications use;
Change-Id: I29af495f90e179e2c5d8753b76e02889a3b4355b
diff --git a/core/api/src/main/java/org/onosproject/net/tunnel/DefaultTunnel.java b/core/api/src/main/java/org/onosproject/net/tunnel/DefaultTunnel.java
new file mode 100644
index 0000000..c21a516
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/tunnel/DefaultTunnel.java
@@ -0,0 +1,168 @@
+package org.onosproject.net.tunnel;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Objects;
+
+import org.onosproject.core.IdGenerator;
+import org.onosproject.net.AbstractModel;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.net.resource.Bandwidth;
+
+/**
+ * Default tunnel model implementation.
+ */
+public final class DefaultTunnel extends AbstractModel implements Tunnel {
+ private final TunnelId id;
+ private final Label src;
+ private final Label dst;
+ private final Type type;
+ private final State state;
+ private final boolean isDurable;
+ private final boolean isBidirectional;
+ private final Bandwidth bandwidth;
+
+ /**
+ * Constructs an tunnel using the builder pattern.
+ *
+ * @param providerId provider identity, can be null if comes from the NB
+ * @param builder tunnelBuilder
+ * @param annotations optional key/value annotations
+ * @return
+ */
+ private DefaultTunnel(ProviderId providerId, TunnelBuilder builder, Annotations... annotations) {
+ super(providerId, annotations);
+ this.id = builder.id;
+ this.src = builder.src;
+ this.dst = builder.dst;
+ this.type = builder.type;
+ this.state = builder.state;
+ this.isDurable = builder.isDurable;
+ this.isBidirectional = builder.isBidirectional;
+ this.bandwidth = builder.bandwidth;
+ }
+
+ @Override
+ public TunnelId id() {
+ return id;
+ }
+
+ @Override
+ public Label src() {
+ return src;
+ }
+
+ @Override
+ public Label dst() {
+ return dst;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public State state() {
+ return state;
+ }
+
+ @Override
+ public boolean isDurable() {
+ return isDurable;
+ }
+
+ @Override
+ public boolean isBidirectional() {
+ return isBidirectional;
+ }
+
+ @Override
+ public Bandwidth bandwidth() {
+ return bandwidth;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ /**
+ * {@inheritDoc}
+ * Note that only TunnelId is considered on equality check.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultTunnel) {
+ final DefaultTunnel other = (DefaultTunnel) obj;
+ return Objects.equals(this.id, other.id);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("tunnelId", id)
+ .add("src", src)
+ .add("dst", dst)
+ .add("type", type)
+ .add("state", state)
+ .add("durable", isDurable)
+ .add("isBidirectional", isBidirectional)
+ .add("bandwidth", bandwidth)
+ .toString();
+ }
+
+ public static class TunnelBuilder {
+ private TunnelId id = null;
+ private Label src = null;
+ private Label dst = null;
+ private Type type = null;
+ private State state = null;
+ private boolean isDurable = false;
+ private boolean isBidirectional = false;
+ private Bandwidth bandwidth = null;
+
+ private static IdGenerator idGenerator;
+
+ public TunnelBuilder labelSrcDst(Label src, Label dst) {
+ this.src = src;
+ this.dst = dst;
+ return this;
+ }
+
+ public TunnelBuilder state(State state) {
+ this.state = state;
+ return this;
+ }
+
+ public TunnelBuilder isDurable(boolean isDurable) {
+ this.isDurable = isDurable;
+ return this;
+ }
+
+ public TunnelBuilder isBidirectional(boolean isBidirectional) {
+ this.isBidirectional = isBidirectional;
+ return this;
+ }
+
+ public TunnelBuilder bandwidth(Bandwidth bandwidth) {
+ this.bandwidth = bandwidth;
+ return this;
+ }
+
+ public DefaultTunnel build(ProviderId providerId, Annotations... annotations) {
+ checkState(idGenerator != null, "Id generator is not bound.");
+ this.id = TunnelId.valueOf(idGenerator.getNewId());
+ return new DefaultTunnel(providerId, this, annotations);
+ }
+
+ }
+
+}