From f1c1754184142b2e62b1f4f2a08184ad310971cb Mon Sep 17 00:00:00 2001 From: ankit21a Date: Tue, 20 May 2014 14:18:08 +0530 Subject: [PATCH] Fix for Bug 934 - issue in validations for nuetronPort creation and updatePort Change-Id: I642faf51a4e986ba3a379f51edc71b4f1398b95b Signed-off-by: ankit21a --- .../northbound/NeutronPortsNorthbound.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java index 9f24e79ea0..1a2512fde3 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java @@ -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 -- 2.36.6