aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/cordvtn
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-11-03 14:08:10 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-11-03 14:08:10 -0800
commit643ee33289bd2cb9e6afbfb09b4ed72d467ba1c2 (patch)
treec2c376a44a359544fe3d4c45eb0cc0e2ec4a7080 /framework/src/onos/apps/cordvtn
parent46eeb79b54345bdafb6055b8ee4bad4ce8b01274 (diff)
This updates ONOS src tree to commit id
03fa5e571cabbd001ddb1598847e1150b11c7333 Change-Id: I13b554026d6f902933e35887d29bd5fdb669c0bd Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/apps/cordvtn')
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java68
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java19
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java2
3 files changed, 65 insertions, 24 deletions
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
index 4b28a14b..e15bc763 100644
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
@@ -23,17 +23,27 @@ 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.onlab.util.ItemNotFoundException;
import org.onlab.util.KryoNamespace;
import org.onosproject.cluster.ClusterService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
+import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
+import org.onosproject.net.behaviour.BridgeConfig;
+import org.onosproject.net.behaviour.BridgeName;
import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.net.behaviour.DefaultTunnelDescription;
+import org.onosproject.net.behaviour.TunnelConfig;
+import org.onosproject.net.behaviour.TunnelDescription;
+import org.onosproject.net.behaviour.TunnelName;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.driver.DriverService;
import org.onosproject.net.host.HostEvent;
import org.onosproject.net.host.HostListener;
import org.onosproject.net.host.HostService;
@@ -58,6 +68,7 @@ import java.util.concurrent.Executors;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.Device.Type.SWITCH;
+import static org.onosproject.net.behaviour.TunnelDescription.Type.VXLAN;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -79,7 +90,6 @@ public class CordVtn implements CordVtnService {
private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS = new HashMap<String, String>() {
{
put("key", "flow");
- put("local_ip", "flow");
put("remote_ip", "flow");
}
};
@@ -99,6 +109,9 @@ public class CordVtn implements CordVtnService {
protected HostService hostService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DriverService driverService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OvsdbController controller;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -213,8 +226,8 @@ public class CordVtn implements CordVtnService {
if (deviceService.getDevice(ovsdb.intBrId()) == null ||
!deviceService.isAvailable(ovsdb.intBrId())) {
createIntegrationBridge(ovsdb);
- } else if (!checkVxlanPort(ovsdb)) {
- createVxlanPort(ovsdb);
+ } else if (!checkVxlanInterface(ovsdb)) {
+ createVxlanInterface(ovsdb);
}
}
@@ -272,26 +285,41 @@ public class CordVtn implements CordVtnService {
});
String dpid = ovsdb.intBrId().toString().substring(DPID_BEGIN);
- // TODO change to use bridge config
- OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
- ovsdbClient.createBridge(DEFAULT_BRIDGE_NAME, dpid, controllers);
+ try {
+ DriverHandler handler = driverService.createHandler(ovsdb.deviceId());
+ BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
+ bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), dpid, controllers);
+ } catch (ItemNotFoundException e) {
+ log.warn("Failed to create integration bridge on {}", ovsdb.deviceId());
+ }
}
- private void createVxlanPort(OvsdbNode ovsdb) {
- // TODO change to use tunnel config and tunnel description
- OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
- ovsdbClient.createTunnel(DEFAULT_BRIDGE_NAME, DEFAULT_TUNNEL,
- DEFAULT_TUNNEL, DEFAULT_TUNNEL_OPTIONS);
+ private void createVxlanInterface(OvsdbNode ovsdb) {
+ DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder();
+ for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) {
+ optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key));
+ }
+ TunnelDescription description =
+ new DefaultTunnelDescription(null, null, VXLAN,
+ TunnelName.tunnelName(DEFAULT_TUNNEL),
+ optionBuilder.build());
+ try {
+ DriverHandler handler = driverService.createHandler(ovsdb.deviceId());
+ TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class);
+ tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), description);
+ } catch (ItemNotFoundException e) {
+ log.warn("Failed to create VXLAN interface on {}", ovsdb.deviceId());
+ }
}
- private boolean checkVxlanPort(OvsdbNode ovsdb) {
- // TODO change to use tunnel config
- OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ private boolean checkVxlanInterface(OvsdbNode ovsdb) {
try {
- ovsdbClient.getPorts().stream()
- .filter(p -> p.portName().value().equals(DEFAULT_TUNNEL))
- .findFirst().get();
- } catch (NoSuchElementException e) {
+ DriverHandler handler = driverService.createHandler(ovsdb.deviceId());
+ BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
+ bridgeConfig.getPorts().stream()
+ .filter(p -> p.annotations().value("portName").equals(DEFAULT_TUNNEL))
+ .findAny().get();
+ } catch (ItemNotFoundException | NoSuchElementException e) {
return false;
}
return true;
@@ -374,8 +402,8 @@ public class CordVtn implements CordVtnService {
return;
}
- if (!checkVxlanPort(ovsdb)) {
- createVxlanPort(ovsdb);
+ if (!checkVxlanInterface(ovsdb)) {
+ createVxlanInterface(ovsdb);
}
}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
index 287f2a34..274ca9b4 100644
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
@@ -72,8 +72,6 @@ public class CordVtnConfigManager {
configService.addListener(configListener);
configRegistry.registerConfigFactory(configFactory);
-
- readConfiguration();
}
@Deactivate
@@ -101,7 +99,22 @@ public class CordVtnConfigManager {
@Override
public void event(NetworkConfigEvent event) {
- // TODO handle update event
+ if (!event.configClass().equals(CordVtnConfig.class)) {
+ return;
+ }
+
+ switch (event.type()) {
+ case CONFIG_ADDED:
+ log.info("Network configuration added");
+ readConfiguration();
+ break;
+ case CONFIG_UPDATED:
+ log.info("Network configuration updated");
+ readConfiguration();
+ break;
+ default:
+ break;
+ }
}
}
}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
index eba52108..46f6e29c 100644
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
@@ -61,7 +61,7 @@ public class DefaultOvsdbNode implements OvsdbNode {
@Override
public DeviceId deviceId() {
- return DeviceId.deviceId("ovsdb:" + this.ip.toString() + ":" + this.port.toString());
+ return DeviceId.deviceId("ovsdb:" + this.ip.toString());
}
@Override