[ONOS-3689] Implement skeleton of Neutron L3 service plugin
- Added event handlers (Floatingip_CUD(Create, Update, Delete), Router_CUD, and RouterInterface_CUD).
- Added packet handlers about ICMP and pNAT.
- Added the models of openstack router, router interface, external gateway and floatingIP.
- Fixed pom.xml
- Added external_fixed_IP information for PNAT and renamed SNAT to PNAT in OpenstackExternalGateway
- Fixed java docs in OpenstackRoutingService.java
Change-Id: Ia694614cf8885d81a66fc4659db2fa0c5de5e950
diff --git a/apps/openstackrouting/pom.xml b/apps/openstackrouting/pom.xml
new file mode 100644
index 0000000..30b8866
--- /dev/null
+++ b/apps/openstackrouting/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-openstackrouting</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>SONA Openstack Routing Application</description>
+
+ <properties>
+ <onos.app.name>org.onosproject.openstackrouting</onos.app.name>
+ <onos.app.category>default</onos.app.category>
+ <onos.app.url>http://onosproject.org</onos.app.url>
+ <onos.app.readme>SONA Openstack Routing Application</onos.app.readme>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackExternalGateway.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackExternalGateway.java
new file mode 100644
index 0000000..6b4d1ea
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackExternalGateway.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+import org.onlab.packet.Ip4Address;
+
+import java.util.HashMap;
+
+/**
+ * A configurable external gateway modes extension model in openstack router.
+ */
+public final class OpenstackExternalGateway {
+
+ private String networkId;
+ private boolean enablePNAT;
+ private HashMap<String, Ip4Address> externalFixedIps;
+
+ private OpenstackExternalGateway(String networkId, boolean enablePNAT,
+ HashMap externalFixedIps) {
+ this.networkId = networkId;
+ this.enablePNAT = enablePNAT;
+ this.externalFixedIps = externalFixedIps;
+ }
+
+ /**
+ * Returns network ID.
+ *
+ * @return Network ID
+ */
+ public String networkId() {
+ return networkId;
+ }
+
+ /**
+ * Returns the PNAT status for external gateway.
+ *
+ * @return PNAT status
+ */
+ public boolean isEnablePNAT() {
+ return enablePNAT;
+ }
+
+ /**
+ * An Openstack External Gateway Builder class.
+ */
+ public static final class Builder {
+ private String networkId;
+ private boolean enablePNAT;
+ private HashMap<String, Ip4Address> externalFixedIPs;
+
+ Builder() {
+ externalFixedIPs = new HashMap<>();
+ }
+
+ /**
+ * Sets network ID.
+ *
+ * @param networkId Network ID
+ * @return Builder object
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return this;
+ }
+
+ /**
+ * Sets whether PNAT status is enabled or not.
+ *
+ * @param enablePNAT true if PNAT status is enabled, false otherwise
+ * @return Builder object
+ */
+ public Builder enablePNAT(boolean enablePNAT) {
+ this.enablePNAT = enablePNAT;
+ return this;
+ }
+
+ /**
+ * Sets external fixed IP address information.
+ *
+ * @param externalFixedIPs External fixed IP information
+ * @return Builder object
+ */
+ public Builder externalFixedIPs(HashMap<String, Ip4Address> externalFixedIPs) {
+ this.externalFixedIPs.putAll(externalFixedIPs);
+ return this;
+ }
+
+ /**
+ * Builds an OpenstackExternalGateway object.
+ *
+ * @return OpenstackExternalGateway object
+ */
+ public OpenstackExternalGateway build() {
+ return new OpenstackExternalGateway(networkId, enablePNAT, externalFixedIPs);
+ }
+ }
+
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIP.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIP.java
new file mode 100644
index 0000000..feb05f9
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIP.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+import org.onlab.packet.Ip4Address;
+
+/**
+ * An Openstack Neutron Floating IP Model.
+ */
+public final class OpenstackFloatingIP {
+
+ public enum FloatingIPStatus {
+ UP,
+ DOWN,
+ ACTIVE,
+ }
+
+ private String tenantId;
+ private String networkId;
+ private Ip4Address fixedIpAddress;
+ private String portId;
+ private String routerId;
+ private String id;
+ private Ip4Address floatingIpAddress;
+ private FloatingIPStatus status;
+
+ private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId,
+ String networkId, Ip4Address fixedIpAddress, String portId,
+ String routerId, Ip4Address floatingIpAddress) {
+ this.status = status;
+ this.id = id;
+ this.tenantId = tenantId;
+ this.networkId = networkId;
+ this.fixedIpAddress = fixedIpAddress;
+ this.portId = portId;
+ this.routerId = routerId;
+ this.floatingIpAddress = floatingIpAddress;
+ }
+
+ /**
+ * Returns floating ip status.
+ *
+ * @return floating ip status
+ */
+ public FloatingIPStatus status() {
+ return status;
+ }
+
+ /**
+ * Returns floating ip`s ID.
+ *
+ * @return floating ip`s ID
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns tenant ID.
+ *
+ * @return tenant ID
+ */
+ public String tenantId() {
+ return tenantId;
+ }
+
+ /**
+ * Returns network ID.
+ *
+ * @return network ID
+ */
+ public String networkId() {
+ return networkId;
+ }
+
+ /**
+ * Returns fixed IP Address.
+ *
+ * @return fixed IP Address
+ */
+ public Ip4Address fixedIpAddress() {
+ return fixedIpAddress;
+ }
+
+ /**
+ * Returns port ID.
+ *
+ * @return port ID
+ */
+ public String portId() {
+ return portId;
+ }
+
+ /**
+ * Returns router ID.
+ *
+ * @return router ID
+ */
+ public String routerId() {
+ return routerId;
+ }
+
+ /**
+ * Returns floating IP address.
+ *
+ * @return Floating IP address
+ */
+ public Ip4Address floatingIpAddress() {
+ return floatingIpAddress;
+ }
+
+ /**
+ * An Openstack Floating IP Builder class.
+ */
+ public static final class Builder {
+ private String tenantId;
+ private String networkId;
+ private Ip4Address fixedIpAddress;
+ private String portId;
+ private String routerId;
+ private String id;
+ private Ip4Address floatingIpAddress;
+ private FloatingIPStatus status;
+
+ /**
+ * Sets tenant ID.
+ *
+ * @param tenantId tenant ID
+ * @return Builder object
+ */
+ public Builder tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ /**
+ * Sets floating IP status.
+ *
+ * @param status Floating IP status
+ * @return Builder object
+ */
+ public Builder status(FloatingIPStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * Sets Floating IP`s ID.
+ *
+ * @param id Floating IP`s ID
+ * @return Builder object
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Sets network ID.
+ *
+ * @param networkId Network ID
+ * @return Builder object
+ */
+ public Builder networkId(String networkId) {
+ this.networkId = networkId;
+ return this;
+ }
+
+ /**
+ * Sets fixed IP address.
+ *
+ * @param fixedIpAddress Fixed IP address
+ * @return Builder object
+ */
+ public Builder fixedIpAddress(Ip4Address fixedIpAddress) {
+ this.fixedIpAddress = fixedIpAddress;
+ return this;
+ }
+
+ /**
+ * Sets port ID.
+ *
+ * @param portId port ID
+ * @return Builder object
+ */
+ public Builder portId(String portId) {
+ this.portId = portId;
+ return this;
+ }
+
+ /**
+ * Sets router ID.
+ *
+ * @param routerId router ID
+ * @return Builder object
+ */
+ public Builder routerId(String routerId) {
+ this.routerId = routerId;
+ return this;
+ }
+
+ /**
+ * Sets floating IP address.
+ *
+ * @param floatingIpAddress Floating IP address
+ * @return Builder object
+ */
+ public Builder floatingIpAddress(Ip4Address floatingIpAddress) {
+ this.floatingIpAddress = floatingIpAddress;
+ return this;
+ }
+
+ /**
+ * Builds an OpenstackFloatingIP object.
+ *
+ * @return OpenstackFloatingIP object
+ */
+ public OpenstackFloatingIP build() {
+ return new OpenstackFloatingIP(status, id, tenantId, networkId,
+ fixedIpAddress, portId, routerId, floatingIpAddress);
+
+ }
+ }
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIPHandler.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIPHandler.java
new file mode 100644
index 0000000..4255f50
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackFloatingIPHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes.
+ */
+public class OpenstackFloatingIPHandler implements Runnable {
+
+ volatile AbstractEvent event;
+ OpenstackFloatingIPHandler(AbstractEvent event) {
+ this.event = event;
+ }
+
+ @Override
+ public void run() {
+
+ }
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackICMPHandler.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackICMPHandler.java
new file mode 100644
index 0000000..fdc0ef97
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackICMPHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+import org.onosproject.net.packet.PacketContext;
+
+/**
+ * Handle ICMP packet processing for Managing Flow Rules In Openstack Nodes.
+ */
+public class OpenstackICMPHandler implements Runnable {
+
+ volatile PacketContext context;
+ OpenstackICMPHandler(PacketContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public void run() {
+
+ }
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackPNATHandler.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackPNATHandler.java
new file mode 100644
index 0000000..2db73e3
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackPNATHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+import org.onosproject.net.packet.PacketContext;
+
+/**
+ * Handle NAT packet processing for Managing Flow Rules In Openstack Nodes.
+ */
+public class OpenstackPNATHandler implements Runnable {
+
+ volatile PacketContext context;
+ OpenstackPNATHandler(PacketContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public void run() {
+
+ }
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouter.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouter.java
new file mode 100644
index 0000000..213ca28
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouter.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+/**
+ * An Openstack Neutron Router Model.
+ */
+public final class OpenstackRouter {
+
+ public enum RouterStatus {
+ UP,
+ DOWN,
+ ACTIVE,
+ }
+
+ private String tenantId;
+ private String id;
+ private String name;
+ private RouterStatus status;
+ private boolean adminStateUp;
+ private OpenstackExternalGateway gatewayExternalInfo;
+
+ private OpenstackRouter(String id, String tenantId, String name, RouterStatus status,
+ boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.status = status;
+ this.adminStateUp = adminStateUp;
+ this.gatewayExternalInfo = gatewayExternalInfo;
+
+ }
+
+ /**
+ * Returns tenant ID.
+ *
+ * @return tenant ID
+ */
+ public String tenantId() {
+ return tenantId;
+ }
+
+ /**
+ * Returns router ID.
+ *
+ * @return router ID
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns router name.
+ *
+ * @return router name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns router status.
+ *
+ * @return router stauts
+ */
+ public RouterStatus status() {
+ return status;
+ }
+
+ /**
+ * Returns whether admin state up or not.
+ *
+ * @return true if admin state up, false otherwise
+ */
+ public boolean adminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * Returns external gateway information.
+ *
+ * @return external gateway information
+ */
+ public OpenstackExternalGateway gatewayExternalInfo() {
+ return gatewayExternalInfo;
+ }
+
+ /**
+ * An Openstack Router Builder class.
+ */
+ public static final class Builder {
+
+ private String tenantId;
+ private String id;
+ private String name;
+ private RouterStatus status;
+ private Boolean adminStateUp;
+ private OpenstackExternalGateway gatewayExternalInfo;
+
+ /**
+ * Sets router ID.
+ *
+ * @param id router ID
+ * @return Builder object
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Sets router name.
+ *
+ * @param name router name
+ * @return Builder object
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Sets router status.
+ *
+ * @param status router status
+ * @return Builder object
+ */
+ public Builder status(RouterStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * Sets tenant ID.
+ *
+ * @param tenantId Tenant ID
+ * @return Builder object
+ */
+ public Builder tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ /**
+ * Sets whether admin state up or not.
+ *
+ * @param adminStateUp true if admin state is up, false otherwise
+ * @return Builder object
+ */
+ public Builder adminStateUp(boolean adminStateUp) {
+ this.adminStateUp = adminStateUp;
+ return this;
+ }
+
+ /**
+ * Sets external gateway information.
+ *
+ * @param gatewayExternalInfo external gateway information
+ * @return Builder object
+ */
+ public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) {
+ this.gatewayExternalInfo = gatewayExternalInfo;
+ return this;
+ }
+
+ /**
+ * Builds an OpenstackRouter object.
+ *
+ * @return OpenstasckRouter object
+ */
+ public OpenstackRouter build() {
+ return new OpenstackRouter(id, tenantId, name, status,
+ adminStateUp, gatewayExternalInfo);
+ }
+ }
+
+
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouterInterface.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouterInterface.java
new file mode 100644
index 0000000..8404ea0
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouterInterface.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+/**
+ * An Openstack Neutron Router Interface Model.
+ */
+public final class OpenstackRouterInterface {
+ private String id;
+ private String tenantId;
+ private String subnetId;
+ private String portId;
+
+ private OpenstackRouterInterface(String id, String tenantId,
+ String subnetId, String portId) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.subnetId = subnetId;
+ this.portId = portId;
+ }
+
+ /**
+ * Returns Router Interface ID.
+ *
+ * @return router interface ID
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns tenant ID.
+ *
+ * @return tenant ID
+ */
+ public String tenantId() {
+ return tenantId;
+ }
+
+ /**
+ * Returns subnet ID.
+ *
+ * @return subnet ID
+ */
+ public String subnetId() {
+ return subnetId;
+ }
+
+ /**
+ * Returns port ID.
+ *
+ * @return port ID
+ */
+ public String portId() {
+ return portId;
+ }
+
+ /**
+ * An Openstack Router Interface Builder class.
+ */
+ public static final class Builder {
+ private String id;
+ private String tenantId;
+ private String subnetId;
+ private String portId;
+
+ /**
+ * Sets Router Interface ID.
+ *
+ * @param id router interface ID
+ * @return Builder object
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Sets tenant ID.
+ *
+ * @param tenantId tenant ID
+ * @return Builder object
+ */
+ public Builder tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ /**
+ * Sets subnet ID.
+ *
+ * @param subnetId subnet ID
+ * @return Builder object
+ */
+ public Builder subnetId(String subnetId) {
+ this.subnetId = subnetId;
+ return this;
+ }
+
+ /**
+ * Sets port ID.
+ *
+ * @param portId port ID
+ * @return Builder object
+ */
+ public Builder portId(String portId) {
+ this.portId = portId;
+ return this;
+ }
+
+
+ /**
+ * Builds an Openstack Router Interface object.
+ *
+ * @return OpenstackRouterInterface object
+ */
+ public OpenstackRouterInterface build() {
+ return new OpenstackRouterInterface(id, tenantId, subnetId, portId);
+ }
+
+ }
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingManager.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingManager.java
new file mode 100644
index 0000000..87a6c99
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingManager.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+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.Ethernet;
+import org.onlab.packet.IPv4;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.net.packet.InboundPacket;
+import org.onosproject.net.packet.PacketContext;
+import org.onosproject.net.packet.PacketProcessor;
+import org.onosproject.net.packet.PacketService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.onlab.util.Tools.groupedThreads;
+
+@Service
+@Component(immediate = true)
+/**
+ * Populates flow rules about L3 functionality for VMs in Openstack.
+ */
+public class OpenstackRoutingManager implements OpenstackRoutingService {
+ private static Logger log = LoggerFactory
+ .getLogger(OpenstackRoutingManager.class);
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected PacketService packetService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DriverService driverService;
+
+ private ApplicationId appId;
+ private OpenstackICMPHandler icmpHandler;
+ private OpenstackPNATHandler natHandler;
+ private OpenstackFloatingIPHandler floatingIPHandler;
+ private OpenstackRoutingRulePopulator openstackRoutingRulePopulator;
+
+ private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
+ private ExecutorService l3EventExcutorService =
+ Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "L3-event"));
+ private ExecutorService icmpEventExcutorService =
+ Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "icmp-event"));
+
+ @Activate
+ protected void activate() {
+ appId = coreService.registerApplication("org.onosproject.openstackrouting");
+ packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
+
+ log.info("onos-openstackrouting started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ packetService.removeProcessor(internalPacketProcessor);
+ log.info("onos-openstackrouting stopped");
+ }
+
+
+ @Override
+ public void createFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
+
+ }
+
+ @Override
+ public void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
+
+ }
+
+ @Override
+ public void deleteFloatingIP(String id) {
+
+ }
+
+ @Override
+ public void createRouter(OpenstackRouter openstackRouter) {
+
+ }
+
+ @Override
+ public void updateRouter(OpenstackRouter openstackRouter) {
+
+ }
+
+ @Override
+ public void deleteRouter(String id) {
+
+ }
+
+ @Override
+ public void createRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
+
+ }
+
+ @Override
+ public void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
+
+ }
+
+ @Override
+ public void deleteRouterInterface(String id) {
+
+ }
+
+ private class InternalPacketProcessor implements PacketProcessor {
+
+ @Override
+ public void process(PacketContext context) {
+
+ if (context.isHandled()) {
+ return;
+ }
+
+ InboundPacket pkt = context.inPacket();
+ Ethernet ethernet = pkt.parsed();
+
+ if (ethernet != null && ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
+ IPv4 iPacket = (IPv4) ethernet.getPayload();
+ switch (iPacket.getProtocol()) {
+ case IPv4.PROTOCOL_ICMP:
+ icmpEventExcutorService.execute(new OpenstackICMPHandler(context));
+ break;
+ default:
+ l3EventExcutorService.execute(new OpenstackPNATHandler(context));
+ break;
+ }
+
+ }
+
+
+ }
+ }
+
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingRulePopulator.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingRulePopulator.java
new file mode 100644
index 0000000..10a41ec
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingRulePopulator.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+/**
+ * Populates Routing Flow Rules.
+ */
+public class OpenstackRoutingRulePopulator {
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingService.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingService.java
new file mode 100644
index 0000000..aca25fb
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRoutingService.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 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.openstackrouting;
+
+/**
+ * The Interface of Openstack Routing.
+ */
+public interface OpenstackRoutingService {
+
+ /**
+ * Stores the Floating IP information created by Openstack.
+ *
+ * @param openstackFloatingIP Floating IP information
+ */
+ void createFloatingIP(OpenstackFloatingIP openstackFloatingIP);
+
+ /**
+ * Updates flow rules corresponding to the Floating IP information updated by Openstack.
+ *
+ * @param openstackFloatingIP Floating IP information
+ */
+ void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP);
+
+ /**
+ * Removes flow rules corresponding to Floating IP information deleted by Openstack.
+ *
+ * @param id Deleted Floating IP`s ID
+ */
+ void deleteFloatingIP(String id);
+
+ /**
+ * Stores the router information created by Openstack.
+ *
+ * @param openstackRouter Floating IP information
+ */
+ void createRouter(OpenstackRouter openstackRouter);
+
+ /**
+ * Updates flow rules corresponding to the router information updated by Openstack.
+ *
+ * @param openstackRouter Router information
+ */
+ void updateRouter(OpenstackRouter openstackRouter);
+
+ /**
+ * Removes flow rules corresponding to the router information deleted by Openstack.
+ *
+ * @param id Deleted router`s ID
+ */
+ void deleteRouter(String id);
+
+ /**
+ * Stores the router information created by Openstack.
+ *
+ * @param openstackRouterInterface Floating IP information
+ */
+ void createRouterInterface(OpenstackRouterInterface openstackRouterInterface);
+
+ /**
+ * Updates flow rules corresponding to the router information updated by Openstack.
+ *
+ * @param openstackRouterInterface Router information
+ */
+ void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
+
+ /**
+ * Removes flow rules corresponding to the router information deleted by Openstack.
+ *
+ * @param id Deleted router`s ID
+ */
+ void deleteRouterInterface(String id);
+
+
+}
diff --git a/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/package-info.java b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/package-info.java
new file mode 100644
index 0000000..1079f4e
--- /dev/null
+++ b/apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Application for OpenstackRouting.
+ */
+package org.onosproject.openstackrouting;
\ No newline at end of file
diff --git a/apps/pom.xml b/apps/pom.xml
index 79e7466..ae99224 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -65,6 +65,7 @@
<module>cpman</module>
<module>events</module>
<module>vrouter</module>
+ <module>openstackrouting</module>
</modules>
<properties>