}
Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canCreateFloatingIP(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
+ int status = service.canCreateFloatingIP(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");
}
floatingIPInterface.addFloatingIP(singleton);
if (instances != null) {
NeutronFloatingIP target = floatingIPInterface.getFloatingIP(floatingipUUID);
Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canUpdateFloatingIP(singleton, target);
- if (status < 200 || status > 299)
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
+ int status = service.canUpdateFloatingIP(singleton, target);
+ 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");
}
floatingIPInterface.updateFloatingIP(floatingipUUID, singleton);
target = floatingIPInterface.getFloatingIP(floatingipUUID);
NeutronFloatingIP singleton = floatingIPInterface.getFloatingIP(floatingipUUID);
Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
if (instances != null) {
- for (Object instance : instances) {
- INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
- int status = service.canDeleteFloatingIP(singleton);
- if (status < 200 || status > 299)
- return Response.status(status).build();
+ if (instances.length > 0) {
+ for (Object instance : instances) {
+ INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
+ int status = service.canDeleteFloatingIP(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");
}
floatingIPInterface.removeFloatingIP(floatingipUUID);
if (instances != null) {