Hyunsun Moon
Committed by Gerrit Code Review

CORD-223 Added ovsdb driver methods for bridge and tunnel interface creation

Change-Id: Ida80a4ef5b66cebb83b2629054c68a3546526d23
......@@ -36,6 +36,17 @@ public interface BridgeConfig extends HandlerBehaviour {
void addBridge(BridgeName bridgeName);
/**
* Adds a bridge with given bridge name and dpid, and sets the controller
* of the bridge with given controllers.
*
* @param bridgeName bridge name
* @param dpid dpid
* @param controllers list of controller
* @return true if succeeds, fail otherwise
*/
boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers);
/**
* Remove a bridge.
*
* @param bridgeName bridge name
......
......@@ -32,6 +32,15 @@ public interface TunnelConfig extends HandlerBehaviour {
void createTunnel(TunnelDescription tunnel);
/**
* Creates a tunnel interface on a given bridge of this device.
*
* @param bridgeName bridge name
* @param tunnel tunnel description
* @return true if succeeds, false otherwise
*/
boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel);
/**
* Removes a tunnel on this device.
*
* @param tunnel tunnel descriptor
......
......@@ -22,11 +22,13 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.onlab.packet.IpAddress;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.BridgeConfig;
import org.onosproject.net.behaviour.BridgeDescription;
import org.onosproject.net.behaviour.BridgeName;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.behaviour.DefaultBridgeDescription;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.PortDescription;
......@@ -52,6 +54,13 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
}
@Override
public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) {
DriverHandler handler = handler();
OvsdbClientService clientService = getOvsdbClientService(handler);
return clientService.createBridge(bridgeName.name(), dpid, controllers);
}
@Override
public void deleteBridge(BridgeName bridgeName) {
DriverHandler handler = handler();
OvsdbClientService clientService = getOvsdbClientService(handler);
......@@ -108,9 +117,10 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour
return ports.stream()
.map(x -> new DefaultPortDescription(
PortNumber.portNumber(x.portNumber().value()),
true
)
)
true,
DefaultAnnotations.builder()
.set("portName", x.portName().value())
.build()))
.collect(Collectors.toSet());
}
......
......@@ -16,11 +16,14 @@
package org.onosproject.driver.ovsdb;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.onlab.packet.IpAddress;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.BridgeName;
import org.onosproject.net.behaviour.DefaultTunnelDescription;
import org.onosproject.net.behaviour.IpTunnelEndPoint;
import org.onosproject.net.behaviour.TunnelConfig;
......@@ -40,6 +43,8 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour
implements TunnelConfig {
private static final String DEFAULT_ADDRESS = "0.0.0.0";
private static final String OPTION_LOCAL_IP = "local_ip";
private static final String OPTION_REMOTE_IP = "remote_ip";
@Override
public void createTunnel(TunnelDescription tunnel) {
......@@ -60,6 +65,22 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour
}
@Override
public boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel) {
Map<String, String> options = ((DefaultAnnotations) tunnel.annotations()).asMap();
if (tunnel.src() != null) {
options.put(OPTION_LOCAL_IP, tunnel.src().toString());
}
if (tunnel.dst() != null) {
options.put(OPTION_REMOTE_IP, tunnel.dst().toString());
}
DriverHandler handler = handler();
OvsdbClientService ovsdbClient = getOvsdbNode(handler);
return ovsdbClient.createTunnel(bridgeName.name(), tunnel.tunnelName().toString(),
tunnel.type().toString().toLowerCase(), options);
}
@Override
public void removeTunnel(TunnelDescription tunnel) {
DriverHandler handler = handler();
OvsdbClientService ovsdbNode = getOvsdbNode(handler);
......