samuel

Updated. Build a OVSDB driver and its associated behaviors for

supporting application to create VxLAN/GRE tunnels
This code is for JIRA ONOS-2181.

Change-Id: If7f341a422620a9e885741d4cc412fad39438d89
/*
* 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.behaviour;
import java.util.Collection;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.driver.HandlerBehaviour;
/**
* Behaviour for handling various drivers for bridge configurations.
*/
public interface BridgeConfig extends HandlerBehaviour {
/**
* Add a bridge.
*
* @param bridgeName bridge name
*/
void addBridge(BridgeName bridgeName);
/**
* Remove a bridge.
*
* @param bridgeName bridge name
*/
void deleteBridge(BridgeName bridgeName);
/**
* Remove a bridge.
*
* @return bridge collection
*/
Collection<BridgeDescription> getBridges();
/**
* Add a logical/virtual port.
*
* @param port port number
*/
void addPort(PortDescription port);
/**
* Delete a logical/virtual port.
*
* @param port port number
*/
void deletePort(PortDescription port);
/**
* Delete a logical/virtual port.
*
* return collection of port
*/
Collection<PortDescription> getPorts();
}
/*
* Copyright 2014-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.behaviour;
import org.onosproject.net.Description;
import org.onosproject.net.DeviceId;
/**
* The abstraction of bridge in OVSDB protocol.
*/
public interface BridgeDescription extends Description {
/**
* Returns bridge name.
*
* @return bridge name
*/
BridgeName bridgeName();
/**
* Returns controller identifier that this bridge belongs to.
*
* @return controller identifier
*/
DeviceId cotrollerDeviceId();
/**
* Returns bridge identifier .
*
* @return bridge identifier
*/
DeviceId deviceId();
}
/*
* Copyright 2014-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.behaviour;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Represents for a bridge name.
*/
public final class BridgeName {
private final String name;
// Public construction is prohibited
private BridgeName(String name) {
this.name = name;
}
/**
* Creates a bridge name using the supplied string.
*
* @param name bridge name
* @return BridgeName
*/
public static BridgeName bridgeName(String name) {
return new BridgeName(name);
}
/**
* Returns the bridge name string.
*
* @return name string
*/
public String name() {
return name;
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BridgeName) {
final BridgeName that = (BridgeName) obj;
return this.getClass() == that.getClass() &&
Objects.equals(this.name, that.name);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("name", name)
.toString();
}
}
/*
* Copyright 2014-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.behaviour;
import java.util.Objects;
import org.onosproject.net.AbstractDescription;
import org.onosproject.net.DeviceId;
import org.onosproject.net.SparseAnnotations;
import com.google.common.base.MoreObjects;
/**
* The default implementation of bridge.
*/
public final class DefaultBridgeDescription extends AbstractDescription
implements BridgeDescription {
private final BridgeName name;
private final DeviceId deviceId;
private final DeviceId controllerId;
public DefaultBridgeDescription(BridgeName name, DeviceId controllerId,
DeviceId deviceId,
SparseAnnotations... annotations) {
super(annotations);
this.name = name;
this.deviceId = deviceId;
this.controllerId = controllerId;
}
@Override
public BridgeName bridgeName() {
return name;
}
@Override
public DeviceId deviceId() {
return deviceId;
}
@Override
public DeviceId cotrollerDeviceId() {
return controllerId;
}
@Override
public int hashCode() {
return Objects.hash(name, deviceId, controllerId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof DefaultBridgeDescription) {
final DefaultBridgeDescription that = (DefaultBridgeDescription) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.name, that.name)
&& Objects.equals(this.deviceId, that.deviceId)
&& Objects.equals(this.controllerId, that.controllerId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).add("name", name)
.add("deviceId", deviceId).add("controllerId", controllerId)
.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.behaviour;
import org.onosproject.net.AbstractDescription;
import org.onosproject.net.SparseAnnotations;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
/**
* Default implementation of immutable tunnel description entity.
*/
@Beta
public class DefaultTunnelDescription extends AbstractDescription
implements TunnelDescription {
private final TunnelEndPoint src;
private final TunnelEndPoint dst;
private final Type type;
// which a tunnel match up
// tunnel producer
private final TunnelName tunnelName; // name of a tunnel
/**
* Creates a tunnel description using the supplied information.
*
* @param src TunnelPoint source
* @param dst TunnelPoint destination
* @param type tunnel type
* @param tunnelName tunnel name
* @param annotations optional key/value annotations
*/
public DefaultTunnelDescription(TunnelEndPoint src,
TunnelEndPoint dst, Type type,
TunnelName tunnelName,
SparseAnnotations... annotations) {
super(annotations);
this.src = src;
this.dst = dst;
this.type = type;
this.tunnelName = tunnelName;
}
@Override
public TunnelEndPoint src() {
return src;
}
@Override
public TunnelEndPoint dst() {
return dst;
}
@Override
public Type type() {
return type;
}
@Override
public TunnelName tunnelName() {
return tunnelName;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("src", src())
.add("dst", dst())
.add("type", type())
.add("tunnelName", tunnelName())
.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.behaviour;
import java.util.Collection;
import org.onosproject.net.driver.HandlerBehaviour;
/**
* Behaviour for handling various drivers for tunnel configuration.
*/
public interface TunnelConfig extends HandlerBehaviour {
/**
* Create a tunnel.
*
* @param tunnel tunnel entity
*/
void createTunnel(TunnelDescription tunnel);
/**
* Remove a tunnel.
*
* @param tunnel tunnel entity
*/
void removeTunnel(TunnelDescription tunnel);
/**
* Update a tunnel.
*
* @param tunnel tunnel entity
*/
void updateTunnel(TunnelDescription tunnel);
/**
* Gets tunnels.
*
* return collection of tunnel
*/
Collection<TunnelDescription> getTunnels();
}
/*
* 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.behaviour;
import org.onosproject.net.Annotated;
import org.onosproject.net.Description;
import com.google.common.annotations.Beta;
/**
* Describes a tunnel.
*/
@Beta
public interface TunnelDescription extends Description, Annotated {
/**
* Tunnel technology type.
*/
enum Type {
/**
* Signifies that this is a MPLS tunnel.
*/
MPLS,
/**
* 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 L1 OTN tunnel.
*/
ODUK,
/**
* Signifies that this is a L0 OCH tunnel.
*/
OCH
}
/**
* Returns the connection point source.
*
* @return tunnel source ConnectionPoint
*/
TunnelEndPoint src();
/**
* Returns the connection point destination.
*
* @return tunnel destination
*/
TunnelEndPoint dst();
/**
* Returns the tunnel type.
*
* @return tunnel type
*/
Type type();
/**
* Return the name of a tunnel.
*
* @return Tunnel Name
*/
TunnelName tunnelName();
}
/*
* 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.behaviour;
import com.google.common.annotations.Beta;
/**
* Represents for source end point or destination end point of a tunnel. Maybe a tunnel
* based on ConnectPoint, IpAddress, MacAddress and so on is built.
*/
@Beta
public interface TunnelEndPoint {
}
/*
* 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.behaviour;
import com.google.common.annotations.Beta;
import java.util.Objects;
/**
* Represents for a unique tunnel name. TunnelId is generated by ONOS while
* TunnelName is given by producer. The consumer can borrow tunnels with
* TunnelId or TunnelName.
*/
@Beta
public final class TunnelName {
private final String str;
// Default constructor for serialization
private TunnelName(String tunnelName) {
this.str = tunnelName;
}
/**
* Creates a tunnel name using the supplied URI string.
*
* @param tunnelName tunnel name string
* @return tunnel name object
*/
public static TunnelName tunnelName(String tunnelName) {
return new TunnelName(tunnelName);
}
/**
* The string of tunnel name.
*
* @return the string of tunnel name
*/
public String value() {
return str;
}
@Override
public int hashCode() {
return Objects.hash(str);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TunnelName) {
final TunnelName that = (TunnelName) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.str, that.str);
}
return false;
}
@Override
public String toString() {
return str;
}
}