X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fnorthbound%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fnorthbound%2FNeutronLoadBalancerNorthbound.java;h=67557ce41f7cf2816dcd611a042cf7b2466cc4a9;hp=308041fe599336cd4daee3266345472f9dbad5bf;hb=3997099eb61b0f2adc47f7a85952c324e9de223f;hpb=f7c3c90a9cebe51fcd70857177029f25141933b6 diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerNorthbound.java b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerNorthbound.java index 308041fe59..67557ce41f 100644 --- a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerNorthbound.java +++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerNorthbound.java @@ -186,14 +186,21 @@ public class NeutronLoadBalancerNorthbound { } Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; - int status = service.canCreateNeutronLoadBalancer(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; + int status = service.canCreateNeutronLoadBalancer(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"); } + loadBalancerInterface.addNeutronLoadBalancer(singleton); if (instances != null) { for (Object instance : instances) { @@ -220,13 +227,19 @@ public class NeutronLoadBalancerNorthbound { throw new BadRequestException("Load Balancer Pool UUID already exists"); } if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; - int status = service.canCreateNeutronLoadBalancer(test); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; + int status = service.canCreateNeutronLoadBalancer(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"); } } /* @@ -298,13 +311,19 @@ public class NeutronLoadBalancerNorthbound { Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; - int status = service.canUpdateNeutronLoadBalancer(delta, original); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; + int status = service.canUpdateNeutronLoadBalancer(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"); } /* @@ -355,15 +374,22 @@ public class NeutronLoadBalancerNorthbound { NeutronLoadBalancer singleton = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID); Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; - int status = service.canDeleteNeutronLoadBalancer(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerAware service = (INeutronLoadBalancerAware) instance; + int status = service.canDeleteNeutronLoadBalancer(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"); } + loadBalancerInterface.removeNeutronLoadBalancer(loadBalancerID); if (instances != null) { for (Object instance : instances) {