diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-22 10:02:05 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-22 10:02:05 -0800 |
commit | 77ce3be7567bd01c66d8ee88a93b485666723501 (patch) | |
tree | 283e7f39a501750bbd705fbb91645b20198900f1 /framework/src/onos/ovsdb | |
parent | 00e6500d0813dcbccaaa741ef38cc1eae6d11e07 (diff) |
Removed patch path since changes have been merged upstream to a different path. Updated README with directions.
Change-Id: Ie419abd2d3d3ef7315de9f607dcd757a78190995
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/ovsdb')
4 files changed, 94 insertions, 6 deletions
diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java index 65ff0245..cfd844d3 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java @@ -16,6 +16,7 @@ package org.onosproject.ovsdb.controller; import com.google.common.util.concurrent.ListenableFuture; + import org.onlab.packet.IpAddress; import org.onosproject.net.DeviceId; import org.onosproject.net.behaviour.ControllerInfo; @@ -84,6 +85,15 @@ public interface OvsdbClientService extends OvsdbRPC { void createBridge(String bridgeName); /** + * Creates a bridge. + * + * @param bridgeName bridge name + * @param dpid data path id + * @param exPortName external port name + */ + void createBridge(String bridgeName, String dpid, String exPortName); + + /** * Creates a bridge with given name and dpid. * Sets the bridge's controller with given controllers. * diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java index 3280ad34..c6038632 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java @@ -24,7 +24,9 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; + import io.netty.channel.Channel; + import org.onlab.packet.IpAddress; import org.onosproject.net.DeviceId; import org.onosproject.net.behaviour.ControllerInfo; @@ -489,6 +491,76 @@ public class DefaultOvsdbClient } @Override + public void createBridge(String bridgeName, String dpid, String exPortName) { + log.debug("create bridge {}", bridgeName); + + DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME); + if (dbSchema == null) { + log.warn("The schema is null"); + return; + } + + Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, + OvsdbTable.BRIDGE); + if (bridge == null) { + log.debug("Can not create bridge"); + return; + } + + Set<String> failModes = new HashSet<>(); + failModes.add("secure"); + bridge.setFailMode(failModes); + + Set<String> protocols = new HashSet<>(); + protocols.add(OvsdbConstant.OPENFLOW13); + bridge.setProtocols(protocols); + + String ovsUuid = getOvsUuid(OvsdbConstant.DATABASENAME); + if (ovsUuid == null) { + log.warn("The Open_vSwitch is null"); + return; + } + + String bridgeUuid = getBridgeUuid(bridgeName); + if (bridgeUuid == null) { + log.debug("Create a new bridge"); + + bridge.setName(bridgeName); + if (dpid != null) { + Map<String, String> options = new HashMap<>(); + options.put("datapath-id", dpid); + bridge.setOtherConfig(options); + } + bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid", + OvsdbConstant.DATABASENAME, "bridges", + ovsUuid, bridge.getRow()); + + if (bridgeUuid != null) { + Port port = (Port) TableGenerator.createTable(dbSchema, + OvsdbTable.PORT); + if (port != null) { + log.debug("the port is not null"); + port.setName(bridgeName); + + insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid, + port.getRow()); + } + } + + } else { + log.info("Update a bridge"); + updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid, bridge.getRow()); + } + // Create external port + if (exPortName != null) { + createPort(bridgeName, exPortName); + } + + setControllerAuto(bridgeUuid); + log.info("Create bridge success"); + } + + @Override public boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers) { DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME); diff --git a/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java b/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java index 2c418d57..5d80a7bf 100644 --- a/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java +++ b/framework/src/onos/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java @@ -18,6 +18,7 @@ package org.onosproject.ovsdb.controller.driver; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.util.concurrent.ListenableFuture; + import org.onlab.packet.IpAddress; import org.onosproject.net.DeviceId; import org.onosproject.net.behaviour.ControllerInfo; @@ -216,4 +217,9 @@ public class OvsdbClientServiceAdapter implements OvsdbClientService { public ListenableFuture<List<JsonNode>> transact(DatabaseSchema dbSchema, List<Operation> operations) { return null; } + + @Override + public void createBridge(String bridgeName, String dpid, String exPortName) { + + } } diff --git a/framework/src/onos/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java b/framework/src/onos/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java index 2e84a16a..fcbbff8e 100644 --- a/framework/src/onos/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java +++ b/framework/src/onos/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java @@ -58,7 +58,7 @@ import org.slf4j.LoggerFactory; /** * The main controller class. Handles all setup and network listeners - - * Distributed ovsdbClient. + * distributed OVSDBClient. */ public class Controller { protected static final Logger log = LoggerFactory @@ -105,7 +105,7 @@ public class Controller { } /** - * Tells controller that we're ready to accept ovsdb node loop. + * Tells controller that we're ready to accept OVSDB node loop. * @throws InterruptedException if thread is interrupted */ public void run() throws InterruptedException { @@ -114,7 +114,7 @@ public class Controller { } /** - * Adds channel pipiline to handle a new connected node. + * Adds channel pipeline to handle a new connected node. */ private class OnosCommunicationChannelInitializer extends ChannelInitializer<SocketChannel> { @@ -128,7 +128,7 @@ public class Controller { } /** - * Handles the new connection of a node. + * Handles the new connection of node. * * @param channel the channel to use. */ @@ -169,9 +169,9 @@ public class Controller { } /** - * Gets an ovsdb client instance. + * Gets an OVSDB client instance. * - * @param nodeId data ovsdb node id + * @param nodeId data OVSDB node id * @param agent OvsdbAgent * @param monitorCallback Callback * @param channel Channel |