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.<br>
}
}
- 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) {
List<NeutronPort> bulk = input.getBulk();
Iterator<NeutronPort> i = bulk.iterator();
HashMap<String, NeutronPort> testMap = new HashMap<String, NeutronPort>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
while (i.hasNext()) {
NeutronPort test = i.next();
}
}
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");
}
}
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
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) {