X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fnorthbound%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fnorthbound%2FNeutronNetworksNorthbound.java;h=3a3c657956133f11db8087037492cb4616865d08;hb=6405fa8d6b47e406cdf566b26b15f980d802cad4;hp=9de5aef5f421eb2436ac73a6dff63e24efcf4c64;hpb=5448d6812e386bd56aec7209c4852c586a6163b3;p=controller.git
diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java
index 9de5aef5f4..3a3c657956 100644
--- a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java
+++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNetworksNorthbound.java
@@ -25,23 +25,16 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
import org.codehaus.enunciate.jaxrs.TypeHint;
-
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-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 for Network.
@@ -209,15 +202,21 @@ public class NeutronNetworksNorthbound {
throw new BadRequestException("network UUID already exists");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canCreateNetwork(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronNetworkAware service = (INeutronNetworkAware) instance;
+ int status = service.canCreateNetwork(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 network to cache
@@ -234,7 +233,7 @@ public class NeutronNetworksNorthbound {
List bulk = input.getBulk();
Iterator i = bulk.iterator();
HashMap testMap = new HashMap();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
while (i.hasNext()) {
NeutronNetwork test = i.next();
@@ -249,13 +248,19 @@ public class NeutronNetworksNorthbound {
throw new BadRequestException("network UUID already exists");
}
if (instances != null) {
- for (Object instance: instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canCreateNetwork(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance: instances) {
+ INeutronNetworkAware service = (INeutronNetworkAware) instance;
+ int status = service.canCreateNetwork(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");
}
testMap.put(test.getID(),test);
}
@@ -317,16 +322,22 @@ public class NeutronNetworksNorthbound {
throw new BadRequestException("attribute edit blocked by Neutron");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- NeutronNetwork original = networkInterface.getNetwork(netUUID);
- int status = service.canUpdateNetwork(delta, original);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronNetworkAware service = (INeutronNetworkAware) instance;
+ NeutronNetwork original = networkInterface.getNetwork(netUUID);
+ int status = service.canUpdateNetwork(delta, 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");
}
// update network object and return the modified object
@@ -371,16 +382,23 @@ public class NeutronNetworksNorthbound {
}
NeutronNetwork singleton = networkInterface.getNetwork(netUUID);
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronNetworkAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- int status = service.canDeleteNetwork(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronNetworkAware service = (INeutronNetworkAware) instance;
+ int status = service.canDeleteNetwork(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");
}
+
networkInterface.removeNetwork(netUUID);
if (instances != null) {
for (Object instance : instances) {