northbound: code clean up
[neutron.git] / northbound-api / src / main / java / org / opendaylight / neutron / northbound / api / NeutronSubnetsNorthbound.java
index 8b7c7796456d7e9aea4d5102e5c8eb123023cd6d..561c4ca10470c75530b20e82360a7e22e84f1120 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corporation and others, 2013.  All rights reserved.
+ * Copyright (c) 2013, 2015 IBM Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,12 +9,9 @@
 package org.opendaylight.neutron.northbound.api;
 
 import java.net.HttpURLConnection;
-
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
@@ -29,11 +26,8 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetAware;
 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
 import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
 import org.opendaylight.neutron.spi.NeutronSubnet;
@@ -57,17 +51,33 @@ import org.opendaylight.neutron.spi.NeutronSubnet;
  */
 
 @Path("/subnets")
-public class NeutronSubnetsNorthbound {
-    private static final int HTTP_OK_BOTTOM = 200;
-    private static final int HTTP_OK_TOP = 299;
-    private static final String INTERFACE_NAME = "Subnet CRUD Interface";
-    private static final String UUID_NO_EXIST = "Subnet UUID does not exist.";
-    private static final String UUID_EXISTS = "Subnet UUID already exists.";
-    private static final String NO_PROVIDERS = "No providers registered.  Please try again later";
-    private static final String NO_PROVIDER_LIST = "Couldn't get providers list.  Please try again later";
+public final class NeutronSubnetsNorthbound
+        extends AbstractNeutronNorthbound<NeutronSubnet, NeutronSubnetRequest, INeutronSubnetCRUD> {
+    private static final String RESOURCE_NAME = "Subnet";
 
-    private NeutronSubnet extractFields(NeutronSubnet o, List<String> fields) {
-        return o.extractFields(fields);
+    @Override
+    protected String getResourceName() {
+        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
@@ -78,8 +88,7 @@ public class NeutronSubnetsNorthbound {
     @GET
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackSubnets.class)
-    @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+    @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
             @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
@@ -90,10 +99,10 @@ public class NeutronSubnetsNorthbound {
             @QueryParam("id") String queryID,
             @QueryParam("network_id") String queryNetworkID,
             @QueryParam("name") String queryName,
-            @QueryParam("ip_version") String queryIPVersion,
+            @QueryParam("ip_version") Integer queryIPVersion,
             @QueryParam("cidr") String queryCIDR,
             @QueryParam("gateway_ip") String queryGatewayIP,
-            @QueryParam("enable_dhcp") String queryEnableDHCP,
+            @QueryParam("enable_dhcp") Boolean queryEnableDHCP,
             @QueryParam("tenant_id") String queryTenantID,
             @QueryParam("ipv6_address_mode") String queryIpV6AddressMode,
             @QueryParam("ipv6_ra_mode") String queryIpV6RaMode,
@@ -101,30 +110,26 @@ public class NeutronSubnetsNorthbound {
             @QueryParam("limit") Integer limit,
             @QueryParam("marker") String marker,
             @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
-            // sorting not supported
-            ) {
-        INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
-        if (subnetInterface == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-        List<NeutronSubnet> allNetworks = subnetInterface.getAllSubnets();
-        List<NeutronSubnet> ans = new ArrayList<NeutronSubnet>();
+    // sorting not supported
+    ) {
+        INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface();
+        List<NeutronSubnet> allNetworks = subnetInterface.getAll();
+        List<NeutronSubnet> ans = new ArrayList<>();
         Iterator<NeutronSubnet> i = allNetworks.iterator();
         while (i.hasNext()) {
             NeutronSubnet oSS = i.next();
-            if ((queryID == null || queryID.equals(oSS.getID())) &&
-                    (queryNetworkID == null || queryNetworkID.equals(oSS.getNetworkUUID())) &&
-                    (queryName == null || queryName.equals(oSS.getName())) &&
-                    (queryIPVersion == null || queryIPVersion.equals(oSS.getIpVersion())) &&
-                    (queryCIDR == null || queryCIDR.equals(oSS.getCidr())) &&
-                    (queryGatewayIP == null || queryGatewayIP.equals(oSS.getGatewayIP())) &&
-                    (queryEnableDHCP == null || queryEnableDHCP.equals(oSS.getEnableDHCP())) &&
-                    (queryTenantID == null || queryTenantID.equals(oSS.getTenantID())) &&
-                    (queryIpV6AddressMode == null || queryIpV6AddressMode.equals(oSS.getIpV6AddressMode())) &&
-                    (queryIpV6RaMode == null || queryIpV6RaMode.equals(oSS.getIpV6RaMode()))){
+            if ((queryID == null || queryID.equals(oSS.getID()))
+                    && (queryNetworkID == null || queryNetworkID.equals(oSS.getNetworkUUID()))
+                    && (queryName == null || queryName.equals(oSS.getName()))
+                    && (queryIPVersion == null || queryIPVersion.equals(oSS.getIpVersion()))
+                    && (queryCIDR == null || queryCIDR.equals(oSS.getCidr()))
+                    && (queryGatewayIP == null || queryGatewayIP.equals(oSS.getGatewayIP()))
+                    && (queryEnableDHCP == null || queryEnableDHCP.equals(oSS.getEnableDHCP()))
+                    && (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))
+                    && (queryIpV6AddressMode == null || queryIpV6AddressMode.equals(oSS.getIpV6AddressMode()))
+                    && (queryIpV6RaMode == null || queryIpV6RaMode.equals(oSS.getIpV6RaMode()))) {
                 if (fields.size() > 0) {
-                    ans.add(extractFields(oSS,fields));
+                    ans.add(oSS.extractFields(fields));
                 } else {
                     ans.add(oSS);
                 }
@@ -133,13 +138,12 @@ public class NeutronSubnetsNorthbound {
 
         if (limit != null && ans.size() > 1) {
             // Return a paginated request
-            NeutronSubnetRequest request = (NeutronSubnetRequest) PaginatedRequestFactory.createRequest(limit,
-                    marker, pageReverse, uriInfo, ans, NeutronSubnet.class);
+            NeutronSubnetRequest request = (NeutronSubnetRequest) PaginatedRequestFactory.createRequest(limit, marker,
+                    pageReverse, uriInfo, ans, NeutronSubnet.class);
             return Response.status(HttpURLConnection.HTTP_OK).entity(request).build();
         }
 
-        return Response.status(HttpURLConnection.HTTP_OK).entity(
-                new NeutronSubnetRequest(ans)).build();
+        return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronSubnetRequest(ans)).build();
     }
 
     /**
@@ -149,32 +153,15 @@ public class NeutronSubnetsNorthbound {
     @GET
     @Produces({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackSubnets.class)
-    @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+    @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
             @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
             @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
-    public Response showSubnet(
-            @PathParam("subnetUUID") String subnetUUID,
+    public Response showSubnet(@PathParam("subnetUUID") String subnetUUID,
             // return fields
             @QueryParam("fields") List<String> fields) {
-        INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
-        if (subnetInterface == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-        if (!subnetInterface.subnetExists(subnetUUID)) {
-            throw new ResourceNotFoundException(UUID_NO_EXIST);
-        }
-        if (fields.size() > 0) {
-            NeutronSubnet ans = subnetInterface.getSubnet(subnetUUID);
-            return Response.status(HttpURLConnection.HTTP_OK).entity(
-                    new NeutronSubnetRequest(extractFields(ans, fields))).build();
-        } else {
-            return Response.status(HttpURLConnection.HTTP_OK).entity(
-                    new NeutronSubnetRequest(subnetInterface.getSubnet(subnetUUID))).build();
-        }
+        return show(subnetUUID, fields);
     }
 
     /**
@@ -184,140 +171,26 @@ public class NeutronSubnetsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackSubnets.class)
-    @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
-            @ResponseCode(code = HttpURLConnection.HTTP_BAD_REQUEST, condition = "Bad Request"),
-            @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
-            @ResponseCode(code = HttpURLConnection.HTTP_FORBIDDEN, condition = "Forbidden"),
-            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
-            @ResponseCode(code = HttpURLConnection.HTTP_CONFLICT, condition = "Conflict"),
-            @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
+    @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
     public Response createSubnets(final NeutronSubnetRequest input) {
-        INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);
-        if (subnetInterface == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-        INeutronNetworkCRUD networkInterface = NeutronCRUDInterfaces.getINeutronNetworkCRUD( this);
-        if (networkInterface == null) {
-            throw new ServiceUnavailableException("Network CRUD Interface "
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-        if (input.isSingleton()) {
-            NeutronSubnet singleton = input.getSingleton();
-
-            /*
-             *  Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?)
-             *  the specified network exists, the subnet has a valid network address,
-             *  and that the gateway IP doesn't overlap with the allocation pools
-             *  *then* add the subnet to the cache
-             */
-            if (subnetInterface.subnetExists(singleton.getID())) {
-                throw new BadRequestException(UUID_EXISTS);
-            }
-            if (!networkInterface.networkExists(singleton.getNetworkUUID())) {
-                throw new ResourceNotFoundException("network UUID does not exist.");
-            }
-            if (!singleton.isValidCIDR()) {
-                throw new BadRequestException("invaild CIDR");
-            }
-            if (!singleton.initDefaults()) {
-                throw new InternalServerErrorException("subnet object could not be initialized properly");
-            }
-            if (singleton.gatewayIP_Pool_overlap()) {
-                throw new ResourceConflictException("IP pool overlaps with gateway");
-            }
-            Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
-            if (instances != null) {
-                if (instances.length > 0) {
-                    for (Object instance : instances) {
-                        INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                        int status = service.canCreateSubnet(singleton);
-                        if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                            return Response.status(status).build();
-                        }
-                    }
-                } else {
-                    throw new ServiceUnavailableException(NO_PROVIDERS);
-                }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDER_LIST);
-            }
-            subnetInterface.addSubnet(singleton);
-            if (instances != null) {
-                for (Object instance : instances) {
-                    INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                    service.neutronSubnetCreated(singleton);
-                }
-            }
-        } else {
-            List<NeutronSubnet> bulk = input.getBulk();
-            Iterator<NeutronSubnet> i = bulk.iterator();
-            HashMap<String, NeutronSubnet> testMap = new HashMap<String, NeutronSubnet>();
-            Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
-            while (i.hasNext()) {
-                NeutronSubnet test = i.next();
-
-                /*
-                 *  Verify that the subnet doesn't already exist (Issue: is a deeper check necessary?)
-                 *  the specified network exists, the subnet has a valid network address,
-                 *  and that the gateway IP doesn't overlap with the allocation pools,
-                 *  and that the bulk request doesn't already contain a subnet with this id
-                 */
+        getNeutronInterfaces(true); // Ensure that network service is loaded
+        return create(input);
+    }
 
-                if (!test.initDefaults()) {
-                    throw new InternalServerErrorException("subnet object could not be initialized properly");
-                }
-                if (subnetInterface.subnetExists(test.getID())) {
-                    throw new BadRequestException(UUID_EXISTS);
-                }
-                if (testMap.containsKey(test.getID())) {
-                    throw new BadRequestException(UUID_EXISTS);
-                }
-                testMap.put(test.getID(), test);
-                if (!networkInterface.networkExists(test.getNetworkUUID())) {
-                    throw new ResourceNotFoundException("network UUID does not exist.");
-                }
-                if (!test.isValidCIDR()) {
-                    throw new BadRequestException("Invalid CIDR");
-                }
-                if (test.gatewayIP_Pool_overlap()) {
-                    throw new ResourceConflictException("IP pool overlaps with gateway");
-                }
-                if (instances != null) {
-                    if (instances.length > 0) {
-                        for (Object instance : instances) {
-                            INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                            int status = service.canCreateSubnet(test);
-                            if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                                return Response.status(status).build();
-                            }
-                        }
-                    } else {
-                        throw new ServiceUnavailableException(NO_PROVIDERS);
-                    }
-                } else {
-                    throw new ServiceUnavailableException(NO_PROVIDER_LIST);
-                }
-            }
+    @Override
+    protected void updateDelta(String uuid, NeutronSubnet delta, NeutronSubnet original) {
+        /*
+         * note: what we get appears to not be a delta, but rather a
+         * complete updated object.  So, that needs to be sent down to
+         * folks to check
+         */
 
-            /*
-             * now, each element of the bulk request can be added to the cache
-             */
-            i = bulk.iterator();
-            while (i.hasNext()) {
-                NeutronSubnet test = i.next();
-                subnetInterface.addSubnet(test);
-                if (instances != null) {
-                    for (Object instance : instances) {
-                        INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                        service.neutronSubnetCreated(test);
-                    }
-                }
-            }
-        }
-        return Response.status(HttpURLConnection.HTTP_CREATED).entity(input).build();
+        delta.setID(uuid);
+        delta.setNetworkUUID(original.getNetworkUUID());
+        delta.setTenantID(original.getTenantID());
+        delta.setIpVersion(original.getIpVersion());
+        delta.setCidr(original.getCidr());
     }
 
     /**
@@ -328,74 +201,11 @@ public class NeutronSubnetsNorthbound {
     @Produces({ MediaType.APPLICATION_JSON })
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackSubnets.class)
-    @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
-            @ResponseCode(code = HttpURLConnection.HTTP_BAD_REQUEST, condition = "Bad Request"),
-            @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
-            @ResponseCode(code = HttpURLConnection.HTTP_FORBIDDEN, condition = "Forbidden"),
+    @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
             @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
-            @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
-    public Response updateSubnet(
-            @PathParam("subnetUUID") String subnetUUID, final NeutronSubnetRequest input
-            ) {
-        INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
-        if (subnetInterface == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-
-        /*
-         * verify the subnet exists and there is only one delta provided
-         */
-        if (!subnetInterface.subnetExists(subnetUUID)) {
-            throw new ResourceNotFoundException(UUID_NO_EXIST);
-        }
-        if (!input.isSingleton()) {
-            throw new BadRequestException("Only singleton edit supported");
-        }
-        NeutronSubnet delta = input.getSingleton();
-        NeutronSubnet original = subnetInterface.getSubnet(subnetUUID);
-
-        /*
-         * updates restricted by Neutron
-         */
-        if (delta.getID() != null || delta.getTenantID() != null ||
-                delta.getIpVersion() != null || delta.getCidr() != null ||
-                delta.getAllocationPools() != null) {
-            throw new BadRequestException("Attribute edit blocked by Neutron");
-        }
-
-        Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
-        if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                    int status = service.canUpdateSubnet(delta, original);
-                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                        return Response.status(status).build();
-                    }
-                }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDERS);
-            }
-        } else {
-            throw new ServiceUnavailableException(NO_PROVIDER_LIST);
-        }
-
-        /*
-         * update the object and return it
-         */
-        subnetInterface.updateSubnet(subnetUUID, delta);
-        NeutronSubnet updatedSubnet = subnetInterface.getSubnet(subnetUUID);
-        if (instances != null) {
-            for (Object instance : instances) {
-                INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                service.neutronSubnetUpdated(updatedSubnet);
-            }
-        }
-        return Response.status(HttpURLConnection.HTTP_OK).entity(
-                new NeutronSubnetRequest(subnetInterface.getSubnet(subnetUUID))).build();
+    public Response updateSubnet(@PathParam("subnetUUID") String subnetUUID, final NeutronSubnetRequest input) {
+        return update(subnetUUID, input);
     }
 
     /**
@@ -403,58 +213,10 @@ public class NeutronSubnetsNorthbound {
 
     @Path("{subnetUUID}")
     @DELETE
-    @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"),
-            @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
+    @StatusCodes({ @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"),
             @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
-            @ResponseCode(code = HttpURLConnection.HTTP_CONFLICT, condition = "Conflict"),
-            @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
-    public Response deleteSubnet(
-            @PathParam("subnetUUID") String subnetUUID) {
-        INeutronSubnetCRUD subnetInterface = NeutronCRUDInterfaces.getINeutronSubnetCRUD( this);
-        if (subnetInterface == null) {
-            throw new ServiceUnavailableException("Network CRUD Interface "
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-
-        /*
-         * verify the subnet exists and it isn't currently in use
-         */
-        if (!subnetInterface.subnetExists(subnetUUID)) {
-            throw new ResourceNotFoundException(UUID_NO_EXIST);
-        }
-        if (subnetInterface.subnetInUse(subnetUUID)) {
-            return Response.status(HttpURLConnection.HTTP_CONFLICT).build();
-        }
-        NeutronSubnet singleton = subnetInterface.getSubnet(subnetUUID);
-        Object[] instances = NeutronUtil.getInstances(INeutronSubnetAware.class, this);
-        if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                    int status = service.canDeleteSubnet(singleton);
-                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                        return Response.status(status).build();
-                    }
-                }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDERS);
-            }
-        } else {
-            throw new ServiceUnavailableException(NO_PROVIDER_LIST);
-        }
-
-        /*
-         * remove it and return 204 status
-         */
-        subnetInterface.removeSubnet(subnetUUID);
-        if (instances != null) {
-            for (Object instance : instances) {
-                INeutronSubnetAware service = (INeutronSubnetAware) instance;
-                service.neutronSubnetDeleted(singleton);
-            }
-        }
-        return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();
+    public Response deleteSubnet(@PathParam("subnetUUID") String subnetUUID) {
+        return delete(subnetUUID);
     }
 }