From: Isaku Yamahata Date: Tue, 13 Sep 2016 15:50:29 +0000 (-0700) Subject: northbound: simplify neutron interface loading X-Git-Tag: release/carbon~62 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F45543%2F1;p=neutron.git northbound: simplify neutron interface loading Now subnets/ports/routers northbound doesn't need dependent interface. So getNeutronInterface() can be removed. Change-Id: I7a78ec35a0b7f2efa79840672e257cc7e5724457 Signed-off-by: Isaku Yamahata --- diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java index 3fd71c768..966837439 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.UriInfo; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; import org.opendaylight.neutron.spi.INeutronPortCRUD; -import org.opendaylight.neutron.spi.NeutronCRUDInterfaces; import org.opendaylight.neutron.spi.NeutronPort; /** @@ -61,33 +60,6 @@ public final class NeutronPortsNorthbound return RESOURCE_NAME; } - private NeutronCRUDInterfaces getNeutronInterfaces(boolean needNetworks, boolean needSubnets) { - NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronPortCRUD(this); - if (answer.getPortInterface() == null) { - throw new ServiceUnavailableException(serviceUnavailable()); - } - if (needNetworks) { - answer = answer.fetchINeutronNetworkCRUD(this); - if (answer.getNetworkInterface() == null) { - throw new ServiceUnavailableException( - "Network CRUD Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); - } - } - if (needSubnets) { - answer = answer.fetchINeutronSubnetCRUD(this); - if (answer.getSubnetInterface() == null) { - throw new ServiceUnavailableException( - "Subnet CRUD Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); - } - } - return answer; - } - - @Override - protected INeutronPortCRUD getNeutronCRUD() { - return getNeutronInterfaces(false, false).getPortInterface(); - } - @Context UriInfo uriInfo; @@ -122,7 +94,7 @@ public final class NeutronPortsNorthbound @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse // sorting not supported ) { - INeutronPortCRUD portInterface = getNeutronInterfaces(false, false).getPortInterface(); + INeutronPortCRUD portInterface = getNeutronCRUD(); List allPorts = portInterface.getAll(); List ans = new ArrayList<>(); Iterator i = allPorts.iterator(); @@ -186,7 +158,6 @@ public final class NeutronPortsNorthbound @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"), @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) public Response createPorts(final NeutronPortRequest input) { - getNeutronInterfaces(true, true); // Ensure that services for networks and subnets are loaded return create(input); } diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java index 60264b4de..2eee4be8e 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java @@ -26,7 +26,6 @@ import javax.ws.rs.core.Response; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; import org.opendaylight.neutron.spi.INeutronRouterCRUD; -import org.opendaylight.neutron.spi.NeutronCRUDInterfaces; import org.opendaylight.neutron.spi.NeutronRouter; import org.opendaylight.neutron.spi.NeutronRouter_Interface; @@ -60,26 +59,6 @@ public final class NeutronRoutersNorthbound return RESOURCE_NAME; } - private NeutronCRUDInterfaces getNeutronInterfaces(boolean flag) { - NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronRouterCRUD(this); - if (answer.getRouterInterface() == null) { - throw new ServiceUnavailableException(serviceUnavailable()); - } - if (flag) { - answer = answer.fetchINeutronNetworkCRUD(this); - if (answer.getNetworkInterface() == null) { - throw new ServiceUnavailableException( - "Network CRUD Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); - } - } - return answer; - } - - @Override - protected INeutronRouterCRUD getNeutronCRUD() { - return getNeutronInterfaces(false).getRouterInterface(); - } - /** * Returns a list of all Routers */ @@ -106,7 +85,7 @@ public final class NeutronRoutersNorthbound @QueryParam("page_reverse") String pageReverse // sorting not supported ) { - INeutronRouterCRUD routerInterface = getNeutronInterfaces(false).getRouterInterface(); + INeutronRouterCRUD routerInterface = getNeutronCRUD(); if (routerInterface == null) { throw new ServiceUnavailableException(serviceUnavailable()); } @@ -162,7 +141,6 @@ public final class NeutronRoutersNorthbound @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"), @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) public Response createRouters(final NeutronRouterRequest input) { - getNeutronInterfaces(true); // ensure that network service is loaded return create(input); } @@ -184,7 +162,6 @@ public final class NeutronRoutersNorthbound @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"), @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) public Response updateRouter(@PathParam("routerUUID") String routerUUID, NeutronRouterRequest input) { - getNeutronInterfaces(true); // ensure that network service is loaded return update(routerUUID, input); } diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java index 561c4ca10..4a7d4634f 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.UriInfo; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; import org.opendaylight.neutron.spi.INeutronSubnetCRUD; -import org.opendaylight.neutron.spi.NeutronCRUDInterfaces; import org.opendaylight.neutron.spi.NeutronSubnet; /** @@ -60,26 +59,6 @@ public final class NeutronSubnetsNorthbound return RESOURCE_NAME; } - private NeutronCRUDInterfaces getNeutronInterfaces(boolean needNetwork) { - NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSubnetCRUD(this); - if (answer.getSubnetInterface() == null) { - throw new ServiceUnavailableException(serviceUnavailable()); - } - if (needNetwork) { - answer = answer.fetchINeutronNetworkCRUD(this); - if (answer.getNetworkInterface() == null) { - throw new ServiceUnavailableException( - "Network CRUD Interface " + RestMessages.SERVICEUNAVAILABLE.toString()); - } - } - return answer; - } - - @Override - protected INeutronSubnetCRUD getNeutronCRUD() { - return getNeutronInterfaces(false).getSubnetInterface(); - } - @Context UriInfo uriInfo; @@ -112,7 +91,7 @@ public final class NeutronSubnetsNorthbound @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse // sorting not supported ) { - INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface(); + INeutronSubnetCRUD subnetInterface = getNeutronCRUD(); List allNetworks = subnetInterface.getAll(); List ans = new ArrayList<>(); Iterator i = allNetworks.iterator(); @@ -174,7 +153,6 @@ public final class NeutronSubnetsNorthbound @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"), @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") }) public Response createSubnets(final NeutronSubnetRequest input) { - getNeutronInterfaces(true); // Ensure that network service is loaded return create(input); }