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;
/**
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;
@DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
// sorting not supported
) {
- INeutronPortCRUD portInterface = getNeutronInterfaces(false, false).getPortInterface();
+ INeutronPortCRUD portInterface = getNeutronCRUD();
List<NeutronPort> allPorts = portInterface.getAll();
List<NeutronPort> ans = new ArrayList<>();
Iterator<NeutronPort> i = allPorts.iterator();
@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);
}
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;
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 */
@QueryParam("page_reverse") String pageReverse
// sorting not supported
) {
- INeutronRouterCRUD routerInterface = getNeutronInterfaces(false).getRouterInterface();
+ INeutronRouterCRUD routerInterface = getNeutronCRUD();
if (routerInterface == null) {
throw new ServiceUnavailableException(serviceUnavailable());
}
@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);
}
@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);
}
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;
/**
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;
@DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
// sorting not supported
) {
- INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface();
+ INeutronSubnetCRUD subnetInterface = getNeutronCRUD();
List<NeutronSubnet> allNetworks = subnetInterface.getAll();
List<NeutronSubnet> ans = new ArrayList<>();
Iterator<NeutronSubnet> i = allNetworks.iterator();
@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);
}