aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/providers/ovsdb
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
commit13d05bc8458758ee39cb829098241e89616717ee (patch)
tree22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/providers/ovsdb
parent6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff)
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/providers/ovsdb')
-rw-r--r--framework/src/onos/providers/ovsdb/app/app.xml30
-rw-r--r--framework/src/onos/providers/ovsdb/app/features.xml35
-rw-r--r--framework/src/onos/providers/ovsdb/app/pom.xml70
-rw-r--r--framework/src/onos/providers/ovsdb/device/pom.xml39
-rw-r--r--framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java134
-rw-r--r--framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/package-info.java21
-rw-r--r--framework/src/onos/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java198
-rw-r--r--framework/src/onos/providers/ovsdb/host/pom.xml39
-rw-r--r--framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java148
-rw-r--r--framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/package-info.java21
-rw-r--r--framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java199
-rw-r--r--framework/src/onos/providers/ovsdb/pom.xml41
-rw-r--r--framework/src/onos/providers/ovsdb/tunnel/pom.xml39
-rw-r--r--framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProvider.java123
-rw-r--r--framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/package-info.java21
-rw-r--r--framework/src/onos/providers/ovsdb/tunnel/src/test/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProviderTest.java185
16 files changed, 1343 insertions, 0 deletions
diff --git a/framework/src/onos/providers/ovsdb/app/app.xml b/framework/src/onos/providers/ovsdb/app/app.xml
new file mode 100644
index 00000000..c3334994
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/app/app.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<app name="org.onosproject.ovsdb" origin="ON.Lab" version="${project.version}"
+ featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
+ features="${project.artifactId}">
+ <description>${project.description}</description>
+
+ <artifact>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-ovsdb-api/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-ovsdb-ctl/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-drivers/${project.version}</artifact>
+
+ <artifact>mvn:${project.groupId}/onos-ovsdb-provider-device/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-ovsdb-provider-host/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-ovsdb-provider-tunnel/${project.version}</artifact>
+</app>
diff --git a/framework/src/onos/providers/ovsdb/app/features.xml b/framework/src/onos/providers/ovsdb/app/features.xml
new file mode 100644
index 00000000..19fab4cd
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/app/features.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <feature>onos-api</feature>
+ <bundle>mvn:io.netty/netty-common/4.0.23.Final</bundle>
+ <bundle>mvn:io.netty/netty-buffer/4.0.23.Final</bundle>
+ <bundle>mvn:io.netty/netty-transport/4.0.23.Final</bundle>
+ <bundle>mvn:io.netty/netty-handler/4.0.23.Final</bundle>
+ <bundle>mvn:io.netty/netty-codec/4.0.23.Final</bundle>
+ <bundle>mvn:${project.groupId}/onos-ovsdb-rfc/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-ovsdb-api/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-ovsdb-ctl/${project.version}</bundle>
+
+ <bundle>mvn:${project.groupId}/onos-ovsdb-provider-device/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-ovsdb-provider-host/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-ovsdb-provider-tunnel/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/framework/src/onos/providers/ovsdb/app/pom.xml b/framework/src/onos/providers/ovsdb/app/pom.xml
new file mode 100644
index 00000000..7bb506ba
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/app/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-providers</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-ovsdatabase</artifactId>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-rfc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-ctl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-drivers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-provider-device</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-provider-host</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-provider-tunnel</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/providers/ovsdb/device/pom.xml b/framework/src/onos/providers/ovsdb/device/pom.xml
new file mode 100644
index 00000000..e5010fa6
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/device/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-providers</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-ovsdb-provider-device</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
new file mode 100644
index 00000000..10e745e3
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProvider.java
@@ -0,0 +1,134 @@
+/*
+ * 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.ovsdb.providers.device;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.net.URI;
+
+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.onlab.packet.ChassisId;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceProvider;
+import org.onosproject.net.device.DeviceProviderRegistry;
+import org.onosproject.net.device.DeviceProviderService;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbNodeListener;
+import org.slf4j.Logger;
+
+/**
+ * Provider which uses an ovsdb controller to detect device.
+ */
+@Component(immediate = true)
+@Service
+public class OvsdbDeviceProvider extends AbstractProvider
+ implements DeviceProvider {
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceProviderRegistry providerRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected OvsdbController controller;
+
+ private DeviceProviderService providerService;
+ private OvsdbNodeListener innerNodeListener = new InnerOvsdbNodeListener();
+ protected static final String ISNOTNULL = "OvsdbNodeId is not null";
+ private static final String UNKNOWN = "unknown";
+
+ @Activate
+ public void activate() {
+ providerService = providerRegistry.register(this);
+ controller.addNodeListener(innerNodeListener);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ providerRegistry.unregister(this);
+ providerService = null;
+ log.info("Stopped");
+ }
+
+ public OvsdbDeviceProvider() {
+ super(new ProviderId("ovsdb", "org.onosproject.ovsdb.provider.device"));
+ }
+
+ @Override
+ public void triggerProbe(DeviceId deviceId) {
+ // TODO: This will be implemented later.
+ log.info("Triggering probe on device {}", deviceId);
+ }
+
+ @Override
+ public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public boolean isReachable(DeviceId deviceId) {
+ return true;
+ }
+
+ private class InnerOvsdbNodeListener implements OvsdbNodeListener {
+
+ @Override
+ public void nodeAdded(OvsdbNodeId nodeId) {
+ checkNotNull(nodeId, ISNOTNULL);
+ DeviceId deviceId = DeviceId.deviceId(nodeId.toString());
+ URI uri = URI.create(nodeId.toString());
+ ChassisId cid = new ChassisId();
+ String ipAddress = nodeId.getIpAddress();
+ SparseAnnotations annotations = DefaultAnnotations.builder()
+ .set("ipaddress", ipAddress).build();
+ DeviceDescription deviceDescription = new DefaultDeviceDescription(
+ uri,
+ Device.Type.CONTROLLER,
+ UNKNOWN, UNKNOWN,
+ UNKNOWN, UNKNOWN,
+ cid,
+ annotations);
+ providerService.deviceConnected(deviceId, deviceDescription);
+
+ }
+
+ @Override
+ public void nodeRemoved(OvsdbNodeId nodeId) {
+ checkNotNull(nodeId, ISNOTNULL);
+ DeviceId deviceId = DeviceId.deviceId(nodeId.toString());
+ providerService.deviceDisconnected(deviceId);
+
+ }
+ }
+}
diff --git a/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/package-info.java b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/package-info.java
new file mode 100644
index 00000000..1636371a
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/device/src/main/java/org/onosproject/ovsdb/providers/device/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ *Provider that uses ovsdb controller as a means of infrastructure device discovery.
+ *
+ */
+package org.onosproject.ovsdb.providers.device; \ No newline at end of file
diff --git a/framework/src/onos/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java b/framework/src/onos/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java
new file mode 100644
index 00000000..5e4c5677
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/device/src/test/java/org/onosproject/ovsdb/providers/device/OvsdbDeviceProviderTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.ovsdb.providers.device;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceProvider;
+import org.onosproject.net.device.DeviceProviderRegistry;
+import org.onosproject.net.device.DeviceProviderService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.device.PortStatistics;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbNodeListener;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+/**
+ * Test for ovsdb device provider.
+ */
+public class OvsdbDeviceProviderTest {
+ private final OvsdbDeviceProvider provider = new OvsdbDeviceProvider();
+ private final TestDeviceRegistry registry = new TestDeviceRegistry();
+ private final TestController controller = new TestController();
+
+ @Before
+ public void startUp() {
+ provider.providerRegistry = registry;
+ provider.controller = controller;
+ provider.activate();
+ assertNotNull("provider should be registered", registry.provider);
+ }
+
+ @After
+ public void tearDown() {
+ provider.deactivate();
+ provider.controller = null;
+ provider.providerRegistry = null;
+ }
+
+ @Test
+ public void triggerProbe() {
+
+ }
+
+ @Test
+ public void testNodeAdded() {
+ controller.listener.nodeAdded(new OvsdbNodeId(IpAddress
+ .valueOf("192.168.202.36"), 5000));
+ assertEquals("ovsdb node added", 1, registry.connected.size());
+ }
+
+ @Test
+ public void testNodeRemoved() {
+ controller.listener.nodeAdded(new OvsdbNodeId(IpAddress
+ .valueOf("192.168.202.36"), 5000));
+ controller.listener.nodeRemoved(new OvsdbNodeId(IpAddress
+ .valueOf("192.168.202.36"), 5000));
+ assertEquals("ovsdb node removded", 0, registry.connected.size());
+ }
+
+ private class TestDeviceRegistry implements DeviceProviderRegistry {
+ DeviceProvider provider;
+
+ Set<DeviceId> connected = new HashSet<>();
+ Multimap<DeviceId, PortDescription> ports = HashMultimap.create();
+ PortDescription descr = null;
+
+ @Override
+ public DeviceProviderService register(DeviceProvider provider) {
+ this.provider = provider;
+ return new TestProviderService();
+ }
+
+ @Override
+ public void unregister(DeviceProvider provider) {
+ }
+
+ @Override
+ public Set<ProviderId> getProviders() {
+ return null;
+ }
+
+ private class TestProviderService implements DeviceProviderService {
+
+ @Override
+ public DeviceProvider provider() {
+ return null;
+ }
+
+ @Override
+ public void deviceConnected(DeviceId deviceId,
+ DeviceDescription deviceDescription) {
+ connected.add(deviceId);
+ }
+
+ @Override
+ public void deviceDisconnected(DeviceId deviceId) {
+ connected.remove(deviceId);
+ ports.removeAll(deviceId);
+ }
+
+ @Override
+ public void updatePorts(DeviceId deviceId,
+ List<PortDescription> portDescriptions) {
+ for (PortDescription p : portDescriptions) {
+ ports.put(deviceId, p);
+ }
+ }
+
+ @Override
+ public void portStatusChanged(DeviceId deviceId,
+ PortDescription portDescription) {
+ ports.put(deviceId, portDescription);
+ descr = portDescription;
+ }
+
+ @Override
+ public void receivedRoleReply(DeviceId deviceId,
+ MastershipRole requested,
+ MastershipRole response) {
+ }
+
+ @Override
+ public void updatePortStatistics(DeviceId deviceId,
+ Collection<PortStatistics> portStatistics) {
+
+ }
+
+ }
+ }
+
+ private class TestController implements OvsdbController {
+ OvsdbNodeListener listener = null;
+
+ @Override
+ public void addNodeListener(OvsdbNodeListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public void removeNodeListener(OvsdbNodeListener listener) {
+ this.listener = null;
+ }
+
+ @Override
+ public void addOvsdbEventListener(OvsdbEventListener listener) {
+
+ }
+
+ @Override
+ public void removeOvsdbEventListener(OvsdbEventListener listener) {
+
+ }
+
+ @Override
+ public List<OvsdbNodeId> getNodeIds() {
+ return null;
+ }
+
+ @Override
+ public OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId) {
+ return null;
+ }
+
+ }
+
+}
diff --git a/framework/src/onos/providers/ovsdb/host/pom.xml b/framework/src/onos/providers/ovsdb/host/pom.xml
new file mode 100644
index 00000000..0bd88555
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/host/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-providers</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-ovsdb-provider-host</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
new file mode 100644
index 00000000..8d2fd142
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/OvsdbHostProvider.java
@@ -0,0 +1,148 @@
+/*
+ * 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.ovsdb.provider.host;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.toHex;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+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.onlab.packet.VlanId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.HostLocation;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.host.DefaultHostDescription;
+import org.onosproject.net.host.HostDescription;
+import org.onosproject.net.host.HostProvider;
+import org.onosproject.net.host.HostProviderRegistry;
+import org.onosproject.net.host.HostProviderService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.EventSubject;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbEvent;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbEventSubject;
+import org.slf4j.Logger;
+
+/**
+ * Provider which uses an ovsdb controller to detect host.
+ */
+@Component(immediate = true)
+@Service
+public class OvsdbHostProvider extends AbstractProvider implements HostProvider {
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostProviderRegistry providerRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected OvsdbController controller;
+
+ private HostProviderService providerService;
+ private OvsdbEventListener innerEventListener = new InnerOvsdbEventListener();
+
+ @Activate
+ public void activate() {
+ providerService = providerRegistry.register(this);
+ controller.addOvsdbEventListener(innerEventListener);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ providerRegistry.unregister(this);
+ providerService = null;
+ log.info("Stopped");
+ }
+
+ public OvsdbHostProvider() {
+ super(new ProviderId("ovsdb", "org.onosproject.ovsdb.provider.host"));
+ }
+
+ @Override
+ public void triggerProbe(Host host) {
+ log.info("Triggering probe on host {}", host);
+ }
+
+ private class InnerOvsdbEventListener implements OvsdbEventListener {
+
+ @Override
+ public void handle(OvsdbEvent<EventSubject> event) {
+ OvsdbEventSubject subject = null;
+ if (event.subject() instanceof OvsdbEventSubject) {
+ subject = (OvsdbEventSubject) event.subject();
+ }
+ checkNotNull(subject, "EventSubject is not null");
+ // If ifaceid is null,it indicates this is not a vm port.
+ if (subject.ifaceid() == null) {
+ return;
+ }
+ switch (event.type()) {
+ case PORT_ADDED:
+ HostId hostId = HostId.hostId(subject.hwAddress(), null);
+ DeviceId deviceId = DeviceId.deviceId(uri(subject.dpid().value()));
+ PortNumber portNumber = PortNumber.portNumber(subject
+ .portNumber().value(), subject.portName().value());
+ HostLocation loaction = new HostLocation(deviceId, portNumber,
+ 0L);
+ SparseAnnotations annotations = DefaultAnnotations.builder()
+ .set("ifaceid", subject.ifaceid().value()).build();
+ HostDescription hostDescription = new DefaultHostDescription(
+ subject.hwAddress(),
+ VlanId.vlanId(),
+ loaction,
+ annotations);
+ providerService.hostDetected(hostId, hostDescription);
+ break;
+ case PORT_REMOVED:
+ HostId host = HostId.hostId(subject.hwAddress(), null);
+ providerService.hostVanished(host);
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ }
+
+ public URI uri(String value) {
+ try {
+ return new URI("of", toHex(Long.valueOf(value)), null);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+}
diff --git a/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/package-info.java b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/package-info.java
new file mode 100644
index 00000000..895ae2ec
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/host/src/main/java/org/onosproject/ovsdb/provider/host/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ *Provider that uses ovsdb controller as a means of infrastructure host discovery.
+ *
+ */
+package org.onosproject.ovsdb.provider.host; \ No newline at end of file
diff --git a/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java b/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java
new file mode 100644
index 00000000..bf18606c
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/host/src/test/java/org/onosproject/ovsdb/provider/host/OvsdbHostProviderTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.ovsdb.provider.host;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.HostId;
+import org.onosproject.net.host.HostDescription;
+import org.onosproject.net.host.HostProvider;
+import org.onosproject.net.host.HostProviderRegistry;
+import org.onosproject.net.host.HostProviderService;
+import org.onosproject.net.provider.AbstractProviderService;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.ovsdb.controller.DefaultEventSubject;
+import org.onosproject.ovsdb.controller.EventSubject;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbDatapathId;
+import org.onosproject.ovsdb.controller.OvsdbEvent;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbIfaceId;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbNodeListener;
+import org.onosproject.ovsdb.controller.OvsdbPortName;
+import org.onosproject.ovsdb.controller.OvsdbPortNumber;
+import org.onosproject.ovsdb.controller.OvsdbPortType;
+
+/**
+ * Test for ovsdb host provider.
+ */
+public class OvsdbHostProviderTest {
+ private static final MacAddress MAC = MacAddress
+ .valueOf("00:00:11:00:00:01");
+ private final OvsdbHostProvider provider = new OvsdbHostProvider();
+ private final TestHostRegistry hostRegistry = new TestHostRegistry();
+ protected OvsdbControllerTest controller = new OvsdbControllerTest();
+ private TestHostProviderService providerService;
+
+ @Before
+ public void setUp() {
+ provider.providerRegistry = hostRegistry;
+ provider.controller = controller;
+ provider.activate();
+ }
+
+ @Test
+ public void basics() {
+ assertNotNull("registration expected", providerService);
+ assertEquals("incorrect provider", provider, providerService.provider());
+ }
+
+ @Test
+ public void portAdded() {
+ DefaultEventSubject eventSubject = new DefaultEventSubject(MAC, null,
+ new OvsdbPortName("portName"),
+ new OvsdbPortNumber(0L),
+ new OvsdbDatapathId("10002"),
+ new OvsdbPortType("vxlan"),
+ new OvsdbIfaceId("102345"));
+ controller.ovsdbEventListener
+ .handle(new OvsdbEvent<EventSubject>(
+ OvsdbEvent.Type.PORT_ADDED,
+ eventSubject));
+ assertNotNull("never went throught the provider service",
+ providerService.added);
+
+ }
+
+ @Test
+ public void portRemoved() {
+ DefaultEventSubject eventSubject = new DefaultEventSubject(MAC, null,
+ new OvsdbPortName("portName"),
+ new OvsdbPortNumber(0L),
+ new OvsdbDatapathId("10002"),
+ new OvsdbPortType("vxlan"),
+ new OvsdbIfaceId("102345"));
+ controller.ovsdbEventListener
+ .handle(new OvsdbEvent<EventSubject>(
+ OvsdbEvent.Type.PORT_REMOVED,
+ eventSubject));
+ assertEquals("port status unhandled", 1, providerService.removeCount);
+ }
+
+ @After
+ public void tearDown() {
+ provider.deactivate();
+ provider.coreService = null;
+ provider.providerRegistry = null;
+ }
+
+ private class TestHostRegistry implements HostProviderRegistry {
+
+ @Override
+ public HostProviderService register(HostProvider provider) {
+ providerService = new TestHostProviderService(provider);
+ return providerService;
+ }
+
+ @Override
+ public void unregister(HostProvider provider) {
+ }
+
+ @Override
+ public Set<ProviderId> getProviders() {
+ return null;
+ }
+
+ }
+
+ private class TestHostProviderService
+ extends AbstractProviderService<HostProvider>
+ implements HostProviderService {
+
+ DeviceId added = null;
+ DeviceId moved = null;
+ DeviceId spine = null;
+ public int removeCount;
+
+ protected TestHostProviderService(HostProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public void hostDetected(HostId hostId, HostDescription hostDescription) {
+ DeviceId descr = hostDescription.location().deviceId();
+ if (added == null) {
+ added = descr;
+ } else if ((moved == null) && !descr.equals(added)) {
+ moved = descr;
+ } else {
+ spine = descr;
+ }
+ }
+
+ @Override
+ public void hostVanished(HostId hostId) {
+ removeCount++;
+ }
+
+ }
+
+ private class OvsdbControllerTest implements OvsdbController {
+ private OvsdbEventListener ovsdbEventListener = null;
+
+ @Override
+ public void addNodeListener(OvsdbNodeListener listener) {
+
+ }
+
+ @Override
+ public void removeNodeListener(OvsdbNodeListener listener) {
+
+ }
+
+ @Override
+ public void addOvsdbEventListener(OvsdbEventListener listener) {
+ ovsdbEventListener = listener;
+
+ }
+
+ @Override
+ public void removeOvsdbEventListener(OvsdbEventListener listener) {
+ ovsdbEventListener = null;
+
+ }
+
+ @Override
+ public List<OvsdbNodeId> getNodeIds() {
+ return null;
+ }
+
+ @Override
+ public OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId) {
+ return null;
+ }
+ }
+}
diff --git a/framework/src/onos/providers/ovsdb/pom.xml b/framework/src/onos/providers/ovsdb/pom.xml
new file mode 100644
index 00000000..bf215bc0
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-providers</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-ovsdb-providers</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>device</module>
+ <module>host</module>
+ <module>tunnel</module>
+ <module>app</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/providers/ovsdb/tunnel/pom.xml b/framework/src/onos/providers/ovsdb/tunnel/pom.xml
new file mode 100644
index 00000000..46ea585b
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/tunnel/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-providers</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-ovsdb-provider-tunnel</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProvider.java b/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProvider.java
new file mode 100644
index 00000000..244e6fe0
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProvider.java
@@ -0,0 +1,123 @@
+/*
+ * 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.ovsdb.provider.tunnel;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+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.incubator.net.tunnel.Tunnel;
+import org.onosproject.incubator.net.tunnel.TunnelDescription;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.tunnel.TunnelProvider;
+import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
+import org.onosproject.incubator.net.tunnel.TunnelProviderService;
+import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.ElementId;
+import org.onosproject.net.Path;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+
+/**
+ * Provider which uses when tunnel added/removed.
+ */
+@Component(immediate = true)
+@Service
+public class OvsdbTunnelProvider extends AbstractProvider
+ implements TunnelProvider {
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected TunnelProviderRegistry providerRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected TunnelService tunnelService;
+
+ private TunnelProviderService providerService;
+
+ @Activate
+ public void activate() {
+ providerService = providerRegistry.register(this);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ providerRegistry.unregister(this);
+ providerService = null;
+ log.info("Stopped");
+ }
+
+ public OvsdbTunnelProvider() {
+ super(new ProviderId("ovsdb", "org.onosproject.ovsdb.provider.tunnel"));
+ }
+
+ @Override
+ public void setupTunnel(Tunnel tunnel, Path path) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public void releaseTunnel(Tunnel tunnel) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public void releaseTunnel(ElementId srcElement, Tunnel tunnel) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public void updateTunnel(Tunnel tunnel, Path path) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
+ // TODO: This will be implemented later.
+ }
+
+ @Override
+ public TunnelId tunnelAdded(TunnelDescription tunnel) {
+ return providerService.tunnelAdded(tunnel);
+ }
+
+ @Override
+ public void tunnelRemoved(TunnelDescription tunnel) {
+ providerService.tunnelRemoved(tunnel);
+ }
+
+ @Override
+ public void tunnelUpdated(TunnelDescription tunnel) {
+ providerService.tunnelUpdated(tunnel);
+ }
+
+ @Override
+ public Tunnel tunnelQueryById(TunnelId tunnelId) {
+ // TODO: This will be implemented later.
+ return null;
+ }
+}
diff --git a/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/package-info.java b/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/package-info.java
new file mode 100644
index 00000000..4f8a1095
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/tunnel/src/main/java/org/onosproject/ovsdb/provider/tunnel/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ *Provider that uses ovsdb controller as a means of infrastructure tunnel discovery.
+ *
+ */
+package org.onosproject.ovsdb.provider.tunnel; \ No newline at end of file
diff --git a/framework/src/onos/providers/ovsdb/tunnel/src/test/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProviderTest.java b/framework/src/onos/providers/ovsdb/tunnel/src/test/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProviderTest.java
new file mode 100644
index 00000000..3d1549e5
--- /dev/null
+++ b/framework/src/onos/providers/ovsdb/tunnel/src/test/java/org/onosproject/ovsdb/provider/tunnel/OvsdbTunnelProviderTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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.ovsdb.provider.tunnel;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.DefaultGroupId;
+import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
+import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.incubator.net.tunnel.TunnelDescription;
+import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.tunnel.TunnelName;
+import org.onosproject.incubator.net.tunnel.TunnelProvider;
+import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
+import org.onosproject.incubator.net.tunnel.TunnelProviderService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultLink;
+import org.onosproject.net.DefaultPath;
+import org.onosproject.net.Link;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.provider.AbstractProviderService;
+import org.onosproject.net.provider.ProviderId;
+
+/**
+ * Test for ovsdb tunnel provider.
+ */
+public class OvsdbTunnelProviderTest {
+ private final OvsdbTunnelProvider provider = new OvsdbTunnelProvider();
+ private final TestTunnelRegistry tunnelRegistry = new TestTunnelRegistry();
+ private TestTunnelProviderService providerService;
+
+ @Before
+ public void setUp() {
+ provider.providerRegistry = tunnelRegistry;
+ provider.activate();
+ }
+
+ @Test
+ public void basics() {
+ assertNotNull("registration expected", providerService);
+ assertEquals("incorrect provider", provider, providerService.provider());
+ }
+
+ @Test
+ public void testTunnelAdded() {
+ TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+ .valueOf("192.168.1.1"));
+ TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+ .valueOf("192.168.1.3"));
+ SparseAnnotations annotations = DefaultAnnotations.builder()
+ .set("bandwidth", "1024").build();
+ Link link = new DefaultLink(
+ this.provider.id(),
+ ConnectPoint.deviceConnectPoint("192.168.2.3/20"),
+ ConnectPoint.deviceConnectPoint("192.168.2.4/30"),
+ Link.Type.DIRECT);
+ List<Link> links = new ArrayList<Link>();
+ links.add(link);
+ TunnelDescription tunnel = new DefaultTunnelDescription(
+ TunnelId.valueOf("1234"),
+ src,
+ dst,
+ Tunnel.Type.VXLAN,
+ new DefaultGroupId(0),
+ this.provider.id(),
+ TunnelName.tunnelName("tunnel12"),
+ new DefaultPath(this.provider.id(), links, 0.3),
+ annotations);
+ provider.tunnelAdded(tunnel);
+ assertEquals(1, providerService.tunnelSet.size());
+ }
+
+ @Test
+ public void testTunnelRemoved() {
+ TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+ .valueOf("192.168.1.1"));
+ TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+ .valueOf("192.168.1.3"));
+ SparseAnnotations annotations = DefaultAnnotations.builder()
+ .set("bandwidth", "1024").build();
+ Link link = new DefaultLink(
+ this.provider.id(),
+ ConnectPoint.deviceConnectPoint("192.168.2.3/20"),
+ ConnectPoint.deviceConnectPoint("192.168.2.4/30"),
+ Link.Type.DIRECT);
+ List<Link> links = new ArrayList<Link>();
+ links.add(link);
+ TunnelDescription tunnel = new DefaultTunnelDescription(
+ TunnelId.valueOf("1234"),
+ src,
+ dst,
+ Tunnel.Type.VXLAN,
+ new DefaultGroupId(0),
+ this.provider.id(),
+ TunnelName.tunnelName("tunnel1"),
+ new DefaultPath(this.provider.id(), links, 0.3),
+ annotations);
+ provider.tunnelRemoved(tunnel);
+ assertEquals(0, providerService.tunnelSet.size());
+ }
+
+ @After
+ public void tearDown() {
+ provider.deactivate();
+ provider.providerRegistry = null;
+ }
+
+ private class TestTunnelRegistry implements TunnelProviderRegistry {
+
+ @Override
+ public TunnelProviderService register(TunnelProvider provider) {
+ providerService = new TestTunnelProviderService(provider);
+ return providerService;
+ }
+
+ @Override
+ public void unregister(TunnelProvider provider) {
+
+ }
+
+ @Override
+ public Set<ProviderId> getProviders() {
+ return null;
+ }
+
+ }
+
+ private class TestTunnelProviderService
+ extends AbstractProviderService<TunnelProvider>
+ implements TunnelProviderService {
+ Set<TunnelDescription> tunnelSet = new HashSet<TunnelDescription>();
+
+ protected TestTunnelProviderService(TunnelProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public TunnelId tunnelAdded(TunnelDescription tunnel) {
+ tunnelSet.add(tunnel);
+ return null;
+ }
+
+ @Override
+ public void tunnelRemoved(TunnelDescription tunnel) {
+ tunnelSet.remove(tunnel);
+ }
+
+ @Override
+ public void tunnelUpdated(TunnelDescription tunnel) {
+
+ }
+
+ @Override
+ public Tunnel tunnelQueryById(TunnelId tunnelId) {
+ return null;
+ }
+
+ }
+}