Fix for Bug 934 - issue in validations for nuetronPort creation and updatePort 34/7234/2
authorankit21a <ankit21.a@tcs.com>
Tue, 20 May 2014 08:48:08 +0000 (14:18 +0530)
committerankit21a <ankit21.a@tcs.com>
Tue, 20 May 2014 08:49:37 +0000 (14:19 +0530)
Change-Id: I642faf51a4e986ba3a379f51edc71b4f1398b95b
Signed-off-by: ankit21a <ankit21.a@tcs.com>
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java

index 9f24e79..1a2512f 100644 (file)
@@ -218,16 +218,6 @@ public class NeutronPortsNorthbound {
             if (portInterface.macInUse(singleton.getMacAddress())) {
                 throw new ResourceConflictException("MAC Address is in use.");
             }
-            Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
-            if (instances != null) {
-                for (Object instance : instances) {
-                    INeutronPortAware service = (INeutronPortAware) instance;
-                    int status = service.canCreatePort(singleton);
-                    if (status < 200 || status > 299) {
-                        return Response.status(status).build();
-                    }
-                }
-            }
             /*
              * if fixed IPs are specified, each one has to have an existing subnet ID
              * that is in the same scoping network as the port.  In addition, if an IP
@@ -260,6 +250,18 @@ public class NeutronPortsNorthbound {
                 }
             }
 
+            Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+            if (instances != null) {
+                for (Object instance : instances) {
+                    INeutronPortAware service = (INeutronPortAware) instance;
+                    int status = service.canCreatePort(singleton);
+                    if (status < 200 || status > 299) {
+                        return Response.status(status).build();
+                    }
+                }
+            }
+
+
             // add the port to the cache
             portInterface.addPort(singleton);
             if (instances != null) {
@@ -309,15 +311,7 @@ public class NeutronPortsNorthbound {
                 if (portInterface.macInUse(test.getMacAddress())) {
                     throw new ResourceConflictException("MAC address in use");
                 }
-                if (instances != null) {
-                    for (Object instance : instances) {
-                        INeutronPortAware service = (INeutronPortAware) instance;
-                        int status = service.canCreatePort(test);
-                        if (status < 200 || status > 299) {
-                            return Response.status(status).build();
-                        }
-                    }
-                }
+
                 /*
                  * if fixed IPs are specified, each one has to have an existing subnet ID
                  * that is in the same scoping network as the port.  In addition, if an IP
@@ -351,6 +345,15 @@ public class NeutronPortsNorthbound {
                         }
                     }
                 }
+                if (instances != null) {
+                    for (Object instance : instances) {
+                        INeutronPortAware service = (INeutronPortAware) instance;
+                        int status = service.canCreatePort(test);
+                        if (status < 200 || status > 299) {
+                            return Response.status(status).build();
+                        }
+                    }
+                }
             }
 
             //once everything has passed, then we can add to the cache

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.