wei wei
Committed by Gerrit Code Review

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
Showing 23 changed files with 1778 additions and 23 deletions
......@@ -26,7 +26,7 @@ public interface Device extends Element {
* Coarse classification of the type of the infrastructure device.
*/
public enum Type {
SWITCH, ROUTER, ROADM, FIREWALL, BALANCER, IPS, IDS, CONTROLLER, OTHER
SWITCH, ROUTER, ROADM, OTN, FIREWALL, BALANCER, IPS, IDS, CONTROLLER, OTHER
}
/**
......@@ -34,6 +34,7 @@ public interface Device extends Element {
*
* @return device id
*/
@Override
DeviceId id();
/**
......
......@@ -44,12 +44,12 @@ public interface Link extends Annotated, Provided, NetworkResource {
/**
* Signifies that this link represents a logical link backed by
* some form of a tunnel.
* some form of a tunnel, e.g., GRE, MPLS, ODUk, OCH.
*/
TUNNEL,
/**
* Signifies that this link is realized by optical connection.
* Signifies that this link is realized by fiber (either single channel or WDM).
*/
OPTICAL
}
......
......@@ -31,7 +31,30 @@ public interface Port extends Annotated {
/**
* Signifies optical fiber-based connectivity.
*/
FIBER
FIBER,
/**
* Signifies optical fiber-based packet port.
*/
PACKET,
/**
* Signifies optical fiber-based optical tributary port (called T-port).
* The signal from the client side will be formed into a ITU G.709 (OTN) frame.
*/
ODUCLT,
/**
* Signifies optical fiber-based Line-side port (called L-port).
*/
OCH,
/**
* Signifies optical fiber-based WDM port (called W-port).
* Optical Multiplexing Section (See ITU G.709).
*/
OMS
}
/**
......
package org.onosproject.net.tunnel;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
import java.util.Optional;
import org.onosproject.net.AbstractModel;
import org.onosproject.net.Annotations;
import org.onosproject.net.ElementId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
/**
* Default label model implementation.
*/
public class DefaultLabel extends AbstractModel implements Label {
private final Optional<ElementId> elementId;
private final Optional<PortNumber> portNumber;
private final Optional<Label> parentLabel;
private final Type type;
private final LabelId id;
private final boolean isGlobal;
/**
* Creates a label attributed to the specified provider (may be null).
* if provider is null, which means the label is not managed by the SB.
*
* @param elementId parent network element
* @param number port number
* @param parentLabel parent port or parent label
* @param type port type
* @param id LabelId
* @param isGlobal indicator whether the label is global significant or not
* @param annotations optional key/value annotations
*/
public DefaultLabel(ProviderId providerId, Optional<ElementId> elementId,
Optional<PortNumber> number, Optional<Label> parentLabel,
Type type, LabelId id, boolean isGlobal, Annotations... annotations) {
super(providerId, annotations);
this.elementId = elementId;
this.portNumber = number;
this.parentLabel = parentLabel;
this.id = id;
this.type = type;
this.isGlobal = isGlobal;
}
@Override
public LabelId id() {
return id;
}
@Override
public Optional<ElementId> elementId() {
return elementId;
}
@Override
public Optional<PortNumber> portNumber() {
return portNumber;
}
@Override
public Optional<Label> parentLabel() {
return parentLabel;
}
@Override
public boolean isGlobal() {
return isGlobal;
}
@Override
public Type type() {
return type;
}
@Override
public int hashCode() {
return Objects.hash(elementId, portNumber, parentLabel, id);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof DefaultLabel) {
final DefaultLabel other = (DefaultLabel) obj;
return Objects.equals(this.id, other.id) &&
Objects.equals(this.type, other.type) &&
Objects.equals(this.isGlobal, other.isGlobal) &&
Objects.equals(this.elementId, other.elementId) &&
Objects.equals(this.portNumber, other.portNumber) &&
Objects.equals(this.parentLabel, other.parentLabel);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this)
.add("elementId", elementId)
.add("portNumber", portNumber)
.add("parentLabel", parentLabel)
.add("type", type)
.add("id", id)
.add("isGlobal", isGlobal)
.toString();
}
}
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);
}
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import com.google.common.base.MoreObjects;
import org.onosproject.net.AbstractDescription;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.SparseAnnotations;
/**
* Default implementation of immutable tunnel description entity.
*/
public class DefaultTunnelDescription extends AbstractDescription
implements TunnelDescription {
private final TunnelId tunnelId;
private final ConnectPoint src;
private final ConnectPoint dst;
private final Tunnel.Type type;
private final boolean isBidirectional;
/**
* Creates a tunnel description using the supplied information.
*
* @param id TunnelId
* @param src ConnectPoint source
* @param dst ConnectPoint destination
* @param type tunnel type
* @param isBidirectional boolean
* @param annotations optional key/value annotations
*/
public DefaultTunnelDescription(TunnelId id, ConnectPoint src, ConnectPoint dst,
Tunnel.Type type, boolean isBidirectional,
SparseAnnotations... annotations) {
super(annotations);
this.tunnelId = id;
this.src = src;
this.dst = dst;
this.type = type;
this.isBidirectional = isBidirectional;
}
@Override
public TunnelId id() {
return tunnelId;
}
@Override
public ConnectPoint src() {
return src;
}
@Override
public ConnectPoint dst() {
return dst;
}
@Override
public Tunnel.Type type() {
return type;
}
@Override
public boolean isBidirectional() {
return isBidirectional;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("tunnelId", id())
.add("src", src())
.add("dst", dst())
.add("type", type())
.add("isBidirectional", isBidirectional())
.toString();
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import java.util.Optional;
import org.onosproject.net.Annotated;
import org.onosproject.net.ElementId;
import org.onosproject.net.NetworkResource;
import org.onosproject.net.PortNumber;
import org.onosproject.net.Provided;
/**
* Generic representation of a logical port entity in a consistent way,
* it is used to identify e.g., VLAN#, MPLS label#, ODUk timeSlot, WDM lambda, etc.
* It supports nested case.
*/
public interface Label extends Annotated, Provided, NetworkResource {
/** Represents coarse Label type classification. */
public enum Type {
/**
* Signifies VLAN-based tag.
*/
VLAN,
/**
* Signifies LAG-based label.
*/
LAG,
/**
* Signifies MPLS-based label.
*/
MPLS,
/**
* Signifies IP-based label.
*/
IP,
/**
* Signifies optical data unit-based label.
*/
TIMESLOT,
/**
* Signifies optical wavelength-based label.
*/
LAMBDA,
/**
* Signifies device-based identifier for the label.
*/
DEVICE
}
/**
* Returns the identifier to this Label.
*
* @return identifier
*/
LabelId id();
/**
* Returns the parent network element to which this label belongs.
*
* @return parent network element
*/
Optional<ElementId> elementId();
/**
* Returns the parent network port to which this label belongs, can not be be null.
*
* @return port number
*/
Optional<PortNumber> portNumber();
/**
* Returns the parent label to which this label belongs, optional.
*
* @return parent label, if it is null, the parent is a physical port
*/
Optional<Label> parentLabel();
/**
* Indicates whether or not the port is global significant.
*
* @return true if the port is global significant
*/
boolean isGlobal();
/**
* Returns the label type.
*
* @return label type
*/
Type type();
}
\ No newline at end of file
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import java.util.Objects;
import com.google.common.primitives.UnsignedLongs;
/**
* Representation of a label Id, a logical port identifier.
*/
public final class LabelId {
/**
* Represents a logical Id.
*/
private final long labelId;
/**
* Constructor, public creation is prohibited.
*/
private LabelId(long id) {
this.labelId = id;
}
/**
* Returns the LabelId representing the specified long value.
*
* @param id identifier as long value
* @return LabelId
*/
public static LabelId labelId(long id) {
return new LabelId(id);
}
public static LabelId labelId(String string) {
return new LabelId(UnsignedLongs.decode(string));
}
public long toLong() {
return labelId;
}
@Override
public String toString() {
return UnsignedLongs.toString(labelId);
}
@Override
public int hashCode() {
return Objects.hash(labelId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LabelId) {
final LabelId other = (LabelId) obj;
return this.labelId == other.labelId;
}
return false;
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.Annotated;
import org.onosproject.net.NetworkResource;
import org.onosproject.net.Provided;
import org.onosproject.net.resource.Bandwidth;
/**
* Abstraction of a generalized Tunnel entity (bandwidth pipe) for either L3/L2 networks or L1/L0 networks,
* representation of e.g., VLAN, GRE tunnel, MPLS LSP, L1 ODUk connection, WDM OCH, etc.. Each Tunnel is
* associated with at least two Label objects that model the logical ports essentially.
* Note that it supports nested case.
*/
public interface Tunnel extends Annotated, Provided, NetworkResource {
/**
* Coarse representation of the Tunnel types.
*/
public enum Type {
/**
* Signifies that this is a L2 tunnel.
*/
VLAN,
/**
* Signifies that this is a DC L2 extension tunnel.
*/
VXLAN,
/**
* Signifies that this is a L3 tunnel.
*/
GRE,
/**
* Signifies that this is a MPLS tunnel.
*/
LSP,
/**
* Signifies that this is a L1 OTN tunnel.
*/
ODUk,
/**
* Signifies that this is a L0 OCH tunnel.
*/
OCH
}
/**
* Representation of the tunnel state.
*
*/
public enum State {
/**
* Signifies that a tunnel is currently in a initialized state.
*/
INIT,
/**
* Signifies that a tunnel is currently established but no traffic.
*/
ESTABLISHED,
/**
* Signifies that a tunnel is currently serving the traffic.
*/
ACTIVE,
/**
* Signifies that a tunnel is currently out of service.
*/
FAILED,
/**
* Signifies that a tunnel is currently in maintenance state.
*/
INACTIVE
}
TunnelId id();
/**
* Returns the tunnel source point (source Label object).
*
* @return source Label object
*/
Label src();
/**
* Returns the tunnel destination point (destination Label object).
*
* @return destination Label object
*/
Label dst();
/**
* Returns the tunnel type.
*
* @return tunnel type
*/
Type type();
/**
* Returns the tunnel state.
*
* @return tunnel state
*/
State state();
/**
* Indicates if the tunnel is to be considered durable.
*
* @return true if the tunnel is durable
*/
boolean isDurable();
/**
* Indicates if the tunnel is to be considered Bidirectional.
*
* @return true if the tunnel is Bidirectional
*/
boolean isBidirectional();
/**
* Return the tunnel bandwidth.
*
* @return tunnel bandwidth
*/
Bandwidth bandwidth();
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Path;
/**
* Service for administering the inventory of provisioned tunnels.
*/
public interface TunnelAdminService {
/**
* Removes the provisioned tunnel.
*
* @param tunnelId tunnel ID
*/
void removeTunnel(TunnelId tunnelId);
/**
* Removes the provisioned tunnel leading to and from the
* specified labels.
*
* @param src source label
* @param dst destination label
*/
void removeTunnels(Label src, Label dst);
/**
* Removes all provisioned tunnels leading to and from the
* specified connection point.
*
* @param src source connection point
* @param dst destination connection point
*/
void removeTunnels(ConnectPoint src, ConnectPoint dst);
/**
* Removes all provisioned tunnels leading to and from the
* specified connection point.
*
* @param src source connection point
* @param dst destination connection point
* @param type tunnel type
*/
void removeTunnels(ConnectPoint src, ConnectPoint dst, Tunnel.Type type);
/**
* Removes all provisioned tunnels leading to and from the
* specified connection point.
*
* @param connectPoint connection point
*/
void removeTunnels(ConnectPoint connectPoint);
/**
* Removes all provisioned tunnels leading to and from the
* specified device.
*
* @param deviceId device identifier
*/
void removeTunnels(DeviceId deviceId);
/**
* Invokes the core to update a tunnel based on specified tunnel parameters.
*
* @param tunnel Tunnel
* @param path explicit route (path changed) or null (path not changed) for the tunnel
*/
void updateTunnel(Tunnel tunnel, Path path);
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Description;
/**
* Describes the tunnel.
*/
public interface TunnelDescription extends Description {
/**
* Returns the tunnel id.
*
* @return tunnelId
*/
TunnelId id();
/**
* Returns the connection point source.
*
* @return tunnel source ConnectionPoint
*/
ConnectPoint src();
/**
* Returns the connection point destination.
*
* @return tunnel destination
*/
ConnectPoint dst();
/**
* Returns the tunnel type.
*
* @return tunnel type
*/
Tunnel.Type type();
/**
* Returns if the tunnel is bidirectional.
*
* @return true if bidirectional, otherwise false
*/
boolean isBidirectional();
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.event.AbstractEvent;
/**
* Describes tunnel events.
*/
public class TunnelEvent extends AbstractEvent<TunnelEvent.Type, Tunnel> {
/**
* Type of tunnel events.
*/
public enum Type {
/**
* Signifies that a new tunnel has been added.
*/
TUNNEL_ADDED,
/**
* Signifies that a tunnel has been updated or changed state.
*/
TUNNEL_UPDATED,
/**
* Signifies that a tunnel has been removed.
*/
TUNNEL_REMOVED
}
/**
* Creates an event of a given type and for the specified tunnel.
*
* @param type tunnel event type
* @param tunnel event tunnel subject
*/
public TunnelEvent(Type type, Tunnel tunnel) {
super(type, tunnel);
}
/**
* Creates an event of a given type and for the specified link and
* the current time.
*
* @param type tunnel event type
* @param tunnel event tunnel subject
* @param time occurrence time
*/
public TunnelEvent(Type type, Tunnel tunnel, long time) {
super(type, tunnel, time);
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import static com.google.common.base.Preconditions.checkArgument;
/**
* Representation of a Tunnel Id.
*/
public final class TunnelId {
private final long value;
/**
* Creates an tunnel identifier from the specified tunnel.
*
* @param value long value
* @return tunnel identifier
*/
public static TunnelId valueOf(long value) {
return new TunnelId(value);
}
public static TunnelId valueOf(String value) {
checkArgument(value.startsWith("0x"));
return new TunnelId(Long.parseLong(value.substring("0x".length()), 16));
}
/**
* Constructor for serializer.
*/
TunnelId() {
this.value = 0;
}
/**
* Constructs the ID corresponding to a given long value.
*
* @param value the underlying value of this ID
*/
TunnelId(long value) {
this.value = value;
}
/**
* Returns the backing value.
*
* @return the value
*/
public long id() {
return value;
}
@Override
public int hashCode() {
return (int) (value ^ (value >>> 32));
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TunnelId)) {
return false;
}
TunnelId that = (TunnelId) obj;
return this.value == that.value;
}
@Override
public String toString() {
return "0x" + Long.toHexString(value);
}
}
/*
* Copyright 2014 Open Networking Laboratory
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,25 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net;
package org.onosproject.net.tunnel;
import org.onosproject.event.EventListener;
/**
* Abstraction of a generalized network tunnel.
* Entity capable of receiving tunnel related events.
*/
public interface Tunnel extends Link {
/**
* Tunnel technology type.
*/
enum Type {
MPLS, VLAN, VXLAN, GRE, OPTICAL
}
/**
* Network resource backing the tunnel, e.g. lambda, VLAN id, MPLS tag.
*
* @return backing resource
*/
NetworkResource resource();
public interface TunnelListener extends EventListener<TunnelEvent> {
}
......
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.ElementId;
import org.onosproject.net.Path;
import org.onosproject.net.provider.Provider;
/**
* Abstraction of an entity providing tunnel setup/release services to the core.
*/
public interface TunnelProvider extends Provider {
/**
* Instructs the provider to setup a tunnel.
*
* @param tunnel Tunnel
* @param path explicit route or null for the tunnel
*/
void setupTunnel(Tunnel tunnel, Path path);
/**
* Instructs the provider to setup a tunnel given the respective device.
*
* @param srcElement device
* @param tunnel Tunnel
* @param path explicit route (not null) for the tunnel
*/
void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path);
/**
* Instructs the provider to release a tunnel.
*
* @param tunnel Tunnel
*/
void releaseTunnel(Tunnel tunnel);
/**
* Instructs the provider to release a tunnel given the respective device.
*
* @param srcElement device
* @param tunnel Tunnel
*/
void releaseTunnel(ElementId srcElement, Tunnel tunnel);
/**
* Instructs the provider to update a tunnel.
*
* @param tunnel Tunnel
* @param path explicit route (path changed) or null (path not changed) for the tunnel
*/
void updateTunnel(Tunnel tunnel, Path path);
/**
* Instructs the provider to update a tunnel given the respective device.
*
* @param srcElement device
* @param tunnel Tunnel
* @param path explicit route (path changed) or null (path not changed) for the tunnel
*/
void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path);
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.provider.ProviderRegistry;
/**
* Abstraction of an tunnel provider registry.
*/
public interface TunnelProviderRegistry
extends ProviderRegistry<TunnelProvider, TunnelProviderService> {
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.provider.ProviderService;
/**
* APIs for tunnel provider to notify the tunnel subSystem.
*/
public interface TunnelProviderService extends ProviderService<TunnelProvider> {
/**
* Signals that the provider has added a tunnel.
*
* @param tunnel tunnel information
*/
void tunnelAdded(TunnelDescription tunnel);
/**
* Signals that the provider has removed a tunnel.
*
* @param tunnel tunnel information
*/
void tunnelRemoved(TunnelDescription tunnel);
/**
* Signals that the a tunnel was changed (e.g., sensing changes of tunnel).
*
* @param tunnel tunnel information
*/
void tunnelUpdated(TunnelDescription tunnel);
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import java.util.Collection;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Path;
import org.onosproject.net.resource.Bandwidth;
/**
* Service for interacting with the tunnel inventory.
*/
public interface TunnelService {
/**
* Invokes the core to create a tunnel based on specified parameters.
*
* @param src sourcePoint
* @param dst destinationPoint
* @param bw bandwidth
* @param path explicit path or null
*/
void requestTunnel(ConnectPoint src, ConnectPoint dst, Bandwidth bw, Path path);
/**
* Invokes the core to create a tunnel based on specified parameters with a tunnel type.
*
* @param src sourcePoint
* @param dst destinationPoint
* @param type tunnelType
* @param bw bandwidth
* @param path explicit path or null
*/
void requestTunnel(ConnectPoint src, ConnectPoint dst, Tunnel.Type type, Bandwidth bw, Path path);
/**
* Returns the count of all known tunnels in the dataStore.
*
* @return number of tunnels
*/
int getTunnelCount();
/**
* Returns a collection of all known tunnel based on the type.
*
* @return all tunnels for a specific type
*/
Collection<Tunnel> getTunnels(Tunnel.Type type);
/**
* Returns set of all tunnels from the
* specified connectpoint.
*
* @return set of tunnels
*/
Collection<Tunnel> getTunnels(ConnectPoint connectPoint, Tunnel.Type type);
/**
* Returns set of all tunnels from the
* specified source connectpoint and destination connectpoint.
*
* @param src sourcePoint
* @param dst destinationPoint
* @param type tunnel type
* @return set of tunnels
*/
Collection<Tunnel> getTunnels(ConnectPoint src, ConnectPoint dst, Tunnel.Type type);
/**
* Returns the tunnel between the specified source
* and destination connection points.
*
* @param src source label
* @param dst destination label
* @return tunnel from source to destination; null if none found
*/
Tunnel getTunnel(Label src, Label dst);
/**
* Returns the tunnel based on the Id.
*
* @param id tunnelId
* @return tunnel with specified Id
*/
Tunnel getTunnel(TunnelId id);
/**
* Adds the specified tunnel listener.
*
* @param listener tunnel listener
*/
void addListener(TunnelListener listener);
/**
* Removes the specified tunnel listener.
*
* @param listener tunnel listener
*/
void removeListener(TunnelListener listener);
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.Store;
/**
* Manages inventory of tunnels.
*/
public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> {
/**
* Returns the number of tunnels in the store.
*
* @return number of tunnels
*/
int getTunnelCount();
/**
* Returns an iterable collection of all tunnel in the inventory.
*
* @return collection of all tunnels
*/
Iterable<Tunnel> getTunnels();
/**
* Returns all tunnels egressing from the specified device.
*
* @param deviceId device identifier
* @return set of device tunnels
*/
Iterable<Tunnel> getDeviceEgressTunnels(DeviceId deviceId);
/**
* Returns all tunnels ingressing from the specified device.
*
* @param deviceId device identifier
* @return set of device tunnels
*/
Iterable<Tunnel> getDeviceIngressTunnels(DeviceId deviceId);
/**
* Returns the tunnel between the two end-points and the tunnel type.
*
* @param src source connection point
* @param dst destination connection point
* @param type tunnel type
* @return tunnels or null if one not found between the end-points
*/
Iterable<Tunnel> getTunnel(ConnectPoint src, ConnectPoint dst, Tunnel.Type type);
/**
* Returns all tunnels egressing from the specified connection point.
*
* @param src source connection point
* @return set of connection point tunnels
*/
Iterable<Tunnel> getEgressTunnels(ConnectPoint src);
/**
* Returns all tunnels ingressing to the specified connection point.
*
* @param dst destination connection point
* @return set of connection point tunnels
*/
Iterable<Tunnel> getIngressTunnels(ConnectPoint dst);
/**
* Creates a new tunnel based on the given information.
*
* @param providerId provider identity (e.g., PCEP provider)
* @param tunnel tunnel information
* @return create tunnel event
*/
public TunnelEvent addTunnel(ProviderId providerId,
Tunnel tunnel);
/**
* Updates a new tunnel based on the given information.
*
* @param providerId provider identity (e.g., PCEP provider)
* @param tunnel tunnel
* @return update tunnel event
*/
public TunnelEvent updateTunnel(ProviderId providerId,
Tunnel tunnel);
/**
* Removes a new tunnel based on the given information.
*
* @param providerId provider identity (e.g., PCEP provider)
* @param tunnel tunnel
* @return remove tunnel event
*/
TunnelEvent removeTunnel(ProviderId providerId,
Tunnel tunnel);
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel;
import org.onosproject.store.StoreDelegate;
/**
* Tunnel store delegate abstraction.
*/
public interface TunnelStoreDelegate extends StoreDelegate<TunnelEvent> {
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Tunnel model related services and providers API definitions.
*/
package org.onosproject.net.tunnel;
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.net.tunnel.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.CoreService;
import org.onosproject.event.AbstractListenerRegistry;
import org.onosproject.event.EventDeliveryService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Path;
import org.onosproject.net.link.LinkEvent;
import org.onosproject.net.link.LinkListener;
import org.onosproject.net.provider.AbstractProviderRegistry;
import org.onosproject.net.provider.AbstractProviderService;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.tunnel.Label;
import org.onosproject.net.tunnel.Tunnel;
import org.onosproject.net.tunnel.TunnelAdminService;
import org.onosproject.net.tunnel.TunnelDescription;
import org.onosproject.net.tunnel.TunnelEvent;
import org.onosproject.net.tunnel.TunnelId;
import org.onosproject.net.tunnel.TunnelListener;
import org.onosproject.net.tunnel.TunnelProvider;
import org.onosproject.net.tunnel.TunnelProviderRegistry;
import org.onosproject.net.tunnel.TunnelProviderService;
import org.onosproject.net.tunnel.TunnelService;
import org.onosproject.net.tunnel.TunnelStore;
import org.onosproject.net.tunnel.TunnelStoreDelegate;
import org.onosproject.net.tunnel.Tunnel.Type;
import org.slf4j.Logger;
/**
* Provides implementation of the tunnel NB/SB APIs.
*/
@Component(immediate = true, enabled = true)
@Service
public class TunnelManager extends AbstractProviderRegistry<TunnelProvider, TunnelProviderService>
implements TunnelService, TunnelAdminService, TunnelProviderRegistry {
private static final String TUNNNEL_ID_NULL = "Tunnel ID cannot be null";
private final Logger log = getLogger(getClass());
protected final AbstractListenerRegistry<TunnelEvent, TunnelListener>
listenerRegistry = new AbstractListenerRegistry<>();
private final TunnelStoreDelegate delegate = new InternalStoreDelegate();
private final InternalTunnelListener tunnelListener = new InternalTunnelListener();
private InternalLinkListener linkListener = new InternalLinkListener();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TunnelStore store;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected EventDeliveryService eventDispatcher;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
private ExecutorService futureService;
@Activate
public void activate() {
// TODO Auto-generated method stub
log.info("Started");
}
@Deactivate
public void deactivate() {
// TODO Auto-generated method stub
log.info("Stopped");
}
@Override
protected TunnelProviderService createProviderService(TunnelProvider provider) {
// TODO Auto-generated method stub
return new InternalTunnelProviderService(provider);
}
@Override
public TunnelProviderService register(TunnelProvider provider) {
// TODO Auto-generated method stub
return null;
}
@Override
public void unregister(TunnelProvider provider) {
// TODO Auto-generated method stub
}
@Override
public Set<ProviderId> getProviders() {
// TODO Auto-generated method stub
return null;
}
@Override
public void removeTunnels(Label src, Label dst) {
// TODO Auto-generated method stub
}
@Override
public void removeTunnels(ConnectPoint connectPoint) {
// TODO Auto-generated method stub
}
@Override
public void removeTunnels(DeviceId deviceId) {
// TODO Auto-generated method stub
}
@Override
public int getTunnelCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Collection<Tunnel> getTunnels(Type type) {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<Tunnel> getTunnels(ConnectPoint connectPoint, Type type) {
// TODO Auto-generated method stub
return null;
}
@Override
public Tunnel getTunnel(Label src, Label dst) {
// TODO Auto-generated method stub
return null;
}
@Override
public Tunnel getTunnel(TunnelId id) {
// TODO Auto-generated method stub
return null;
}
@Override
public void addListener(TunnelListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeListener(TunnelListener listener) {
// TODO Auto-generated method stub
}
private class InternalTunnelListener implements TunnelListener {
@Override
public void event(TunnelEvent event) {
// TODO Auto-generated method stub
}
}
private class InternalLinkListener implements LinkListener {
@Override
public void event(LinkEvent event) {
// TODO Auto-generated method stub
}
}
private class InternalTunnelProviderService
extends AbstractProviderService<TunnelProvider>
implements TunnelProviderService {
protected InternalTunnelProviderService(TunnelProvider provider) {
super(provider);
// TODO Auto-generated constructor stub
}
@Override
public void tunnelAdded(TunnelDescription tunnel) {
// TODO Auto-generated method stub
}
@Override
public void tunnelUpdated(TunnelDescription tunnel) {
// TODO Auto-generated method stub
}
@Override
public void tunnelRemoved(TunnelDescription tunnel) {
// TODO Auto-generated method stub
}
}
private class InternalStoreDelegate implements TunnelStoreDelegate {
@Override
public void notify(TunnelEvent event) {
// TODO Auto-generated method stub
if (event != null) {
eventDispatcher.post(event);
}
}
}
@Override
public void requestTunnel(ConnectPoint src, ConnectPoint dst,
Bandwidth bw, Path path) {
// TODO Auto-generated method stub
}
@Override
public void requestTunnel(ConnectPoint src, ConnectPoint dst, Type type,
Bandwidth bw, Path path) {
// TODO Auto-generated method stub
}
@Override
public void removeTunnel(TunnelId tunnelId) {
// TODO Auto-generated method stub
}
@Override
public void removeTunnels(ConnectPoint src, ConnectPoint dst) {
// TODO Auto-generated method stub
}
@Override
public void removeTunnels(ConnectPoint src, ConnectPoint dst, Type type) {
// TODO Auto-generated method stub
}
@Override
public void updateTunnel(Tunnel tunnel, Path path) {
// TODO Auto-generated method stub
}
@Override
public Collection<Tunnel> getTunnels(ConnectPoint src, ConnectPoint dst,
Type type) {
// TODO Auto-generated method stub
return null;
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Core subsystem for tracking global inventory of tunnels.
*/
package org.onosproject.net.tunnel.impl;