Initial code for Southbound plugin to the OpenContrail Platform 78/8478/1
authorAric Gardner <agardner@linuxfoundation.org>
Thu, 22 May 2014 17:47:38 +0000 (17:47 +0000)
committerankit_juniper <ankita@juniper.net>
Tue, 1 Jul 2014 07:30:32 +0000 (13:00 +0530)
Change-Id: I4e5e47f90d89a608efdde7f88e2acb5aecafb794
Signed-off-by: ankit_juniper <ankita@juniper.net>
12 files changed:
LICENSE [new file with mode: 0755]
README.md [new file with mode: 0755]
commons/parent/pom.xml [new file with mode: 0755]
neutron/pom.xml [new file with mode: 0755]
neutron/src/main/java/org/opendaylight/plugin2oc/neutron/Activator.java [new file with mode: 0755]
neutron/src/main/java/org/opendaylight/plugin2oc/neutron/NetworkHandler.java [new file with mode: 0755]
neutron/src/main/java/org/opendaylight/plugin2oc/neutron/PortHandler.java [new file with mode: 0755]
neutron/src/main/java/org/opendaylight/plugin2oc/neutron/SubnetHandler.java [new file with mode: 0755]
neutron/src/test/java/org/opendaylight/plugin2oc/neutron/NetworkHandlerTest.java [new file with mode: 0755]
neutron/src/test/java/org/opendaylight/plugin2oc/neutron/PortHandlerTest.java [new file with mode: 0755]
neutron/src/test/java/org/opendaylight/plugin2oc/neutron/SubnetHandlerTest.java [new file with mode: 0755]
pom.xml [new file with mode: 0755]

diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..e7cc497
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,70 @@
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+i) changes to the Program, and
+ii) additions to the Program;
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+b) its license agreement:
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+a) it must be made available under this Agreement; and
+b) a copy of this Agreement must be included with each copy of the Program.
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
diff --git a/README.md b/README.md
new file mode 100755 (executable)
index 0000000..7c200a1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+Southbound plugin to the OpenContrail platform
+=======================
+
+Plugin overview
+
+
+This project will provide the integration/interworking between the OpenDaylight controller and OpenContrail. This combined open-source solution will seamlessly enable OpenContrail capabilities within the OpenDaylight project. The southbound plugin v1.0 for OpenDaylight project will enable the continuous integration with the OpenContrail as it develops and evolves.
+
+The plugin will enable OpenDaylight to utilize OpenContrail’s networking capabilities such as:
+
+1. Cloud Networking – Dynamic and reliable management of virtual overlay networks with scalability important for Private clouds for Enterprises or Service Providers, Infrastructure as a Service (IaaS) and Virtual Private Clouds (VPCs) for Cloud Service Providers.
+
+2. Network Function Virtualization (NFV) in Service Provider Network and service chaining for enterprise deployments – Streamlined service chaining utilizing L3 overlay solution.
diff --git a/commons/parent/pom.xml b/commons/parent/pom.xml
new file mode 100755 (executable)
index 0000000..18f9c5c
--- /dev/null
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+  <prerequisites>
+    <maven>3.0</maven>
+  </prerequisites>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.1</version>
+  </parent>
+  <groupId>org.opendaylight.plugin2oc</groupId>
+  <artifactId>commons.plugin2oc</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <sonar.host.url> http://localhost:9000/ </sonar.host.url>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <java.version.source>1.7</java.version.source>
+    <java.version.target>1.7</java.version.target>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration>
+            <source>${java.version.source}</source>
+            <target>${java.version.target}</target>
+            <testSource>${java.version.source}</testSource>
+            <testTarget>${java.version.target}</testTarget>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  <repositories>
+    <!-- Opendaylight public group -->
+    <repository>
+      <id>opendaylight-public</id>
+      <name>opendaylight-public</name>
+      <url>${nexusproxy}/groups/public/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+    <!-- OpenDayLight Released artifact -->
+    <repository>
+      <id>opendaylight-release</id>
+      <name>opendaylight-release</name>
+      <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release/</url>
+    </repository>
+    <!-- OpenDayLight Snapshot artifact -->
+    <repository>
+      <id>opendaylight-snapshot</id>
+      <name>opendaylight-snapshot</name>
+      <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+    </repository>
+  </repositories>
+
+  <pluginRepositories>
+    <pluginRepository>
+      <id>opendaylight-public</id>
+      <name>opendaylight-public</name>
+      <url>http://nexus.opendaylight.org/content/groups/public/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </pluginRepository>
+    <pluginRepository>
+      <id>opendaylight-release</id>
+      <name>central2</name>
+      <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release/</url>
+    </pluginRepository>
+    <pluginRepository>
+      <id>opendaylight-snapshot</id>
+      <name>central2</name>
+      <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+    </pluginRepository>
+  </pluginRepositories>
+</project>
\ No newline at end of file
diff --git a/neutron/pom.xml b/neutron/pom.xml
new file mode 100755 (executable)
index 0000000..5bed3af
--- /dev/null
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.opendaylight.plugin2oc</groupId>
+        <artifactId>commons.plugin2oc</artifactId>
+        <version>0.1</version>
+        <relativePath>../commons/parent</relativePath>
+    </parent>
+    <artifactId>plugin2oc.neutron</artifactId>
+    <version>0.1</version>
+    <packaging>bundle</packaging>
+    <repositories>
+        <repository>
+            <id>juniper-contrail</id>
+            <url>https://github.com/Juniper/contrail-maven/raw/master/releases</url>
+        </repository>
+        <repository>
+            <id>opendaylight-release</id>
+            <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release</url>
+        </repository>
+    </repositories>
+    <properties>
+        <guava.version>14.0.1</guava.version>
+        <xtend.version>2.4.3</xtend.version>
+        <bundle.plugin.version>2.4.0</bundle.plugin.version>
+        <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
+        <sonar.host.url> http://localhost:9000/</sonar.host.url>
+    </properties>
+    <build>
+        <defaultGoal>install</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.6</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                    <Import-Package>
+                            org.opendaylight.controller.networkconfig.neutron,
+                            org.opendaylight.controller.sal.binding.api,
+                            org.apache.felix.dm,
+                            org.slf4j,
+                            org.apache.http.*;version="4.3.2",
+                            org.osgi.framework,
+                            *
+                        </Import-Package>
+                        <Bundle-Activator>
+                            org.opendaylight.plugin2oc.neutron.Activator
+                        </Bundle-Activator>
+                        <Embed-Dependency>httpclient,httpcore;type=!pom;inline=false</Embed-Dependency>
+                        <Export-Package>
+                            net.juniper.contrail.api.*;version="1.2"
+                        </Export-Package>
+                        <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>net.juniper.contrail</groupId>
+            <artifactId>juniper-contrail-api</artifactId>
+            <version>1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <version>0.4.1</version>
+            <artifactId>networkconfig.neutron</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpcore</artifactId>
+        <version>4.3.2</version>
+        </dependency>
+        <dependency>
+         <groupId>org.apache.httpcomponents</groupId>
+         <artifactId>httpclient</artifactId>
+         <version>4.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>14.0</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-exec</artifactId>
+            <version>1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.16</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal</artifactId>
+            <version>0.7.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-module-junit4</artifactId>
+            <version>1.5.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito</artifactId>
+            <version>1.5.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.javassist</groupId>
+            <artifactId>javassist</artifactId>
+            <version>3.15.0-GA</version>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <version>3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-nodep</artifactId>
+            <version>2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-module-junit4-legacy</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-easymock</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/Activator.java b/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/Activator.java
new file mode 100755 (executable)
index 0000000..5ca486b
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ApiConnectorFactory;
+
+import org.apache.felix.dm.Component;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OSGi bundle activator for the plugin2oc Neutron Interface.
+ */
+public class Activator extends ComponentActivatorAbstractBase {
+    static ApiConnector apiConnector = null;
+    static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
+    /**
+     * Function called when the activator starts just after some initializations
+     * are done by the ComponentActivatorAbstractBase.
+     */
+    @Override
+    public void init() {
+        LOGGER.info("plugin2oc Plugin service Registered");
+        apiConnector = getApiConnection();
+    }
+
+    /**
+     * Function called to get APIConnector object. porperties must be defined in
+     * opendaylight configuration folder inside config.ini at
+     * opendaylight/distribution
+     * /opendaylight/src/main/resources/configuration/config.ini
+     */
+    public ApiConnector getApiConnection() {
+        String ipAddress = System.getProperty("plugin2oc.apiserver.ipaddress");
+        String port = System.getProperty("plugin2oc.apiserver.port");
+        int portNumber = 0;
+        try {
+            portNumber = Integer.parseInt(port);
+        } catch (Exception ex) {
+            LOGGER.error("Missing entry in Config file of Opendaylight", ex);
+        }
+        apiConnector = ApiConnectorFactory.build(ipAddress, portNumber);
+        return apiConnector;
+    }
+
+    /**
+     * Function called when the activator stops just before the cleanup done by
+     * ComponentActivatorAbstractBase.
+     *
+     */
+    @Override
+    public void destroy() {
+    }
+
+    /**
+     * Function that is used to communicate to dependency manager the list of
+     * known implementations for services inside a container.
+     *
+     * @return An array containing all the CLASS objects that will be
+     *         instantiated in order to get an fully working implementation
+     *         Object
+     */
+    @Override
+    public Object[] getImplementations() {
+        Object[] res = { NetworkHandler.class, SubnetHandler.class, PortHandler.class };
+        return res;
+    }
+
+    /**
+     * Function that is called when configuration of the dependencies is
+     * required.
+     *
+     * @param c
+     *            dependency manager Component object, used for configuring the
+     *            dependencies exported and imported
+     * @param imp
+     *            Implementation class that is being configured, needed as long
+     *            as the same routine can configure multiple implementations
+     * @param containerName
+     *            The containerName being configured, this allow also optional
+     *            per-container different behavior if needed, usually should not
+     *            be the case though.
+     */
+    @Override
+    public void configureInstance(Component c, Object imp, String containerName) {
+        if (imp.equals(NetworkHandler.class)) {
+            c.setInterface(INeutronNetworkAware.class.getName(), null);
+        }
+        if (imp.equals(SubnetHandler.class)) {
+            c.setInterface(INeutronSubnetAware.class.getName(), null);
+        }
+        if (imp.equals(PortHandler.class)) {
+            c.setInterface(INeutronPortAware.class.getName(), null);
+        }
+        // Create service dependencies.
+        c.add(createServiceDependency().setService(BindingAwareBroker.class).setCallbacks("setBindingAwareBroker", "unsetBindingAwareBroker")
+                .setRequired(true));
+    }
+}
diff --git a/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/NetworkHandler.java b/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/NetworkHandler.java
new file mode 100755 (executable)
index 0000000..4ea54ff
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.UUID;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.types.Project;
+import net.juniper.contrail.api.types.VirtualNetwork;
+
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handle requests for Neutron Network.
+ */
+public class NetworkHandler implements INeutronNetworkAware {
+    /**
+     * Logger instance.
+     */
+    static final Logger LOGGER = LoggerFactory.getLogger(NetworkHandler.class);
+    static ApiConnector apiConnector;
+
+    /**
+     * Invoked when a network creation is requested to check if the specified
+     * network can be created and then creates the network
+     *
+     * @param network
+     *            An instance of proposed new Neutron Network object.
+     *
+     * @return A HTTP status code to the creation request.
+     */
+    @Override
+    public int canCreateNetwork(NeutronNetwork network) {
+        if (network == null) {
+            LOGGER.error("Network object can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        LOGGER.debug("Network object " + network);
+        apiConnector = Activator.apiConnector;
+        if (network.getNetworkUUID() == null || network.getNetworkName() == null || network.getNetworkUUID().equals("")
+                || network.getNetworkName().equals("")) {
+            LOGGER.error("Network UUID and Network Name can't be null/empty...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (network.getTenantID() == null) {
+            LOGGER.error("Network tenant Id can not be null");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        try {
+            return createNetwork(network);
+        } catch (IOException ie) {
+            LOGGER.error("IOException :   " + ie);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        } catch (Exception e) {
+            LOGGER.error("Exception :   " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to take action after a network has been created.
+     *
+     * @param network
+     *            An instance of new Neutron Network object.
+     */
+    @Override
+    public void neutronNetworkCreated(NeutronNetwork network) {
+        VirtualNetwork virtualNetwork = null;
+        try {
+            virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, network.getNetworkUUID());
+            if (virtualNetwork != null) {
+                LOGGER.info("Network creation verified....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :     " + e);
+        }
+    }
+
+    /**
+     * Invoked to create the specified Neutron Network.
+     *
+     * @param network
+     *            An instance of new Neutron Network object.
+     *
+     * @return A HTTP status code to the creation request.
+     */
+    private int createNetwork(NeutronNetwork network) throws IOException {
+        VirtualNetwork virtualNetwork = null;
+        String networkUUID = null;
+        String projectUUID = null;
+        try {
+            networkUUID = UUID.fromString(network.getNetworkUUID()).toString();
+            projectUUID = network.getTenantID().toString();
+            if (!(projectUUID.contains("-"))) {
+                projectUUID = uuidFormater(projectUUID);
+            }
+            projectUUID = UUID.fromString(projectUUID).toString();
+            LOGGER.info("projectUUID 2  " + projectUUID);
+        } catch (Exception ex) {
+            LOGGER.error("UUID input incorrect", ex);
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, networkUUID);
+        Project project = (Project) apiConnector.findById(Project.class, projectUUID);
+        if (project == null) {
+            try {
+                Thread.currentThread();
+                Thread.sleep(3000);
+            } catch (InterruptedException e) {
+                LOGGER.error("InterruptedException :    ", e);
+            }
+            project = (Project) apiConnector.findById(Project.class, projectUUID);
+            if (project == null) {
+                LOGGER.error("Could not find projectUUID...");
+                return HttpURLConnection.HTTP_NOT_FOUND;
+            }
+        }
+        if (virtualNetwork != null) {
+            LOGGER.warn("Network already exists..");
+            return HttpURLConnection.HTTP_FORBIDDEN;
+        }
+        virtualNetwork = new VirtualNetwork();
+        // map neutronNetwork to virtualNetwork
+        virtualNetwork = mapNetworkProperties(network, virtualNetwork);
+        virtualNetwork.setParent(project);
+        boolean networkCreated = apiConnector.create(virtualNetwork);
+        LOGGER.debug("networkCreated:   " + networkCreated);
+        if (!networkCreated) {
+            LOGGER.warn("Network creation failed..");
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+        LOGGER.info("Network : " + virtualNetwork.getName() + "  having UUID : " + virtualNetwork.getUuid() + "  sucessfully created...");
+        return HttpURLConnection.HTTP_OK;
+    }
+
+    /**
+     * Invoked to map the NeutronNetwork object properties to the virtualNetwork
+     * object.
+     *
+     * @param neutronNetwork
+     *            An instance of new Neutron Network object.
+     * @param virtualNetwork
+     *            An instance of new virtualNetwork object.
+     * @return {@link VirtualNetwork}
+     */
+    private VirtualNetwork mapNetworkProperties(NeutronNetwork neutronNetwork, VirtualNetwork virtualNetwork) {
+        String networkUUID = neutronNetwork.getNetworkUUID();
+        String networkName = neutronNetwork.getNetworkName();
+        virtualNetwork.setName(networkName);
+        virtualNetwork.setUuid(networkUUID);
+        virtualNetwork.setDisplayName(networkName);
+        return virtualNetwork;
+    }
+
+    /**
+     * Invoked when a network update is requested to indicate if the specified
+     * network can be changed using the specified delta.
+     *
+     * @param delta
+     *            Updates to the network object using patch semantics.
+     * @param original
+     *            An instance of the Neutron Network object to be updated.
+     * @return A HTTP status code to the update request.
+     */
+    @Override
+    public int canUpdateNetwork(NeutronNetwork deltaNetwork, NeutronNetwork originalNetwork) {
+        VirtualNetwork virtualnetwork = new VirtualNetwork();
+        apiConnector = Activator.apiConnector;
+        if (deltaNetwork == null || originalNetwork == null) {
+            LOGGER.error("Neutron Networks can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (("").equals(deltaNetwork.getNetworkName())) {
+            LOGGER.error("Neutron Networks name to be update can't be empty..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        try {
+            virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, originalNetwork.getNetworkUUID());
+        } catch (IOException e) {
+            LOGGER.error("Exception :     " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+        if (virtualnetwork == null) {
+            LOGGER.error("No network exists for the specified UUID...");
+            return HttpURLConnection.HTTP_FORBIDDEN;
+        } else {
+            try {
+                return updateNetwork(deltaNetwork, virtualnetwork);
+            } catch (IOException ie) {
+                LOGGER.error("IOException:     " + ie);
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            } catch (Exception e) {
+                LOGGER.error("Exception:     " + e);
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            }
+        }
+    }
+
+    /**
+     * Invoked to update the network
+     *
+     * @param delta_network
+     *            An instance of Network.
+     * @param virtualNetwork
+     *            An instance of new virtualNetwork object.
+     *
+     * @return A HTTP status code to the creation request.
+     */
+    private int updateNetwork(NeutronNetwork deltaNetwork, VirtualNetwork virtualNetwork) throws IOException {
+        String networkName = deltaNetwork.getNetworkName();
+        virtualNetwork.setName(networkName);
+        virtualNetwork.setDisplayName(networkName);
+        {
+            boolean networkUpdate = apiConnector.update(virtualNetwork);
+            if (!networkUpdate) {
+                LOGGER.warn("Network Updation failed..");
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            }
+            LOGGER.info("Network having UUID : " + virtualNetwork.getUuid() + "  has been sucessfully updated...");
+            return HttpURLConnection.HTTP_OK;
+        }
+    }
+
+    /**
+     * Invoked to take action after a network has been updated.
+     *
+     * @param network
+     *            An instance of modified Neutron Network object.
+     */
+    @Override
+    public void neutronNetworkUpdated(NeutronNetwork network) {
+        try {
+            VirtualNetwork virtualnetwork = new VirtualNetwork();
+            virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, network.getNetworkUUID());
+            if (network.getNetworkName().equalsIgnoreCase(virtualnetwork.getDisplayName())) {
+                LOGGER.info("Network updatation verified....");
+            } else {
+                LOGGER.info("Network updatation failed....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :" + e);
+        }
+    }
+
+    /**
+     * Invoked when a network deletion is requested to indicate if the specified
+     * network can be deleted.
+     *
+     * @param network
+     *            An instance of the Neutron Network object to be deleted.
+     * @return A HTTP status code to the deletion request.
+     */
+    @Override
+    public int canDeleteNetwork(NeutronNetwork network) {
+        apiConnector = Activator.apiConnector;
+        VirtualNetwork virtualNetwork = null;
+        try {
+            virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, network.getNetworkUUID());
+            if (virtualNetwork != null) {
+                if (virtualNetwork.getVirtualMachineInterfaceBackRefs() != null) {
+                    LOGGER.info("Network with UUID :  " + network.getNetworkUUID() + " cannot be deleted as it has port(s) associated with it....");
+                    return HttpURLConnection.HTTP_FORBIDDEN;
+                } else {
+                    apiConnector.delete(virtualNetwork);
+                    LOGGER.info("Network with UUID :  " + network.getNetworkUUID() + "  has been deleted successfully....");
+                    return HttpURLConnection.HTTP_OK;
+                }
+            } else {
+                LOGGER.info("No Network exists with UUID :  " + network.getNetworkUUID());
+                return HttpURLConnection.HTTP_BAD_REQUEST;
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception : " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to take action after a network has been deleted.
+     *
+     * @param network
+     *            An instance of deleted Neutron Network object.
+     */
+    @Override
+    public void neutronNetworkDeleted(NeutronNetwork network) {
+        VirtualNetwork virtualNetwork = null;
+        try {
+            virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, network.getNetworkUUID());
+            if (virtualNetwork == null) {
+                LOGGER.info("Network deletion verified....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :   " + e);
+        }
+    }
+
+    /**
+     * Invoked to format the UUID if UUID is not in correct format.
+     *
+     * @param String
+     *            An instance of UUID string.
+     *
+     * @return Correctly formated UUID string.
+     */
+    private String uuidFormater(String uuid) {
+        String uuidPattern = null;
+        String id1 = uuid.substring(0, 8);
+        String id2 = uuid.substring(8, 12);
+        String id3 = uuid.substring(12, 16);
+        String id4 = uuid.substring(16, 20);
+        String id5 = uuid.substring(20, 32);
+        uuidPattern = (id1 + "-" + id2 + "-" + id3 + "-" + id4 + "-" + id5);
+        return uuidPattern;
+    }
+}
\ No newline at end of file
diff --git a/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/PortHandler.java b/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/PortHandler.java
new file mode 100755 (executable)
index 0000000..bae5b9a
--- /dev/null
@@ -0,0 +1,534 @@
+/*
+ * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.List;
+import java.util.UUID;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ApiPropertyBase;
+import net.juniper.contrail.api.ObjectReference;
+import net.juniper.contrail.api.types.InstanceIp;
+import net.juniper.contrail.api.types.MacAddressesType;
+import net.juniper.contrail.api.types.Project;
+import net.juniper.contrail.api.types.VirtualMachine;
+import net.juniper.contrail.api.types.VirtualMachineInterface;
+import net.juniper.contrail.api.types.VirtualNetwork;
+import net.juniper.contrail.api.types.VnSubnetsType;
+
+import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
+import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
+import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
+import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
+import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handle requests for Neutron Port.
+ */
+public class PortHandler implements INeutronPortAware {
+    /**
+     * Logger instance.
+     */
+    static final Logger LOGGER = LoggerFactory.getLogger(PortHandler.class);
+    static ApiConnector apiConnector;
+
+    /**
+     * Invoked when a port creation is requested to check if the specified Port
+     * can be created and then creates the port
+     *
+     * @param NeutronPort
+     *            An instance of proposed new Neutron Port object.
+     * @return A HTTP status code to the creation request.
+     */
+    @Override
+    public int canCreatePort(NeutronPort neutronPort) {
+        apiConnector = Activator.apiConnector;
+        if (neutronPort == null) {
+            LOGGER.error("NeutronPort object can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (neutronPort.getID().equals("")) {
+            LOGGER.error("Port Device Id or Port Uuid can't be empty/null...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (neutronPort.getTenantID() == null) {
+            LOGGER.error("Tenant ID can't be null...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+
+        List<Neutron_IPs> ips = neutronPort.getFixedIPs();
+        if (ips == null) {
+            LOGGER.warn("Neutron Fixed Ips can't be null..");
+            return HttpURLConnection.HTTP_FORBIDDEN;
+        }
+        try {
+            return createPort(neutronPort);
+        } catch (Exception e) {
+            LOGGER.error("exception :   ", e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to create the specified Neutron port.
+     *
+     * @param network
+     *            An instance of new Neutron Port object.
+     *
+     * @return A HTTP status code to the creation request.
+     */
+    private int createPort(NeutronPort neutronPort) {
+        String networkID = neutronPort.getNetworkUUID();
+        String portID = neutronPort.getID();
+        String portDesc = neutronPort.getID();
+        String deviceID = neutronPort.getDeviceID();
+        String projectID = neutronPort.getTenantID();
+        String portMACAddress = neutronPort.getMacAddress();
+        VirtualMachineInterface virtualMachineInterface = null;
+        VirtualMachine virtualMachine = null;
+        VirtualNetwork virtualNetwork = null;
+        Project project = null;
+        MacAddressesType macAddressesType = new MacAddressesType();
+        try {
+            networkID = UUID.fromString(neutronPort.getNetworkUUID()).toString();
+            portID = UUID.fromString(neutronPort.getID()).toString();
+            if (neutronPort.getDeviceID() != null && !(("").equals(neutronPort.getDeviceID()))) {
+                if (!(deviceID.contains("-"))) {
+                    deviceID = uuidFormater(deviceID);
+                }
+                deviceID = UUID.fromString(deviceID).toString();
+            }
+            if (!(projectID.contains("-"))) {
+                projectID = uuidFormater(projectID);
+            }
+            projectID = UUID.fromString(projectID).toString();
+        } catch (Exception ex) {
+            LOGGER.error("exception :   ", ex);
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        try {
+            LOGGER.debug("portId:    " + portID);
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, portID);
+            if (virtualMachineInterface != null) {
+                LOGGER.warn("Port already exist.");
+                return HttpURLConnection.HTTP_FORBIDDEN;
+            } else {
+                if (deviceID != null && !(("").equals(deviceID))) {
+                    virtualMachine = (VirtualMachine) apiConnector.findById(VirtualMachine.class, deviceID);
+                    LOGGER.debug("virtualMachine:   " + virtualMachine);
+                    if (virtualMachine == null) {
+                        virtualMachine = new VirtualMachine();
+                        virtualMachine.setName(deviceID);
+                        virtualMachine.setUuid(deviceID);
+                        boolean virtualMachineCreated = apiConnector.create(virtualMachine);
+                        LOGGER.debug("virtualMachineCreated: " + virtualMachineCreated);
+                        if (!virtualMachineCreated) {
+                            LOGGER.warn("virtualMachine creation failed..");
+                            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                        }
+                        LOGGER.info("virtualMachine : " + virtualMachine.getName() + "  having UUID : " + virtualMachine.getUuid()
+                                + "  sucessfully created...");
+                    }
+                }
+                project = (Project) apiConnector.findById(Project.class, projectID);
+                if (project == null) {
+                    try {
+                        Thread.currentThread();
+                        Thread.sleep(3000);
+                    } catch (InterruptedException e) {
+                        LOGGER.error("InterruptedException :      ", e);
+                    }
+                    project = (Project) apiConnector.findById(Project.class, projectID);
+                    if (project == null) {
+                        LOGGER.error("Could not find projectUUID...");
+                        return HttpURLConnection.HTTP_NOT_FOUND;
+                    }
+                }
+                virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, networkID);
+                LOGGER.info("virtualNetwork: " + virtualNetwork);
+                if (virtualNetwork == null) {
+                    LOGGER.warn("virtualNetwork does not exist..");
+                    return HttpURLConnection.HTTP_BAD_REQUEST;
+                } else {
+                    virtualMachineInterface = new VirtualMachineInterface();
+                    virtualMachineInterface.setUuid(portID);
+                    virtualMachineInterface.setName(portDesc);
+                    virtualMachineInterface.setParent(project);
+                    virtualMachineInterface.setVirtualNetwork(virtualNetwork);
+                    macAddressesType.addMacAddress(portMACAddress);
+                    virtualMachineInterface.setMacAddresses(macAddressesType);
+                    if (deviceID != null && !(("").equals(deviceID))) {
+                        virtualMachineInterface.setVirtualMachine(virtualMachine);
+                    }
+                    boolean virtualMachineInterfaceCreated = apiConnector.create(virtualMachineInterface);
+                    if (!virtualMachineInterfaceCreated) {
+                        LOGGER.warn("actual virtualMachineInterface creation failed..");
+                        return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                    }
+                    LOGGER.info("virtualMachineInterface : " + virtualMachineInterface.getName() + "  having UUID : "
+                            + virtualMachineInterface.getUuid() + "  sucessfully created...");
+                }
+
+            }
+            INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
+            NeutronSubnet subnet = null;
+            List<Neutron_IPs> ips = neutronPort.getFixedIPs();
+            InstanceIp instanceIp = new InstanceIp();
+            String instaneIpUuid = UUID.randomUUID().toString();
+            for (Neutron_IPs ipValues : ips) {
+                if (ipValues.getIpAddress() == null) {
+                    subnet = systemCRUD.getSubnet(ipValues.getSubnetUUID());
+                    instanceIp.setAddress(subnet.getLowAddr());
+                } else {
+                    instanceIp.setAddress(ipValues.getIpAddress());
+                }
+            }
+
+            instanceIp.setName(instaneIpUuid);
+            instanceIp.setUuid(instaneIpUuid);
+            instanceIp.setParent(virtualMachineInterface);
+            instanceIp.setVirtualMachineInterface(virtualMachineInterface);
+            instanceIp.setVirtualNetwork(virtualNetwork);
+
+            boolean instanceIpCreated = apiConnector.create(instanceIp);
+            if (!instanceIpCreated) {
+                LOGGER.warn("instanceIp addition failed..");
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            }
+            LOGGER.info("Instance IP added sucessfully...");
+            return HttpURLConnection.HTTP_OK;
+        } catch (IOException ie) {
+            LOGGER.error("IOException :    ", ie);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to take action after a port has been created.
+     *
+     * @param network
+     *            An instance of new Neutron port object.
+     */
+    @Override
+    public void neutronPortCreated(NeutronPort neutronPort) {
+        VirtualMachineInterface virtualMachineInterface = null;
+        try {
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID());
+            if (virtualMachineInterface != null) {
+                LOGGER.info("Port creation verified....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :    " + e);
+        }
+    }
+
+    /**
+     * Invoked when a port deletion is requested to check if the specified Port
+     * can be deleted and then delete the port
+     *
+     * @param NeutronPort
+     *            An instance of proposed Neutron Port object.
+     * @return A HTTP status code to the deletion request.
+     */
+    @Override
+    public int canDeletePort(NeutronPort neutronPort) {
+        if (neutronPort == null) {
+            LOGGER.info("Port object can't be null...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        apiConnector = Activator.apiConnector;
+        try {
+            return deletePort(neutronPort);
+        } catch (Exception e) {
+            LOGGER.error("exception :   ", e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to delete the specified Neutron port.
+     *
+     * @param network
+     *            An instance of new Neutron Port object.
+     *
+     * @return A HTTP status code to the deletion request.
+     */
+    private int deletePort(NeutronPort neutronPort) {
+        String portID = neutronPort.getID();
+        String deviceID = neutronPort.getDeviceID();
+        VirtualMachineInterface virtualMachineInterface = null;
+        VirtualMachine virtualMachine = null;
+        InstanceIp instanceIP = null;
+        List<ObjectReference<ApiPropertyBase>> virtualMachineInterfaceBackRefs = null;
+        try {
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, portID);
+            if (virtualMachineInterface == null) {
+                LOGGER.info("Specified port does not exist...");
+                return HttpURLConnection.HTTP_BAD_REQUEST;
+            } else {
+                List<ObjectReference<ApiPropertyBase>> instanceIPs = virtualMachineInterface.getInstanceIpBackRefs();
+                if (instanceIPs != null) {
+                    for (ObjectReference<ApiPropertyBase> ref : instanceIPs) {
+                        String instanceIPUUID = ref.getUuid();
+                        if (instanceIPUUID != null) {
+                            instanceIP = (InstanceIp) apiConnector.findById(InstanceIp.class, instanceIPUUID);
+                            apiConnector.delete(instanceIP);
+                        }
+                    }
+                }
+                apiConnector.delete(virtualMachineInterface);
+                virtualMachine = (VirtualMachine) apiConnector.findById(VirtualMachine.class, deviceID);
+                if (virtualMachine != null) {
+                    virtualMachineInterfaceBackRefs = virtualMachine.getVirtualMachineInterfaceBackRefs();
+                    if (virtualMachineInterfaceBackRefs == null) {
+                        apiConnector.delete(virtualMachine);
+                    }
+                }
+                LOGGER.info("Specified port deleted sucessfully...");
+                return HttpURLConnection.HTTP_OK;
+            }
+        } catch (IOException io) {
+            LOGGER.error("Exception  :   " + io);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        } catch (Exception e) {
+            LOGGER.error("Exception  :   " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to take action after a port has been deleted.
+     *
+     * @param network
+     *            An instance of new Neutron port object.
+     */
+    @Override
+    public void neutronPortDeleted(NeutronPort neutronPort) {
+        VirtualMachineInterface virtualMachineInterface = new VirtualMachineInterface();
+        try {
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID());
+            if (virtualMachineInterface == null) {
+                LOGGER.info("Port deletion verified....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :    " + e);
+        }
+    }
+
+    /**
+     * Invoked when a port update is requested to indicate if the specified port
+     * can be updated using the specified delta and update the port
+     *
+     * @param delta
+     *            Updates to the port object using patch semantics.
+     * @param original
+     *            An instance of the Neutron Port object to be updated.
+     *
+     * @return A HTTP status code to the update request.
+     */
+    @Override
+    public int canUpdatePort(NeutronPort deltaPort, NeutronPort originalPort) {
+        apiConnector = Activator.apiConnector;
+        VirtualMachineInterface virtualMachineInterface = null;
+        if (deltaPort == null || originalPort == null) {
+            LOGGER.error("Neutron Port objects can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (deltaPort.getMacAddress() != null) {
+            LOGGER.error("MAC Address for the port can't be updated..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        try {
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, originalPort.getPortUUID());
+            return updatePort(deltaPort, virtualMachineInterface, originalPort);
+        } catch (IOException ie) {
+            LOGGER.error("IOException:     " + ie);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        } catch (Exception e) {
+            LOGGER.error("Exception:     " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to update the port
+     *
+     * @param delta_network
+     *            An instance of Neutron Port.
+     * @param An
+     *            instance of new {@link VirtualMachineInterface} object.
+     *
+     * @return A HTTP status code to the updation request.
+     */
+    private int updatePort(NeutronPort deltaPort, VirtualMachineInterface virtualMachineInterface, NeutronPort originalPort) throws IOException {
+        VirtualMachine virtualMachine = null;
+        String deviceID = deltaPort.getDeviceID();
+        String portName = deltaPort.getName();
+        List<Neutron_IPs> fixedIPs = deltaPort.getFixedIPs();
+        boolean instanceIpUpdate = false;
+        String networkUUID = deltaPort.getNetworkUUID();
+        VirtualNetwork virtualnetwork = null;
+        if (fixedIPs != null) {
+            if (networkUUID == null) {
+                for (ObjectReference<ApiPropertyBase> networks : virtualMachineInterface.getVirtualNetwork()) {
+                    networkUUID = networks.getUuid();
+                }
+            }
+            boolean subnetExist = false;
+            virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, networkUUID);
+            if (virtualnetwork == null) {
+                LOGGER.error(" Virtual network does not exist");
+                return HttpURLConnection.HTTP_FORBIDDEN;
+            }
+            if (virtualnetwork != null && virtualnetwork.getNetworkIpam() != null) {
+                for (Neutron_IPs fixedIp : fixedIPs) {
+                    for (ObjectReference<VnSubnetsType> ref : virtualnetwork.getNetworkIpam()) {
+                        VnSubnetsType vnSubnetsType = ref.getAttr();
+                        if (vnSubnetsType != null) {
+                            List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
+                            if (subnets != null) {
+                                for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
+                                    Boolean doesSubnetExist = subnetValue.getSubnetUuid().matches(fixedIp.getSubnetUUID());
+                                    if (doesSubnetExist) {
+                                        subnetExist = true;
+                                        for (ObjectReference<ApiPropertyBase> instanceIp : virtualMachineInterface.getInstanceIpBackRefs()) {
+                                            InstanceIp instanceIpLocal = (InstanceIp) apiConnector.findById(InstanceIp.class, instanceIp.getUuid());
+                                            instanceIpLocal.setVirtualNetwork(virtualnetwork);
+                                            INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
+                                            NeutronSubnet subnet = null;
+                                            for (Neutron_IPs ip : originalPort.getFixedIPs()) {
+                                                subnet = systemCRUD.getSubnet(ip.getSubnetUUID());
+                                                subnet.releaseIP(ip.getIpAddress());
+                                            }
+                                            if (fixedIp.getIpAddress() == null) {
+                                                subnet = systemCRUD.getSubnet(fixedIp.getSubnetUUID());
+                                                instanceIpLocal.setAddress(subnet.getLowAddr());
+                                            } else {
+                                                instanceIpLocal.setAddress(fixedIp.getIpAddress());
+                                            }
+                                            instanceIpUpdate = apiConnector.update(instanceIpLocal);
+                                            virtualMachineInterface.setVirtualNetwork(virtualnetwork);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (!subnetExist) {
+                LOGGER.error("Subnet UUID must exist in the network..");
+                return HttpURLConnection.HTTP_BAD_REQUEST;
+            }
+        } else if (networkUUID != null && fixedIPs == null) {
+            LOGGER.error("Subnet UUID must exist in the network..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (deviceID != null) {
+            if (("").equals(deviceID)) {
+                virtualMachineInterface.clearVirtualMachine();
+            } else {
+                deviceID = UUID.fromString(deltaPort.getDeviceID()).toString();
+                try {
+                    virtualMachine = (VirtualMachine) apiConnector.findById(VirtualMachine.class, deviceID);
+                } catch (Exception e) {
+                    LOGGER.error("Exception:     " + e);
+                    return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                }
+                if (virtualMachine == null) {
+                    virtualMachine = new VirtualMachine();
+                    virtualMachine.setName(deviceID);
+                    virtualMachine.setUuid(deviceID);
+                    boolean virtualMachineCreated = apiConnector.create(virtualMachine);
+                    LOGGER.debug("virtualMachineCreated: " + virtualMachineCreated);
+                    if (!virtualMachineCreated) {
+                        LOGGER.warn("virtualMachine creation failed..");
+                        return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                    }
+                    LOGGER.info("virtualMachine : " + virtualMachine.getName() + "  having UUID : " + virtualMachine.getUuid()
+                            + "  sucessfully created...");
+                }
+                virtualMachineInterface.setVirtualMachine(virtualMachine);
+            }
+        }
+        if (portName != null) {
+            virtualMachineInterface.setDisplayName(portName);
+        }
+        if ((deviceID != null && !(("").equals(deviceID))) || portName != null || instanceIpUpdate) {
+            if ((deviceID != null && !(("").equals(deviceID))) || portName != null) {
+                boolean portUpdate = apiConnector.update(virtualMachineInterface);
+                if (!portUpdate) {
+                    LOGGER.warn("Port Updation failed..");
+                    return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                }
+            }
+            LOGGER.info("Port having UUID : " + virtualMachineInterface.getUuid() + "  has been sucessfully updated...");
+            return HttpURLConnection.HTTP_OK;
+        } else {
+            LOGGER.info("Nothing to update...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+    }
+
+    /**
+     * Invoked to take action after a port has been updated.
+     *
+     * @param network
+     *            An instance of modified Neutron Port object.
+     */
+    @Override
+    public void neutronPortUpdated(NeutronPort neutronPort) {
+        try {
+            VirtualMachineInterface virtualMachineInterface;
+            virtualMachineInterface = (VirtualMachineInterface) apiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID());
+            if (("").equals(neutronPort.getDeviceID())) { // TODO : VM Refs not getting cleared correctly - to be fixed
+                if (neutronPort.getName().matches(virtualMachineInterface.getDisplayName()) && virtualMachineInterface.getVirtualMachine() == null) {
+                    LOGGER.info("Port updatation verified....");
+                }
+            } else if (neutronPort.getName().matches(virtualMachineInterface.getDisplayName())
+                    && neutronPort.getDeviceID().matches(virtualMachineInterface.getVirtualMachine().get(0).getUuid())) {
+                LOGGER.info("Port updatation verified....");
+            } else {
+                LOGGER.info("Port updatation failed....");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :" + e);
+        }
+    }
+
+    /**
+     * Invoked to format the UUID if UUID is not in correct format.
+     *
+     * @param String
+     *            An instance of UUID string.
+     *
+     * @return Correctly formated UUID string.
+     */
+    private String uuidFormater(String uuid) {
+        String uuidPattern = null;
+        try {
+            String id1 = uuid.substring(0, 8);
+            String id2 = uuid.substring(8, 12);
+            String id3 = uuid.substring(12, 16);
+            String id4 = uuid.substring(16, 20);
+            String id5 = uuid.substring(20, 32);
+            uuidPattern = (id1 + "-" + id2 + "-" + id3 + "-" + id4 + "-" + id5);
+
+        } catch (Exception e) {
+            LOGGER.error("UUID is not in correct format ");
+            LOGGER.error("Exception :" + e);
+        }
+        return uuidPattern;
+    }
+}
diff --git a/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/SubnetHandler.java b/neutron/src/main/java/org/opendaylight/plugin2oc/neutron/SubnetHandler.java
new file mode 100755 (executable)
index 0000000..826edd3
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.Iterator;
+import java.util.List;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ObjectReference;
+import net.juniper.contrail.api.types.NetworkIpam;
+import net.juniper.contrail.api.types.SubnetType;
+import net.juniper.contrail.api.types.VirtualNetwork;
+import net.juniper.contrail.api.types.VnSubnetsType;
+
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
+import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
+import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet_IPAllocationPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handle requests for Neutron Subnet.
+ */
+public class SubnetHandler implements INeutronSubnetAware {
+    /**
+     * Logger instance.
+     */
+    static final Logger LOGGER = LoggerFactory.getLogger(SubnetHandler.class);
+    static ApiConnector apiConnector = Activator.apiConnector;
+
+    /**
+     * Invoked when a subnet creation is requested to check if the specified
+     * subnet can be created and then creates the subnet.
+     *
+     * @param subnet
+     *            An instance of proposed new Neutron Subnet object.
+     *
+     * @return A HTTP status code to the creation request.
+     **/
+    @Override
+    public int canCreateSubnet(NeutronSubnet subnet) {
+        VirtualNetwork virtualnetwork = new VirtualNetwork();
+        apiConnector = Activator.apiConnector;
+        if (subnet == null) {
+            LOGGER.error("Neutron Subnet can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (subnet.getCidr() == null || ("").equals(subnet.getCidr())) {
+            LOGGER.info("Subnet Cidr can not be empty or null...");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        boolean isvalidGateway = validGatewayIP(subnet, subnet.getGatewayIP());
+        if (!isvalidGateway) {
+            LOGGER.error("Incorrect gateway IP....");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        try {
+            virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID());
+        } catch (IOException e) {
+            LOGGER.error("Exception : " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+        if (virtualnetwork == null) {
+            LOGGER.error("No network exists for the specified UUID...");
+            return HttpURLConnection.HTTP_FORBIDDEN;
+        } else {
+            try {
+                boolean ifSubnetExist = subnetExists(virtualnetwork.getNetworkIpam(), subnet);
+                if (ifSubnetExist) {
+                    LOGGER.error("The subnet already exists..");
+                    return HttpURLConnection.HTTP_FORBIDDEN;
+                }
+                return createSubnet(subnet, virtualnetwork);
+            } catch (IOException ie) {
+                LOGGER.error("IOException:     " + ie);
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            } catch (Exception e) {
+                LOGGER.error("Exception:  " + e);
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            }
+        }
+    }
+
+    private boolean subnetExists(List<ObjectReference<VnSubnetsType>> ipamRefs, NeutronSubnet subnet) {
+        if (ipamRefs != null) {
+            for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
+                VnSubnetsType vnSubnetsType = ref.getAttr();
+                if (vnSubnetsType != null) {
+                    List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
+                    if (subnets != null) {
+                        for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
+                            String[] ipPrefix = getIpPrefix(subnet);
+                            Boolean doesSubnetExist = subnetValue.getSubnet().getIpPrefix().matches(ipPrefix[0]);
+                            if (doesSubnetExist) {
+                                return doesSubnetExist;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Invoked to create the subnet
+     *
+     * @param subnet
+     *            An instance of new Subnet Type object.
+     */
+    @Override
+    public void neutronSubnetCreated(NeutronSubnet subnet) {
+        VirtualNetwork virtualNetwork = null;
+        try {
+            virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID());
+            boolean ifSubnetExists = subnetExists(virtualNetwork.getNetworkIpam(), subnet);
+            if (ifSubnetExists) {
+                LOGGER.info("Subnet creation verified...");
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :    " + e);
+        }
+    }
+
+    /**
+     * Invoked to create the subnet
+     *
+     * @param subnet
+     *            An instance of new Subnet Type object.
+     * @param virtualNetwork
+     *            An instance of new virtualNetwork object.
+     *
+     * @return A HTTP status code to the creation request.
+     */
+    private int createSubnet(NeutronSubnet subnet, VirtualNetwork virtualNetwork) throws IOException {
+        // add subnet properties to the virtual-network object
+        VirtualNetwork virtualnetwork = mapSubnetProperties(subnet, virtualNetwork);
+        boolean subnetCreate = apiConnector.update(virtualnetwork);
+        if (!subnetCreate) {
+            LOGGER.warn("Subnet creation failed..");
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        } else {
+            LOGGER.info("Subnet " + subnet.getCidr() + "sucessfully added to the network having UUID : " + virtualnetwork.getUuid());
+            return HttpURLConnection.HTTP_OK;
+        }
+    }
+
+    /**
+     * Invoked to add the NeutronSubnet properties to the virtualNetwork object.
+     *
+     * @param subnet
+     *            An instance of new Neutron Subnet object.
+     * @param virtualNetwork
+     *            An instance of new virtualNetwork object.
+     *
+     * @return {@link VirtualNetwork}
+     */
+    private VirtualNetwork mapSubnetProperties(NeutronSubnet subnet, VirtualNetwork vn) {
+        String[] ipPrefix = null;
+        NetworkIpam ipam = null;
+        VnSubnetsType vnSubnetsType = new VnSubnetsType();
+        SubnetType subnetType = new SubnetType();
+        try {
+            if (subnet.getCidr().contains("/")) {
+                ipPrefix = subnet.getCidr().split("/");
+            } else {
+                throw new IllegalArgumentException("String " + subnet.getCidr() + " not in correct format..");
+            }
+            // Find default-network-ipam
+            String ipamId = apiConnector.findByName(NetworkIpam.class, null, "default-network-ipam");
+            ipam = (NetworkIpam) apiConnector.findById(NetworkIpam.class, ipamId);
+        } catch (IOException ex) {
+            LOGGER.error("IOException :     " + ex);
+        } catch (Exception ex) {
+            LOGGER.error("Exception :      " + ex);
+        }
+        if (ipPrefix != null) {
+            subnetType.setIpPrefix(ipPrefix[0]);
+            subnetType.setIpPrefixLen(Integer.valueOf(ipPrefix[1]));
+            if (vn.getNetworkIpam() != null) {
+                for (ObjectReference<VnSubnetsType> ref : vn.getNetworkIpam()) {
+                    vnSubnetsType = ref.getAttr();
+                    vnSubnetsType.addIpamSubnets(subnetType, subnet.getGatewayIP(), subnet.getSubnetUUID());
+                }
+            } else {
+                vnSubnetsType.addIpamSubnets(subnetType, subnet.getGatewayIP(), subnet.getSubnetUUID());
+            }
+            vn.setNetworkIpam(ipam, vnSubnetsType);
+        }
+        return vn;
+    }
+
+    /**
+     * Invoked to get the IP Prefix from the Neutron Subnet object.
+     *
+     * @param subnet
+     *            An instance of new Neutron Subnet object.
+     *
+     * @return IP Prefix
+     * @throws Exception
+     */
+    String[] getIpPrefix(NeutronSubnet subnet) {
+        String[] ipPrefix = null;
+        String cidr = subnet.getCidr();
+        if (cidr.contains("/")) {
+            ipPrefix = cidr.split("/");
+        } else {
+            throw new IllegalArgumentException("String " + cidr + " not in correct format..");
+        }
+        return ipPrefix;
+    }
+
+    /**
+     * Invoked when a subnet update is requested to indicate if the specified
+     * subnet can be changed using the specified delta.
+     *
+     * @param delta
+     *            Updates to the subnet object using patch semantics.
+     * @param original
+     *            An instance of the Neutron Subnet object to be updated.
+     * @return A HTTP status code to the update request.
+     */
+    @Override
+    public int canUpdateSubnet(NeutronSubnet deltaSubnet, NeutronSubnet originalSubnet) {
+        if (deltaSubnet == null || originalSubnet == null) {
+            LOGGER.error("Neutron Subnets can't be null..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        if (deltaSubnet.getGatewayIP() == null || ("").equals(deltaSubnet.getGatewayIP().toString())) {
+            LOGGER.error("Gateway IP can't be empty/null`..");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        boolean isvalidGateway = validGatewayIP(originalSubnet, deltaSubnet.getGatewayIP());
+        if (!isvalidGateway) {
+            LOGGER.error("Incorrect gateway IP....");
+            return HttpURLConnection.HTTP_BAD_REQUEST;
+        }
+        apiConnector = Activator.apiConnector;
+        try {
+            boolean ifSubnetExist = false;
+            VirtualNetwork virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, originalSubnet.getNetworkUUID());
+            List<ObjectReference<VnSubnetsType>> ipamRefs = virtualnetwork.getNetworkIpam();
+            if (ipamRefs != null) {
+                for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
+                    VnSubnetsType vnSubnetsType = ref.getAttr();
+                    if (vnSubnetsType != null) {
+                        List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
+                        for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
+                            boolean doesSubnetExist = subnetValue.getSubnetUuid().matches(originalSubnet.getSubnetUUID());
+                            if (doesSubnetExist) {
+                                subnetValue.setDefaultGateway(deltaSubnet.getGatewayIP());
+                                ifSubnetExist = true;
+                            }
+                        }
+                    }
+                }
+            }
+            if (ifSubnetExist) {
+                boolean subnetUpdate = apiConnector.update(virtualnetwork);
+                if (!subnetUpdate) {
+                    LOGGER.warn("Subnet upadtion failed..");
+                    return HttpURLConnection.HTTP_INTERNAL_ERROR;
+                } else {
+                    LOGGER.info(" Subnet " + originalSubnet.getCidr() + " sucessfully updated with gateway IP : " + deltaSubnet.getGatewayIP());
+                    return HttpURLConnection.HTTP_OK;
+                }
+            } else {
+                LOGGER.warn("Subnet upadtion failed..");
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            }
+        } catch (IOException e) {
+            LOGGER.error("Exception :     " + e);
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    /**
+     * Invoked to take action after a subnet has been updated.
+     *
+     * @param subnet
+     *            An instance of modified Neutron Subnet object.
+     */
+    @Override
+    public void neutronSubnetUpdated(NeutronSubnet subnet) {
+        try {
+            boolean ifSubnetExist = false;
+            VirtualNetwork virtualnetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID());
+            List<ObjectReference<VnSubnetsType>> ipamRefs = virtualnetwork.getNetworkIpam();
+            if (ipamRefs != null) {
+                for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
+                    VnSubnetsType vnSubnetsType = ref.getAttr();
+                    if (vnSubnetsType != null) {
+                        List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
+                        for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
+                            boolean doesSubnetExist = subnetValue.getDefaultGateway().matches(subnet.getGatewayIP());
+                            if (doesSubnetExist) {
+                                ifSubnetExist = true;
+                            }
+                        }
+                    }
+                }
+            }
+            if (ifSubnetExist) {
+                LOGGER.info("Subnet upadtion verified..");
+            } else {
+                LOGGER.warn("Subnet upadtion failed..");
+            }
+        } catch (Exception ex) {
+            LOGGER.error("Exception :     " + ex);
+        }
+    }
+
+    /**
+     * Invoked when a subnet deletion is requested to indicate if the specified
+     * subnet can be deleted and then delete the subnet.
+     *
+     * @param subnet
+     *            An instance of the Neutron Subnet object to be deleted.
+     *
+     * @return A HTTP status code to the deletion request.
+     */
+    @Override
+    public int canDeleteSubnet(NeutronSubnet subnet) {
+        apiConnector = Activator.apiConnector;
+        VirtualNetwork virtualNetwork = null;
+        try {
+            virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID());
+            boolean subnetDelete = deleteSubnet(subnet, virtualNetwork);
+            if (!subnetDelete) {
+                LOGGER.error("Subnet deletion failed..");
+                return HttpURLConnection.HTTP_INTERNAL_ERROR;
+            } else {
+                LOGGER.info("Subnet " + subnet.getCidr() + " sucessfully deleted from network  : " + virtualNetwork.getUuid());
+                return HttpURLConnection.HTTP_NO_CONTENT;
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception :     ", e.getMessage());
+            return HttpURLConnection.HTTP_INTERNAL_ERROR;
+        }
+    }
+
+    boolean validGatewayIP(NeutronSubnet subnet, String ipAddress) {
+        try {
+
+            SubnetUtils util = new SubnetUtils(subnet.getCidr());
+            SubnetInfo info = util.getInfo();
+            boolean inRange = info.isInRange(ipAddress);
+            if (!inRange) {
+                return false;
+            } else {
+                // ip available in allocation pool
+                Iterator<NeutronSubnet_IPAllocationPool> i = subnet.getAllocationPools().iterator();
+                while (i.hasNext()) {
+                    NeutronSubnet_IPAllocationPool pool = i.next();
+                    if (pool.contains(ipAddress)) {
+                        return true;
+                    }
+                }
+                return true;
+            }
+        } catch (Exception e) {
+            LOGGER.error("Exception  :  " + e);
+            return false;
+        }
+    }
+
+    /**
+     * Invoked to delete a specified subnet.
+     *
+     * @param subnet
+     *            An instance of the Neutron Subnet object to be deleted.
+     *
+     * @param virtualNetwork
+     *            An instance of the Virtual network object.
+     *
+     * @return A HTTP status code to the deletion request.
+     */
+    private boolean deleteSubnet(NeutronSubnet subnet, VirtualNetwork virtualNetwork) {
+        try {
+            VnSubnetsType.IpamSubnetType subnetVmType = null;
+            VnSubnetsType vnSubnetsType = null;
+            List<VnSubnetsType.IpamSubnetType> subnets = null;
+            List<ObjectReference<VnSubnetsType>> ipamRefs = virtualNetwork.getNetworkIpam();
+            if (ipamRefs != null) {
+                for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
+                    vnSubnetsType = ref.getAttr();
+                    if (vnSubnetsType != null) {
+                        subnets = vnSubnetsType.getIpamSubnets();
+                        for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
+                            String[] ipPrefix = getIpPrefix(subnet);
+                            boolean doesSubnetExist = subnetValue.getSubnet().getIpPrefix().matches(ipPrefix[0]);
+                            if (doesSubnetExist) {
+                                subnetVmType = subnetValue;
+                            }
+                        }
+                    }
+                }
+                vnSubnetsType.clearIpamSubnets();
+                for (VnSubnetsType.IpamSubnetType subnetVal : subnets) {
+                    if (!subnetVal.getSubnet().getIpPrefix().matches(subnetVmType.getSubnet().getIpPrefix())) {
+                        vnSubnetsType.addIpamSubnets(subnetVal);
+                    }
+                }
+                if (vnSubnetsType.getIpamSubnets() != null) {
+                    virtualNetwork.clearNetworkIpam();
+                    String ipamId = apiConnector.findByName(NetworkIpam.class, null, "default-network-ipam");
+                    NetworkIpam ipam = (NetworkIpam) apiConnector.findById(NetworkIpam.class, ipamId);
+                    virtualNetwork.addNetworkIpam(ipam, vnSubnetsType);
+                } else {
+                    virtualNetwork.clearNetworkIpam();
+                }
+                return apiConnector.update(virtualNetwork);
+            } else {
+                LOGGER.error("Subnet deletion failed...");
+                return false;
+            }
+        } catch (IOException ioEx) {
+            LOGGER.error("Exception     : " + ioEx);
+            return false;
+        } catch (Exception ex) {
+            LOGGER.error("Exception     : " + ex);
+            return false;
+        }
+    }
+
+    /**
+     * Invoked to take action after a subnet has been deleted.
+     *
+     * @param subnet
+     *            An instance of deleted Neutron Subnet object.
+     */
+    @Override
+    public void neutronSubnetDeleted(NeutronSubnet subnet) {
+        try {
+            VirtualNetwork virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, subnet.getNetworkUUID());
+            boolean ifSubnetExist = subnetExists(virtualNetwork.getNetworkIpam(), subnet);
+            if (!ifSubnetExist) {
+                LOGGER.info("Subnet deletion verified..");
+            } else {
+                LOGGER.warn("Subnet deletion failed..");
+            }
+        } catch (Exception ex) {
+            LOGGER.error("Exception :    " + ex);
+        }
+    }
+}
diff --git a/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/NetworkHandlerTest.java b/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/NetworkHandlerTest.java
new file mode 100755 (executable)
index 0000000..2c239b4
--- /dev/null
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.easymock.PowerMock.expectNew;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ApiPropertyBase;
+import net.juniper.contrail.api.ObjectReference;
+import net.juniper.contrail.api.types.Project;
+import net.juniper.contrail.api.types.VirtualNetwork;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Test Class for Neutron Network.
+ */
+@PrepareForTest({ NetworkHandler.class, VirtualNetwork.class })
+@RunWith(PowerMockRunner.class)
+public class NetworkHandlerTest {
+    NetworkHandler networkHandler;
+    NeutronNetwork mockedNeutronNetwork = mock(NeutronNetwork.class);
+    ApiConnector mockedApiConnector = mock(ApiConnector.class);
+    ApiConnector mockedApiConnector1 = Mockito.mock(ApiConnector.class);
+    VirtualNetwork mockedVirtualNetwork = mock(VirtualNetwork.class);
+    Project mockProject = mock(Project.class);
+
+    @Before
+    public void beforeTest() {
+        networkHandler = new NetworkHandler();
+        assertNotNull(mockedApiConnector);
+        assertNotNull(mockedNeutronNetwork);
+        assertNotNull(mockedVirtualNetwork);
+        assertNotNull(mockProject);
+    }
+
+    @After
+    public void AfterTest() {
+        networkHandler = null;
+        Activator.apiConnector = null;
+    }
+
+    /* dummy params for Neutron Network */
+    public NeutronNetwork defaultNeutronObject() {
+        NeutronNetwork neutron = new NeutronNetwork();
+        neutron.setNetworkName("Virtual-Network");
+        neutron.setNetworkUUID("6b9570f2-17b1-4fc3-99ec-1b7f7778a29a");
+        neutron.setProviderNetworkType("gre");
+        neutron.setTenantID("019570f2-17b1-4fc3-99ec-1b7f7778a29a");
+        neutron.setProviderSegmentationID("2");
+        neutron.setAdminStateUp(true);
+        neutron.setProviderNetworkType("gre");
+        neutron.setProviderSegmentationID("2");
+        neutron.setShared(false);
+        neutron.setRouterExternal(false);
+        return neutron;
+    }
+
+    /* dummy params for Neutron Network for update */
+    public NeutronNetwork defaultNeutronObjectUpdate() {
+        NeutronNetwork delta_neutron = new NeutronNetwork();
+        delta_neutron.setNetworkName("Virtual-Network-2");
+        delta_neutron.setTenantID("cfedfe89b66e406aad56052873c683e7");
+        delta_neutron.setProviderSegmentationID("3");
+        delta_neutron.setAdminStateUp(true);
+        delta_neutron.setProviderNetworkType("gre");
+        delta_neutron.setProviderSegmentationID("4");
+        delta_neutron.setShared(false);
+        delta_neutron.setRouterExternal(false);
+        return delta_neutron;
+    }
+
+    /* Test method to check if neutron network is null */
+    @Test
+    public void testCanCreateNetworkNull() {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canCreateNetwork(null));
+    }
+
+    /* Test method to check if neutron network uuid or name is null */
+    @Test
+    public void testCanCreateNetworkUuidNameNull() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutron = new NeutronNetwork();
+        neutron.setNetworkUUID(null);
+        neutron.setNetworkName(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canCreateNetwork(neutron));
+    }
+
+    /* Test method to check if neutron network uuid is empty or name is null */
+    @Test
+    public void testCanCreateNetworkUuidEmpty() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutron = new NeutronNetwork();
+        neutron.setNetworkUUID("");
+        neutron.setNetworkName(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canCreateNetwork(neutron));
+    }
+
+    /* Test method to check if neutron network tenant id is null */
+    @Test
+    public void testCanCreateNetworkTenantIdNull() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        neutronNetwork.setTenantID(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canCreateNetwork(neutronNetwork));
+    }
+
+    /* Test method to check neutron network with virtual network Existence */
+    @Test
+    public void testCanCreateNetworkVirtualNetworkExists() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.findById(Project.class, neutronNetwork.getTenantID())).thenReturn(mockProject);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, networkHandler.canCreateNetwork(neutronNetwork));
+    }
+
+    /*
+     * Test method to check neutron network creation fails with Internal Server
+     * Error
+     */
+    @Test
+    public void testCanCreateNetworkInternalError() throws Exception {
+        VirtualNetwork mockInstance = PowerMock.createNiceMock(VirtualNetwork.class);
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        expectNew(VirtualNetwork.class).andReturn(mockInstance);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(Project.class, neutronNetwork.getTenantID())).thenReturn(mockProject);
+        when(mockedApiConnector.create(mockInstance)).thenReturn(false);
+        PowerMock.replay(mockInstance, VirtualNetwork.class);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, networkHandler.canCreateNetwork(neutronNetwork));
+    }
+
+    /* Test method to check network is created */
+    @Test
+    public void testCanCreateNetworkHttpOk() throws Exception {
+        VirtualNetwork mockInstance = PowerMock.createNiceMock(VirtualNetwork.class);
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        expectNew(VirtualNetwork.class).andReturn(mockInstance);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(Project.class, neutronNetwork.getTenantID())).thenReturn(mockProject);
+        when(mockedApiConnector.create(mockInstance)).thenReturn(true);
+        PowerMock.replay(mockInstance, VirtualNetwork.class);
+        assertEquals(HttpURLConnection.HTTP_OK, networkHandler.canCreateNetwork(neutronNetwork));
+    }
+
+    /* Test method to check neutron network with virtual network Existence */
+    @Test
+    public void testcanCreateNetworkProjectNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        when(mockedApiConnector.findById(Project.class, neutronNetwork.getTenantID())).thenReturn(null);
+        when(mockedApiConnector.findById(Project.class, neutronNetwork.getTenantID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_NOT_FOUND, networkHandler.canCreateNetwork(neutronNetwork));
+    }
+
+    /* Test method to check neutron network with virtual network Existence */
+    @Test
+    public void testcanDeleteNetwork() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canDeleteNetwork(neutronNetwork));
+    }
+
+    /* Test method to check delete network with when Port exist */
+    @Test
+    public void testcanDeleteNetworkPortExists() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        List<ObjectReference<ApiPropertyBase>> test = new ArrayList<ObjectReference<ApiPropertyBase>>();
+        when(mockedVirtualNetwork.getVirtualMachineInterfaceBackRefs()).thenReturn(test);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, networkHandler.canDeleteNetwork(neutronNetwork));
+    }
+
+    /* Test method to check if neutron network is null */
+    @Test
+    public void testCanUpdateNetworkNull() {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canUpdateNetwork(null, null));
+    }
+
+    /* Test method to check if neutron network is null */
+    @Test
+    public void testCanUpdateNetworkEmptyName() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        NeutronNetwork delta_neutronNetwork = defaultNeutronObjectUpdate();
+        delta_neutronNetwork.setNetworkName("");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, networkHandler.canUpdateNetwork(delta_neutronNetwork, neutronNetwork));
+    }
+
+    /* Test method to check neutron network with virtual network Existence */
+    @Test
+    public void testCanUpdateNetworkVirtualNetworkNotExists() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        NeutronNetwork delta_neutronNetwork = defaultNeutronObjectUpdate();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, networkHandler.canUpdateNetwork(delta_neutronNetwork, neutronNetwork));
+    }
+
+    /*
+     * Test method to check neutron network update fails with Internal Server
+     * Error
+     */
+    @Test
+    public void testUpdateNetworkInternalError() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        NeutronNetwork delta_neutronNetwork = defaultNeutronObjectUpdate();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(false);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, networkHandler.canUpdateNetwork(delta_neutronNetwork, neutronNetwork));
+    }
+
+    /* Test method to check neutron network update with HTTP OK */
+    @Test
+    public void testUpdateNetwork() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronNetwork neutronNetwork = defaultNeutronObject();
+        NeutronNetwork delta_neutronNetwork = defaultNeutronObjectUpdate();
+        mockedVirtualNetwork.setName(delta_neutronNetwork.getNetworkName());
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronNetwork.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_OK, networkHandler.canUpdateNetwork(delta_neutronNetwork, neutronNetwork));
+    }
+}
\ No newline at end of file
diff --git a/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/PortHandlerTest.java b/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/PortHandlerTest.java
new file mode 100755 (executable)
index 0000000..b140e29
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+d * Copyright (C) 2014 Juniper Networks, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+package org.opendaylight.plugin2oc.neutron;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.types.InstanceIp;
+import net.juniper.contrail.api.types.Project;
+import net.juniper.contrail.api.types.VirtualMachine;
+import net.juniper.contrail.api.types.VirtualMachineInterface;
+import net.juniper.contrail.api.types.VirtualNetwork;
+
+import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
+import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.easymock.PowerMock.expectNew;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+/**
+ * Test Class for Neutron Network.
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ PortHandler.class, VirtualMachineInterface.class, InstanceIp.class })
+public class PortHandlerTest {
+    PortHandler porthandler;
+    PortHandler mockedporthandler = mock(PortHandler.class);
+    NeutronNetwork mockedNeutronNetwork = mock(NeutronNetwork.class);
+    ApiConnector mockedApiConnector = mock(ApiConnector.class);
+    VirtualNetwork mockedVirtualNetwork = mock(VirtualNetwork.class);
+    NeutronPort mockedNeutronPort = mock(NeutronPort.class);
+    VirtualMachineInterface mockedVirtualMachineInterface = mock(VirtualMachineInterface.class);
+    VirtualMachine mockedvirtualMachine = mock(VirtualMachine.class);
+    Project mockedProject = mock(Project.class);
+    Neutron_IPs mockNeutron_IPs = mock(Neutron_IPs.class);
+    InstanceIp mockInstanceIp = mock(InstanceIp.class);
+
+    @Before
+    public void beforeTest() {
+        porthandler = new PortHandler();
+        assertNotNull(mockedApiConnector);
+        assertNotNull(mockedNeutronNetwork);
+        assertNotNull(mockedVirtualNetwork);
+        assertNotNull(mockedNeutronPort);
+        assertNotNull(mockedVirtualMachineInterface);
+        assertNotNull(mockedvirtualMachine);
+        assertNotNull(mockNeutron_IPs);
+        assertNotNull(mockInstanceIp);
+        assertNotNull(mockedProject);
+    }
+
+    @After
+    public void AfterTest() {
+        porthandler = null;
+        Activator.apiConnector = null;
+    }
+
+    /* dummy params for Neutron Port */
+    public NeutronPort defaultNeutronPortObject() {
+        NeutronPort neutronPort = new NeutronPort();
+        neutronPort.setPortUUID("64a271fe-0216-46bc-a3e6-1ff582fbd324");
+        neutronPort.setNetworkUUID("54a271fe-0216-46bc-a3e6-1ff582fbd324");
+        neutronPort.setMacAddress("02:70:72:93:4d:d6");
+        neutronPort.setName("port12");
+        neutronPort.setDeviceID("100071fe-0216-46bc-a3e6-1ff582fbd324");
+        neutronPort.setTenantID("100071fe-0216-46bc-a3e6-1ff582fbd324");
+        List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+        ips.add(mockNeutron_IPs);
+        neutronPort.setFixedIPs(ips);
+        return neutronPort;
+    }
+
+    /* dummy params for Update Neutron Port */
+    public NeutronPort detaNeutronPort() {
+        NeutronPort dummyNeutronPort = new NeutronPort();
+        dummyNeutronPort.setPortUUID("64a271fe-0216-46bc-a3e6-1ff582fbd324");
+        dummyNeutronPort.setNetworkUUID("54a271fe-0216-46bc-a3e6-1ff582fbd324");
+        dummyNeutronPort.setName("port01");
+        dummyNeutronPort.setDeviceID("100071fe-0216-46bc-a3e6-1ff582fbd324");
+        dummyNeutronPort.setTenantID("100071fe-0216-46bc-a3e6-1ff582fbd324");
+        List<Neutron_IPs> ips = new ArrayList<Neutron_IPs>();
+        ips.add(mockNeutron_IPs);
+        dummyNeutronPort.setFixedIPs(ips);
+        return dummyNeutronPort;
+    }
+
+    /* Test method to check if neutron port is null */
+
+    @Test
+    public void testCanCreatePortNull() {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canCreatePort(null));
+    }
+
+    /* Test method to check if neutron port device ID is empty */
+    @Test
+    public void testCanCreateIdEmtpy() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = new NeutronPort();
+        neutronPort.setPortUUID("");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if neutron port tenant id is null */
+    @Test
+    public void testCanCreateTenantIdNull() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        neutronPort.setTenantID(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if neutron port fixed IP is null */
+    @Test
+    public void testCanCreateFixedIPNull() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        neutronPort.setFixedIPs(null);
+        when(mockedNeutronPort.getFixedIPs()).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if neutron port is already exist */
+    @Test
+    public void testCanCreatePortExist() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getID())).thenReturn(mockedVirtualMachineInterface);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if Virtual Machine Is Not Created */
+    @Test
+    public void testCanCreatePortVirtualMachineNotCreated() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        VirtualMachine mockedvirtualMachine = PowerMock.createNiceMock(VirtualMachine.class);
+        expectNew(VirtualMachine.class).andReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(null);
+        when(mockedApiConnector.create(mockedvirtualMachine)).thenReturn(false);
+        PowerMock.replay(mockedvirtualMachine, VirtualMachine.class);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if Project is not available */
+    @Test
+    public void testCanCreatePortProjectSearch() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(null);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_NOT_FOUND, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if Virtual Network does not exist */
+    @Test
+    public void testCanCreatePortVirtualNetworkNotExist() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(mockedProject);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronPort.getNetworkUUID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if virtual machine interface creation failed */
+    @Test
+    public void testCanCreateVirtualMachineInterface() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        VirtualMachineInterface mockedVirtualMachineInterface = PowerMock.createNiceMock(VirtualMachineInterface.class);
+        expectNew(VirtualMachineInterface.class).andReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(mockedProject);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronPort.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.create(mockedVirtualMachineInterface)).thenReturn(false);
+        PowerMock.replay(mockedVirtualMachineInterface, VirtualMachineInterface.class);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check port is not created */
+    @Test
+    public void testCanCreatePortFails() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        VirtualMachineInterface mockedVirtualMachineInterface = PowerMock.createNiceMock(VirtualMachineInterface.class);
+        expectNew(VirtualMachineInterface.class).andReturn(mockedVirtualMachineInterface);
+        InstanceIp mockedInstanceIp = PowerMock.createNiceMock(InstanceIp.class);
+        expectNew(InstanceIp.class).andReturn(mockedInstanceIp);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(mockedProject);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronPort.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.create(mockedVirtualMachineInterface)).thenReturn(true);
+        PowerMock.replay(mockedVirtualMachineInterface, VirtualMachineInterface.class);
+        when(neutronPort.getFixedIPs().get(0).getIpAddress()).thenReturn("10.0.0.1");
+        when(mockedApiConnector.create(mockedInstanceIp)).thenReturn(false);
+        PowerMock.replay(mockedInstanceIp, InstanceIp.class);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check port is created */
+
+    @Test
+    public void testCanCreatePortOk() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        VirtualMachineInterface mockedVirtualMachineInterface = PowerMock.createNiceMock(VirtualMachineInterface.class);
+        expectNew(VirtualMachineInterface.class).andReturn(mockedVirtualMachineInterface);
+        InstanceIp mockedInstanceIp = PowerMock.createNiceMock(InstanceIp.class);
+        expectNew(InstanceIp.class).andReturn(mockedInstanceIp);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(null);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.findById(Project.class, neutronPort.getTenantID())).thenReturn(mockedProject);
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronPort.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedApiConnector.create(mockedVirtualMachineInterface)).thenReturn(true);
+        PowerMock.replay(mockedVirtualMachineInterface, VirtualMachineInterface.class);
+        when(neutronPort.getFixedIPs().get(0).getIpAddress()).thenReturn("10.0.0.1");
+        when(mockedApiConnector.create(mockedInstanceIp)).thenReturn(true);
+        PowerMock.replay(mockedInstanceIp, InstanceIp.class);
+        assertEquals(HttpURLConnection.HTTP_OK, porthandler.canCreatePort(neutronPort));
+    }
+
+    /* Test method to check if neutron port is null for delete */
+    @Test
+    public void testcanDeletePortNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canDeletePort(null));
+    }
+
+    /* Test method to check if virtual machine interface is null */
+    @Test
+    public void testcanDeletePortVirtualMachineInterfaceNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canDeletePort(neutronPort));
+    }
+
+    /* Test method to update port with null neutron port and delta port */
+    @Test
+    public void testcanUpdatePortNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canUpdatePort(null, null));
+    }
+
+    /* Test method to update port with mac address */
+    @Test
+    public void testcanUpdatePortMacAddress() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        dummyNeutronPort.setMacAddress("00:70:72:93:4d:d6");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port when IpPrefix is null and network Uuid exist */
+    @Test
+    public void testcanUpdatePortIpPrefixNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        dummyNeutronPort.setFixedIPs(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port when virtual machine create fails */
+    @Test
+    public void testcanUpdatePortVirtualMachineCreateFail() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        VirtualMachine mockedVirtualMachine = PowerMock.createNiceMock(VirtualMachine.class);
+        expectNew(VirtualMachine.class).andReturn(mockedVirtualMachine);
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        dummyNeutronPort.setFixedIPs(null);
+        dummyNeutronPort.setNetworkUUID(null);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(null);
+        when(mockedApiConnector.create(mockedVirtualMachine)).thenReturn(false);
+        PowerMock.replay(mockedVirtualMachine, VirtualMachine.class);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port when update fails */
+    @Test
+    public void testcanUpdatePortVirtualMachineInterfaceUpdateFail() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        dummyNeutronPort.setFixedIPs(null);
+        dummyNeutronPort.setNetworkUUID(null);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.update(mockedVirtualMachineInterface)).thenReturn(false);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port */
+    @Test
+    public void testcanUpdatePortVirtualMachineInterfaceUpdateOk() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        dummyNeutronPort.setFixedIPs(null);
+        dummyNeutronPort.setNetworkUUID(null);
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualMachine.class, neutronPort.getDeviceID())).thenReturn(mockedvirtualMachine);
+        when(mockedApiConnector.update(mockedVirtualMachineInterface)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_OK, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port when virtual network does not exist */
+    @Test
+    public void testcanUpdatePortVirtualNetworkNotExist() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualNetwork.class, dummyNeutronPort.getNetworkUUID())).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+
+    /* Test method to update port when virtual network does not exist */
+    @Test
+    public void testcanUpdatePortSubnetNotExistInNetwork() throws Exception {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronPort neutronPort = defaultNeutronPortObject();
+        NeutronPort dummyNeutronPort = detaNeutronPort();
+        when(mockedApiConnector.findById(VirtualMachineInterface.class, neutronPort.getPortUUID())).thenReturn(mockedVirtualMachineInterface);
+        when(mockedApiConnector.findById(VirtualNetwork.class, dummyNeutronPort.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, porthandler.canUpdatePort(dummyNeutronPort, neutronPort));
+    }
+}
\ No newline at end of file
diff --git a/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/SubnetHandlerTest.java b/neutron/src/test/java/org/opendaylight/plugin2oc/neutron/SubnetHandlerTest.java
new file mode 100755 (executable)
index 0000000..5927156
--- /dev/null
@@ -0,0 +1,359 @@
+package org.opendaylight.plugin2oc.neutron;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.juniper.contrail.api.ApiConnector;
+import net.juniper.contrail.api.ObjectReference;
+import net.juniper.contrail.api.types.SubnetType;
+import net.juniper.contrail.api.types.VirtualNetwork;
+import net.juniper.contrail.api.types.VnSubnetsType;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
+import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet_IPAllocationPool;
+
+/**
+ * Test Class for Subnet.
+ */
+public class SubnetHandlerTest {
+    SubnetHandler subnetHandler;
+    VirtualNetwork mockedVirtualNetwork = mock(VirtualNetwork.class);
+    SubnetHandler mockedSubnetHandler = mock(SubnetHandler.class);
+    ApiConnector mockedApiConnector = mock(ApiConnector.class);
+
+    @Before
+    public void beforeTest() {
+        subnetHandler = new SubnetHandler();
+        assertNotNull(mockedApiConnector);
+        assertNotNull(mockedVirtualNetwork);
+        assertNotNull(mockedSubnetHandler);
+    }
+
+    @After
+    public void afterTest() {
+        subnetHandler = null;
+        Activator.apiConnector = null;
+    }
+
+    /* dummy params for Neutron Subnet */
+    public NeutronSubnet defaultSubnetObject() {
+        NeutronSubnet subnet = new NeutronSubnet();
+        List<NeutronSubnet_IPAllocationPool> allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+        NeutronSubnet_IPAllocationPool neutronSubnet_IPAllocationPool = new NeutronSubnet_IPAllocationPool();
+        subnet.setNetworkUUID("6b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        subnet.setSubnetUUID("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        subnet.setCidr("10.0.0.0/24");
+        subnet.setGatewayIP("10.0.0.254");
+        neutronSubnet_IPAllocationPool.setPoolStart("10.0.0.1");
+        neutronSubnet_IPAllocationPool.setPoolEnd("10.0.0.254");
+        allocationPools.add(neutronSubnet_IPAllocationPool);
+        subnet.setAllocationPools(allocationPools);
+        return subnet;
+    }
+
+    /* dummy params for Neutron Delta Subnet */
+    public NeutronSubnet defaultDeltaSubnet() {
+        NeutronSubnet subnet = new NeutronSubnet();
+        subnet.setNetworkUUID("6b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        subnet.setSubnetUUID("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        subnet.setCidr("10.0.0.0/24");
+        subnet.setGatewayIP("10.0.0.254");
+        return subnet;
+    }
+
+    /* Test method to check if neutron subnet is null */
+    @Test
+    public void testCanCreateSubnetNull() {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canCreateSubnet(null));
+    }
+
+    /* Test method to check if neutron subnet is null */
+    @Test
+    public void testCanCreateSubnetCidrNull() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet subnet = new NeutronSubnet();
+        subnet.setCidr(null);
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canCreateSubnet(subnet));
+    }
+
+    /* Test method to check if Gateway Ip is invalid */
+    @Test
+    public void testCanCreateSubnetInvalidGatewayIp() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        neutronSubnet.setGatewayIP("20.0.0.250");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canCreateSubnet(neutronSubnet));
+    }
+
+    /* Test method to check if virtual network is null */
+
+    @Test
+    public void testCanCreateSubnetVirtualNetworkNull() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, subnetHandler.canCreateSubnet(neutronSubnet));
+    }
+
+    /* Test method to check if subnet can be created with IpamRefs null */
+    @Test
+    public void testCanCreateSubnet() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(null);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_OK, subnetHandler.canCreateSubnet(neutronSubnet));
+    }
+
+    /* Test method to check if subnet creation returns Internal Server Error */
+    @Test
+    public void testCanCreateSubnetException() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(null);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(false);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, subnetHandler.canCreateSubnet(neutronSubnet));
+    }
+
+    /* Test method to check if subnet already exists */
+    @Test
+    public void testCanCreateSubnetExists() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        VnSubnetsType vnSubnetType = new VnSubnetsType();
+        ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
+        List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
+        List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
+        VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
+        SubnetType type = new SubnetType();
+        List<String> temp = new ArrayList<String>();
+        for (int i = 0; i < 1; i++) {
+            subnetType.setSubnet(type);
+            subnetType.getSubnet().setIpPrefix("10.0.0.0");
+            subnetType.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType);
+            vnSubnetType.addIpamSubnets(subnetType);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
+        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, subnetHandler.canCreateSubnet(neutronSubnet));
+    }
+
+    /* Test method to check ipPrefix */
+    @Test
+    public void testGetIpPrefix() {
+        SubnetHandler.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        String cidr = "10.0.0.0/24";
+        String[] ipPrefix = cidr.split("/");
+        assertArrayEquals(ipPrefix, subnetHandler.getIpPrefix(neutronSubnet));
+    }
+
+    /* Test method to check if ipPrefix is valid */
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetIpPrefixInvalid() {
+        SubnetHandler.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = new NeutronSubnet();
+        neutronSubnet.setNetworkUUID("6b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        neutronSubnet.setSubnetUUID("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
+        neutronSubnet.setCidr("10.0.0.0");
+        subnetHandler.getIpPrefix(neutronSubnet);
+    }
+
+    /* Test method to check if neutron subnets are null for update */
+    @Test
+    public void testcanUpdateSubnetNull() {
+        Activator.apiConnector = mockedApiConnector;
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canUpdateSubnet(null, null));
+    }
+
+    /* Test method to check if updated subnet gateway ip is empty */
+    @Test
+    public void testcanUpdateSubnetGatewayEmpty() {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        NeutronSubnet deltaSubnet = new NeutronSubnet();
+        deltaSubnet.setGatewayIP("");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
+    }
+
+    /* Test method to check if gateway ip is valide for update */
+    @Test
+    public void testcanUpdateSubnetInvalidGateway() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        NeutronSubnet deltaSubnet = defaultDeltaSubnet();
+        deltaSubnet.setGatewayIP("20.0.0.200");
+        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
+    }
+
+    /* Test method to check if subnets do not exist */
+    @Test
+    public void testcanUpdateSubnetNotFound() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        NeutronSubnet deltaSubnet = defaultDeltaSubnet();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
+    }
+
+    /*
+     * Test method to check if subnet already exists and update subnet
+     * successfully
+     */
+    @Test
+    public void testcanUpdateSubnetOK() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        NeutronSubnet deltaSubnet = defaultDeltaSubnet();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        VnSubnetsType vnSubnetType = new VnSubnetsType();
+        ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
+        List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
+        List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
+        VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
+        SubnetType type = new SubnetType();
+        List<String> temp = new ArrayList<String>();
+        for (int i = 0; i < 1; i++) {
+            subnetType.setSubnet(type);
+            subnetType.setSubnetUuid("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
+            subnetType.getSubnet().setIpPrefix("10.0.0.0");
+            subnetType.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType);
+            vnSubnetType.addIpamSubnets(subnetType);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_OK, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
+    }
+
+    /* Test method to check if subnet already exists and update subnet fails */
+    @Test
+    public void testcanUpdateSubnetFail() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        NeutronSubnet deltaSubnet = defaultDeltaSubnet();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        VnSubnetsType vnSubnetType = new VnSubnetsType();
+        ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
+        List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
+        List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
+        VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
+        SubnetType type = new SubnetType();
+        List<String> temp = new ArrayList<String>();
+        for (int i = 0; i < 1; i++) {
+            subnetType.setSubnet(type);
+            subnetType.setSubnetUuid("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
+            subnetType.getSubnet().setIpPrefix("10.0.0.0");
+            subnetType.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType);
+            vnSubnetType.addIpamSubnets(subnetType);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(false);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
+    }
+
+    /* Tets method to check if a subnet deletion terminate with Internal_Error */
+    @Test
+    public void testCanDeleteSubnet() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(null);
+        assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, subnetHandler.canDeleteSubnet(neutronSubnet));
+
+    }
+
+    /*
+     * Tets method to check if a subnet is deleted from the network when
+     * vnSubnetsType.getIpamSubnets() is not null
+     */
+    @Test
+    public void testCanDeleteSubnetTrue() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        List<ObjectReference<VnSubnetsType>> ipamRefs = mockedVirtualNetwork.getNetworkIpam();
+        VnSubnetsType vnSubnetType = new VnSubnetsType();
+        ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
+        List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
+        VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
+        SubnetType type = new SubnetType();
+        List<String> temp = new ArrayList<String>();
+        for (int i = 0; i < 1; i++) {
+            subnetType.setSubnet(type);
+            subnetType.getSubnet().setIpPrefix("10.0.0.0");
+            subnetType.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType);
+            vnSubnetType.addIpamSubnets(subnetType);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        VnSubnetsType.IpamSubnetType subnetType1 = new VnSubnetsType.IpamSubnetType();
+        SubnetType type1 = new SubnetType();
+        for (int i = 0; i < 1; i++) {
+            subnetType1.setSubnet(type1);
+            subnetType1.getSubnet().setIpPrefix("10.0.1.0");
+            subnetType1.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType1);
+            vnSubnetType.addIpamSubnets(subnetType1);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_NO_CONTENT, subnetHandler.canDeleteSubnet(neutronSubnet));
+    }
+
+    /*
+     * Test method to check if a subnet is deleted from the network when
+     * vnSubnetsType.getIpamSubnets() is null
+     */
+    @Test
+    public void testCanDeleteSubnetNullGetIpamSubnets() throws IOException {
+        Activator.apiConnector = mockedApiConnector;
+        NeutronSubnet neutronSubnet = defaultSubnetObject();
+        when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
+        List<ObjectReference<VnSubnetsType>> ipamRefs = mockedVirtualNetwork.getNetworkIpam();
+        VnSubnetsType vnSubnetType = new VnSubnetsType();
+        ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
+        List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
+        VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
+        SubnetType type = new SubnetType();
+        List<String> temp = new ArrayList<String>();
+        for (int i = 0; i < 1; i++) {
+            subnetType.setSubnet(type);
+            subnetType.getSubnet().setIpPrefix("10.0.0.0");
+            subnetType.getSubnet().setIpPrefixLen(24);
+            subnets.add(subnetType);
+            vnSubnetType.addIpamSubnets(subnetType);
+            ref.setReference(temp, vnSubnetType, "", "");
+            ipamRefs.add(ref);
+        }
+        when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
+        when(mockedApiConnector.update(mockedVirtualNetwork)).thenReturn(true);
+        assertEquals(HttpURLConnection.HTTP_NO_CONTENT, subnetHandler.canDeleteSubnet(neutronSubnet));
+    }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100755 (executable)
index 0000000..b418b75
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+  <prerequisites>
+    <maven>3.0</maven>
+  </prerequisites>
+
+  <parent>
+    <groupId>org.opendaylight.plugin2oc</groupId>
+    <artifactId>commons.plugin2oc</artifactId>
+    <version>0.1</version>
+    <relativePath>commons/parent</relativePath>
+  </parent>
+  <groupId>org.opendaylight.plugin2oc</groupId>
+  <artifactId>plugin2oc.project</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+  <properties>
+  <sonar.host.url> http://localhost:9000/ </sonar.host.url>
+  </properties>
+  <modules>
+    <module>neutron</module>
+    <module>commons/parent</module>
+  </modules>
+</project>
\ No newline at end of file