Skip to content

Commit cad4227

Browse files
Adds a REST interface application to ovsdb
Change-Id: Ife8adac92ed8dc3fda6ffd97bdd783ecc3af9f35
1 parent 1845280 commit cad4227

15 files changed

+1424
-0
lines changed

ovsdb-rest/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# OVSDBREST ONOS APPLICATION
2+
3+
This application provides a ***minimal*** interface to an ovsdb device by exposing REST APIs.
4+
The API allows to create/delete a bridge, attach/remove ports from an existing bridge, create peer patch and setup GRE tunnels.
5+
6+
## Install
7+
To install the application on a running onos instance run the following steps.
8+
9+
- first of all, if it is not ready installed, you need to install the ovsdb driver provided by onos. On your onos root directory run:
10+
11+
cd drivers/ovsdb/
12+
onos-app {onos-address} reinstall target/onos-drivers-ovsdb-1.7.0-SNAPSHOT.oar
13+
14+
- then build the source code of the ovsdbrest application through maven:
15+
16+
git clone https://github.com/netgroup-polito/onos-applications
17+
cd onos-applications/ovsdbrest
18+
mvn clean install
19+
20+
- Finally you can install the application through the command:
21+
22+
onos-app {onos-address} reinstall target/onos-app-ovsdbrest-1.7.0-SNAPSHOT.oar
23+
24+
(onos-address is the ip-address of onos server, for example 192.168.123.1)
25+
26+
27+
## Activate
28+
After installing the application, you can activate it through the onos cli by typing:
29+
30+
app activate org.onosproject.ovsdbrest
31+
32+
To check that the app has been activated type log:tail from the onos cli.
33+
34+
35+
## Configure
36+
After activating the application you need to configure the ovsdb node IP. This is done by using the onos Network Configuration system.
37+
38+
- Send a REST request as follows:
39+
40+
**POST http://{onos-address}:8181/onos/v1/network/configuration/**
41+
42+
```json
43+
{
44+
"apps": {
45+
"org.onosproject.ovsdbrest": {
46+
"ovsdbrest": {
47+
"nodes": [
48+
{
49+
"ovsdbIp": "192.168.123.2",
50+
"ovsdbPort": "6632"
51+
}
52+
]
53+
}
54+
}
55+
}
56+
}
57+
```
58+
59+
Check your ovsdb configuration to get the correct ip and port for the ovsdb node.
60+
The request uses basic HTTP authentication, so you need to provide onos username and password.
61+
To verify that the configuration has been correctly pushed you can type log:tail from the onos cli.
62+
The app will start contacting the ovsdb nodes and you should see some related logs from the onos cli.
63+
64+
65+
## API
66+
67+
- Create/Delete bridge:
68+
69+
**POST http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}**
70+
71+
**DELETE http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}**
72+
73+
- Add/Remove a port in a bridge:
74+
75+
**POST http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}/port/{port-name}**
76+
77+
**DELETE http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}/port/{port-name}**
78+
79+
- Create patch port:
80+
81+
**POST http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}/port/{port-name}/patch_peer/{peer-port}**
82+
83+
- Create/Delete a GRE tunnel:
84+
85+
**POST http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}/port/{port-name}/gre/{local-ip}/{remote-ip}/{key}**
86+
87+
**DELETE http://{onos-address}:8181/onos/ovsdb/{ovsdb-ip}/bridge/{bridge-name}/port/{port-name}/gre**

ovsdb-rest/pom.xml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.onosproject</groupId>
9+
<artifactId>onos-dependencies</artifactId>
10+
<version>1.9.0-rc2</version>
11+
<relativePath/><!-- parent is remote -->
12+
</parent>
13+
14+
<artifactId>ovsdb-rest</artifactId>
15+
<version>1.9.0-SNAPSHOT</version>
16+
<packaging>bundle</packaging>
17+
18+
<description>REST apis for bridge and GRE port setup in ovs</description>
19+
20+
<properties>
21+
<onos.app.name>org.onosproject.ovsdbrest</onos.app.name>
22+
<web.context>/onos/ovsdb</web.context>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<onos.app.url>http://onosproject.org</onos.app.url>
25+
<onos.app.title>REST apis for bridge and GRE port setup in ovs</onos.app.title>
26+
<onos.app.requires>
27+
org.onosproject.ovsdb-base,
28+
org.onosproject.drivers.ovsdb
29+
</onos.app.requires>
30+
<onos.version>1.9.0-rc2</onos.version>
31+
</properties>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.osgi</groupId>
36+
<artifactId>org.osgi.core</artifactId>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.osgi</groupId>
41+
<artifactId>org.osgi.compendium</artifactId>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>org.onosproject</groupId>
46+
<artifactId>onos-core-serializers</artifactId>
47+
<version>${onos.version}</version>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.onosproject</groupId>
52+
<artifactId>onos-core-common</artifactId>
53+
<version>${onos.version}</version>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.onosproject</groupId>
58+
<artifactId>onlab-misc</artifactId>
59+
<version>${onos.version}</version>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>org.onosproject</groupId>
64+
<artifactId>onos-api</artifactId>
65+
<version>${onos.version}</version>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>org.onosproject</groupId>
70+
<artifactId>onos-ovsdb-rfc</artifactId>
71+
<version>1.6.0</version>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>org.onosproject</groupId>
76+
<artifactId>onos-ovsdb-api</artifactId>
77+
<version>1.6.0</version>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>javax.ws.rs</groupId>
82+
<artifactId>javax.ws.rs-api</artifactId>
83+
<version>2.0.1</version>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>org.onosproject</groupId>
88+
<artifactId>onlab-osgi</artifactId>
89+
<version>${onos.version}</version>
90+
</dependency>
91+
92+
<dependency>
93+
<groupId>org.onosproject</groupId>
94+
<artifactId>onos-rest</artifactId>
95+
<version>${onos.version}</version>
96+
</dependency>
97+
98+
<dependency>
99+
<groupId>org.glassfish.jersey.containers</groupId>
100+
<artifactId>jersey-container-servlet</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.glassfish.jersey.containers</groupId>
104+
<artifactId>jersey-container-servlet-core</artifactId>
105+
</dependency>
106+
</dependencies>
107+
108+
<build>
109+
<plugins>
110+
<plugin>
111+
<groupId>org.apache.felix</groupId>
112+
<artifactId>maven-bundle-plugin</artifactId>
113+
<extensions>true</extensions>
114+
<configuration>
115+
<instructions>
116+
<_wab>src/main/webapp/</_wab>
117+
<Bundle-SymbolicName>
118+
${project.groupId}.${project.artifactId}
119+
</Bundle-SymbolicName>
120+
<Import-Package>
121+
*,org.glassfish.jersey.servlet
122+
</Import-Package>
123+
<Web-ContextPath>${web.context}</Web-ContextPath>
124+
</instructions>
125+
</configuration>
126+
</plugin>
127+
</plugins>
128+
</build>
129+
<repositories>
130+
<repository>
131+
<id>ovsdb-api</id>
132+
<url>https://oss.sonatype.org/content/repositories/snapshots/org/onosproject/onos-ovsdb-api/1.8.0-SNAPSHOT/</url>
133+
</repository>
134+
<repository>
135+
<id>ovsdb-rfc</id>
136+
<url>https://oss.sonatype.org/content/repositories/snapshots/org/onosproject/onos-ovsdb-rfc/1.8.0-SNAPSHOT/</url>
137+
</repository>
138+
</repositories>
139+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2017-present Open Networking Laboratory
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.onosproject.ovsdbrest;
18+
19+
/**
20+
* Entity capable of handling a subject connected and disconnected situation.
21+
*/
22+
public interface ConnectionHandler<T> {
23+
24+
/**
25+
* Processes the connected subject.
26+
*
27+
* @param subject subject
28+
*/
29+
void connected(T subject);
30+
31+
/**
32+
* Processes the disconnected subject.
33+
*
34+
* @param subject subject.
35+
*/
36+
void disconnected(T subject);
37+
}
38+

0 commit comments

Comments
 (0)