X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fnorthbound%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fnorthbound%2FNeutronPortsNorthbound.java;h=5ff3de58d6b7139ad3792e78ccad686dcccb9c4b;hb=3997099eb61b0f2adc47f7a85952c324e9de223f;hp=5451fbf3e129e4be88addabcc7816e308c2cb2b7;hpb=42c32160bfd41de57189bb246fec5ffb48ed8e9e;p=controller.git
diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java
index 5451fbf3e1..5ff3de58d6 100644
--- a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java
+++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronPortsNorthbound.java
@@ -38,12 +38,6 @@ import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
/**
* Neutron Northbound REST APIs.
@@ -263,18 +257,23 @@ public class NeutronPortsNorthbound {
}
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
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 (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canCreatePort(singleton);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
}
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
}
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
}
-
// add the port to the cache
portInterface.addPort(singleton);
if (instances != null) {
@@ -287,7 +286,7 @@ public class NeutronPortsNorthbound {
List bulk = input.getBulk();
Iterator i = bulk.iterator();
HashMap testMap = new HashMap();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
while (i.hasNext()) {
NeutronPort test = i.next();
@@ -359,13 +358,19 @@ 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();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canCreatePort(test);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
}
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
}
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
}
}
@@ -433,15 +438,21 @@ public class NeutronPortsNorthbound {
throw new BadRequestException("attribute change blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canUpdatePort(singleton, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canUpdatePort(singleton, original);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
}
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
}
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
}
// Verify the new fixed ips are valid
@@ -515,15 +526,21 @@ public class NeutronPortsNorthbound {
Response.status(403).build();
}
NeutronPort singleton = portInterface.getPort(portUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canDeletePort(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canDeletePort(singleton);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
}
+ } else {
+ throw new ServiceUnavailableException("No providers registered. Please try again later");
}
+ } else {
+ throw new ServiceUnavailableException("Couldn't get providers list. Please try again later");
}
portInterface.removePort(portUUID);
if (instances != null) {