From: Madhu Venugopal Date: Thu, 7 Nov 2013 15:04:38 +0000 (-0800) Subject: Added DELETE support for Bridge and Port resources X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~465^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=36a0cd2902fcfe51b54d3d7453b3b8c4d8d7810c Added DELETE support for Bridge and Port resources Change-Id: Ica167c669115706c5b5b916134c7ec4c168c9253 Signed-off-by: Madhu Venugopal --- diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java index 08a7149d7a..805f5be296 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/java/org/opendaylight/controller/networkconfig/bridgedomain/northbound/BridgeDomainNorthbound.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.Map; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -82,6 +83,9 @@ public class BridgeDomainNorthbound { * @param nodeId Node Identifier of the node with the management session. * @param bridgeName Name / Identifier for a bridge to be created. * @param bridgeConfigs Additional Bridge Configurations. + * It takes in complex structures under the ConfigConstants.CUSTOM key. + * The use-cases are documented under wiki.opendaylight.org project pages: + * https://wiki.opendaylight.org/view/OVSDB_Integration:Mininet_OVSDB_Tutorial */ @Path("/bridge/{nodeType}/{nodeId}/{bridgeName}") @@ -116,6 +120,53 @@ public class BridgeDomainNorthbound { throw new ResourceNotFoundException(status.getDescription()); } + + /** + * Remove a Bridge. + *
+    *
+    * Example :
+    *
+    * Request :
+    * DELETE
+    * http://localhost:8080/controller/nb/v2/networkconfig/bridgedomain/bridge/STUB/mgmt1/bridge1
+    *
+    *
+ * @param nodeType Node Type of the node with the management session. + * @param nodeId Node Identifier of the node with the management session. + * @param bridgeName Name / Identifier for a bridge to be deleted. + */ + + @Path("/bridge/{nodeType}/{nodeId}/{bridgeName}") + @DELETE + @StatusCodes( { @ResponseCode(code = 200, condition = "Bridge deleted successfully"), + @ResponseCode(code = 404, condition = "Could not delete Bridge"), + @ResponseCode(code = 412, condition = "Failed to delete Bridge due to an exception"), + @ResponseCode(code = 503, condition = "Bridge Domain Configuration Service not available")} ) + + public Response deleteBridge( + @PathParam(value = "nodeType") String nodeType, + @PathParam(value = "nodeId") String nodeId, + @PathParam(value = "bridgeName") String name) { + + IBridgeDomainConfigService configurationService = getConfigurationService(); + if (configurationService == null) { + throw new ServiceUnavailableException("IBridgeDomainConfigService not available."); + } + + Node node = Node.fromString(nodeType, nodeId); + Status status = null; + try { + status = configurationService.deleteBridgeDomain(node, name); + if (status.getCode().equals(StatusCode.SUCCESS)) { + return Response.status(Response.Status.OK).build(); + } + } catch (Throwable t) { + return Response.status(Response.Status.PRECONDITION_FAILED).build(); + } + throw new ResourceNotFoundException(status.getDescription()); + } + /** * Add a Port to a Bridge *
@@ -131,6 +182,9 @@ public class BridgeDomainNorthbound {
     * @param bridgeName Name / Identifier of the bridge to which a Port is being added.
     * @param portName Name / Identifier of a Port that is being added to a bridge.
     * @param portConfigs Additional Port Configurations.
+    *        It takes in complex structures under the ConfigConstants.CUSTOM key.
+    *        The use-cases are documented under wiki.opendaylight.org project pages :
+    *        https://wiki.opendaylight.org/view/OVSDB_Integration:Mininet_OVSDB_Tutorial
     */
 
    @Path("/port/{nodeType}/{nodeId}/{bridgeName}/{portName}")
@@ -167,6 +221,55 @@ public class BridgeDomainNorthbound {
        throw new ResourceNotFoundException(status.getDescription());
    }
 
+   /**
+    * Remove a Port from a Bridge
+    * 
+    *
+    * Example :
+    *
+    * Request :
+    * DELETE
+    * http://localhost:8080/controller/nb/v2/networkconfig/bridgedomain/port/STUB/mgmt1/bridge1/port1
+    *
+    *
+ * @param nodeType Node Type of the node with the management session. + * @param nodeId Node Identifier of the node with the management session. + * @param bridgeName Name / Identifier of the bridge to which a Port is being added. + * @param portName Name / Identifier of a Port that is being deleted from a bridge. + */ + + @Path("/port/{nodeType}/{nodeId}/{bridgeName}/{portName}") + @DELETE + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @StatusCodes( { @ResponseCode(code = 200, condition = "Port deleted successfully"), + @ResponseCode(code = 404, condition = "Could not delete Port to the Bridge"), + @ResponseCode(code = 412, condition = "Failed to delete Port due to an exception"), + @ResponseCode(code = 503, condition = "Bridge Domain Configuration Service not available")} ) + + public Response deletePort( + @PathParam(value = "nodeType") String nodeType, + @PathParam(value = "nodeId") String nodeId, + @PathParam(value = "bridgeName") String bridge, + @PathParam(value = "portName") String port) { + + IBridgeDomainConfigService configurationService = getConfigurationService(); + if (configurationService == null) { + throw new ServiceUnavailableException("IBridgeDomainConfigService not available."); + } + + Node node = Node.fromString(nodeType, nodeId); + Status status = null; + try { + status = configurationService.deletePort(node, bridge, port); + if (status.getCode().equals(StatusCode.SUCCESS)) { + return Response.status(Response.Status.OK).build(); + } + } catch (Throwable t) { + return Response.status(Response.Status.PRECONDITION_FAILED).build(); + } + throw new ResourceNotFoundException(status.getDescription()); + } + private Map buildConfig(Map rawConfigs) { if (rawConfigs == null) return null; Map configs = new HashMap(); diff --git a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/resources/WEB-INF/web.xml b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/resources/WEB-INF/web.xml index bb871a1a77..455fbdd1c7 100644 --- a/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/resources/WEB-INF/web.xml +++ b/opendaylight/northbound/networkconfiguration/bridgedomain/src/main/resources/WEB-INF/web.xml @@ -26,7 +26,7 @@ cors.allowed.methods - GET,POST,HEAD,OPTIONS,PUT + GET,POST,DELETE,HEAD,OPTIONS,PUT cors.allowed.headers