From 171c283d513bc07c4422a37120b203b4bcc53e43 Mon Sep 17 00:00:00 2001 From: Prasanth Pallamreddy Date: Tue, 10 Sep 2013 11:17:33 -0700 Subject: [PATCH] Bug #65 - Fix inconsistencies in the NB REST APIs 1) PUT is used to create resources (when resource path is known to client and the action is idempotent). 2) Use plural resource name when listing contents. 3) Rename service names (flow -> flowprogrammer, host -> hosttracker, subnet -> subnetservice) as they conflict with resource names. Change-Id: I7171ec725b83799ec3686460ab7aa23c7df56c9b Signed-off-by: Prasanth Pallamreddy --- opendaylight/northbound/commons/pom.xml | 2 + .../northbound/commons/types/StringList.java | 38 +++++++++ .../northbound/flowprogrammer/enunciate.xml | 2 +- .../northbound/flowprogrammer/pom.xml | 2 +- .../northbound/FlowProgrammerNorthbound.java | 34 ++++---- opendaylight/northbound/hosttracker/pom.xml | 2 +- .../northbound/HostTrackerNorthbound.java | 27 +++--- .../integrationtest/NorthboundIT.java | 84 +++++++++---------- .../northbound/StaticRoutingNorthbound.java | 18 ++-- .../northbound/StatisticsNorthbound.java | 6 +- opendaylight/northbound/subnets/enunciate.xml | 4 +- opendaylight/northbound/subnets/pom.xml | 2 +- .../subnets/northbound/SubnetsNorthbound.java | 49 +++++++---- .../northbound/switchmanager/enunciate.xml | 2 +- opendaylight/northbound/switchmanager/pom.xml | 2 +- .../northbound/SwitchNorthbound.java | 35 ++++---- .../northbound/topology/enunciate.xml | 2 +- .../northbound/TopologyNorthboundJAXRS.java | 29 ++++--- 18 files changed, 196 insertions(+), 144 deletions(-) create mode 100644 opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java diff --git a/opendaylight/northbound/commons/pom.xml b/opendaylight/northbound/commons/pom.xml index 6031ddea35..b88375ffdc 100644 --- a/opendaylight/northbound/commons/pom.xml +++ b/opendaylight/northbound/commons/pom.xml @@ -28,12 +28,14 @@ org.opendaylight.controller.northbound.commons.exception, + org.opendaylight.controller.northbound.commons.types, org.opendaylight.controller.northbound.commons.utils, org.opendaylight.controller.northbound.commons javax.ws.rs, javax.ws.rs.core, + javax.xml.bind.annotation, org.opendaylight.controller.sal.utils, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.containermanager, diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java new file mode 100644 index 0000000000..62d1608098 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/types/StringList.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013 Cisco Systems, Inc. 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, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.northbound.commons.types; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents a list of string values + */ +@XmlRootElement(name = "list") +@XmlAccessorType(XmlAccessType.NONE) +public class StringList { + @XmlElement(name = "item") + private List list; + + public StringList() { + } + + public StringList(List list) { + this.list = list; + } + + public List getList() { + return list; + } + +} diff --git a/opendaylight/northbound/flowprogrammer/enunciate.xml b/opendaylight/northbound/flowprogrammer/enunciate.xml index 90bf6de1d6..3ac676907b 100644 --- a/opendaylight/northbound/flowprogrammer/enunciate.xml +++ b/opendaylight/northbound/flowprogrammer/enunciate.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> - + diff --git a/opendaylight/northbound/flowprogrammer/pom.xml b/opendaylight/northbound/flowprogrammer/pom.xml index 7aef0652fe..960c835dc8 100644 --- a/opendaylight/northbound/flowprogrammer/pom.xml +++ b/opendaylight/northbound/flowprogrammer/pom.xml @@ -60,7 +60,7 @@ - /controller/nb/v2/flow + /controller/nb/v2/flowprogrammer ${project.basedir}/src/main/resources/META-INF diff --git a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java index 257fbbda67..ea3f748dcc 100644 --- a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java +++ b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java @@ -48,7 +48,7 @@ import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.switchmanager.ISwitchManager; /** - * Flow Configuration Northbound API + * Flow Configuration Northbound API provides capabilities to program flows. * *
*
@@ -56,11 +56,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; * Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
- * HTTPS Authentication is disabled by default. Administrator can enable it in - * tomcat-server.xml after adding a proper keystore / SSL certificate from a - * trusted authority.
- * More info : - * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * HTTPS Authentication is disabled by default. * */ @Path("/") @@ -158,7 +154,7 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default + * http://localhost:8080/controller/nb/v2/flowprogrammer/default * * Response in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -223,7 +219,7 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01 + * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01 * * Response in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -296,7 +292,7 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1 + * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1 * * Response in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -320,7 +316,7 @@ public class FlowProgrammerNorthbound { * * */ - @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}") + @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(FlowConfig.class) @@ -357,7 +353,8 @@ public class FlowProgrammerNorthbound { } /** - * Add a flow configuration + * Add a flow configuration. If a flow by the given name already + * exists, this method will respond with a non-successful status response. * * @param containerName * Name of the Container (Eg. 'default') @@ -376,7 +373,7 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1 + * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1 * * Request in XML: * <flowConfig> @@ -400,7 +397,7 @@ public class FlowProgrammerNorthbound { * */ - @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}") + @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}") @PUT @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @@ -476,16 +473,16 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1 + * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1 * * */ - @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}") + @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}") @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ - @ResponseCode(code = 200, condition = "Flow Config deleted successfully"), + @ResponseCode(code = 204, condition = "Flow Config deleted successfully"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The Container Name or Node-id or Flow Name passed is not found"), @ResponseCode(code = 406, condition = "Failed to delete Flow config due to invalid operation. Failure details included in HTTP Error response"), @@ -523,6 +520,7 @@ public class FlowProgrammerNorthbound { Status status = frm.removeStaticFlow(name, node); if (status.isSuccess()) { NorthboundUtils.auditlog("Flow", username, "removed", name, containerName); + return Response.noContent().build(); } return NorthboundUtils.getResponse(status); } @@ -545,11 +543,11 @@ public class FlowProgrammerNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/flow/default/node/OF/00:00:00:00:00:00:00:01/static-flow/flow1 + * http://localhost:8080/controller/nb/v2/flowprogrammer/default/node/OF/00:00:00:00:00:00:00:01/staticFlow/flow1 * * */ - @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}") + @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}") @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ diff --git a/opendaylight/northbound/hosttracker/pom.xml b/opendaylight/northbound/hosttracker/pom.xml index 3757ea1f36..d39ae17c90 100644 --- a/opendaylight/northbound/hosttracker/pom.xml +++ b/opendaylight/northbound/hosttracker/pom.xml @@ -61,7 +61,7 @@ org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs - /controller/nb/v2/host + /controller/nb/v2/hosttracker ${project.basedir}/src/main/resources/META-INF diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java index f0bdf5d891..836bfa2d60 100644 --- a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java @@ -62,11 +62,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; * Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
- * HTTPS Authentication is disabled by default. Administrator can enable it in - * tomcat-server.xml after adding a proper keystore / SSL certificate from a - * trusted authority.
- * More info : - * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * HTTPS Authentication is disabled by default. * */ @@ -137,7 +133,7 @@ public class HostTrackerNorthbound { * * RequestURL: * - * http://localhost:8080/controller/nb/v2/host/default + * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/active * * Response in XML * @@ -192,7 +188,7 @@ public class HostTrackerNorthbound { * } * */ - @Path("/{containerName}") + @Path("/{containerName}/hosts/active") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(Hosts.class) @@ -224,7 +220,7 @@ public class HostTrackerNorthbound { * * RequestURL: * - * http://localhost:8080/controller/nb/v2/host/default/inactive + * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/inactive * * Response in XML * @@ -279,7 +275,7 @@ public class HostTrackerNorthbound { * } * */ - @Path("/{containerName}/inactive") + @Path("/{containerName}/hosts/inactive") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(Hosts.class) @@ -312,7 +308,7 @@ public class HostTrackerNorthbound { * * RequestURL: * - * http://localhost:8080/controller/nb/v2/host/default/1.1.1.1 + * http://localhost:8080/controller/nb/v2/hosttracker/default/address/1.1.1.1 * * Response in XML * @@ -341,7 +337,7 @@ public class HostTrackerNorthbound { * } * */ - @Path("/{containerName}/{networkAddress}") + @Path("/{containerName}/address/{networkAddress}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(HostConfig.class) @@ -374,7 +370,8 @@ public class HostTrackerNorthbound { } /** - * Add a Static Host configuration + * Add a Static Host configuration. If a host by the given address already + * exists, this method will respond with a non-successful status response. * * @param containerName * Name of the Container. The Container name for the base @@ -391,7 +388,7 @@ public class HostTrackerNorthbound { * * RequestURL: * - * http://localhost:8080/controller/nb/v2/host/default/1.1.1.1 + * http://localhost:8080/controller/nb/v2/hosttracker/default/address/1.1.1.1 * * Request in XML * @@ -421,7 +418,7 @@ public class HostTrackerNorthbound { * */ - @Path("/{containerName}/{networkAddress}") + @Path("/{containerName}/address/{networkAddress}") @PUT @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @@ -477,7 +474,7 @@ public class HostTrackerNorthbound { * @return Response as dictated by the HTTP Response code. */ - @Path("/{containerName}/{networkAddress}") + @Path("/{containerName}/address/{networkAddress}") @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ diff --git a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java index 27a50c015d..38336c1dd8 100644 --- a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java +++ b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java @@ -293,7 +293,7 @@ public class NorthboundIT { @Test public void testSubnetsNorthbound() throws JSONException { System.out.println("Starting Subnets JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnet/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnetservice/"; String name1 = "testSubnet1"; String subnet1 = "1.1.1.1/24"; @@ -313,7 +313,7 @@ public class NorthboundIT { nodePortsJson3_1.append(nodePortsJson3).append(",").append(nodePortsJson2); // Test GET subnets in default container - String result = getJsonResult(baseURL + "default/subnet/all"); + String result = getJsonResult(baseURL + "default/subnets"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); JSONArray subnetConfigs = json.getJSONArray("subnetConfig"); @@ -326,7 +326,7 @@ public class NorthboundIT { // Test POST subnet1 JSONObject jo = new JSONObject().put("name", name1).put("subnet", subnet1); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name1, "POST", jo.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name1, "PUT", jo.toString()); Assert.assertTrue(httpResponseCode == 201); // Test GET subnet1 @@ -340,31 +340,31 @@ public class NorthboundIT { // Test POST subnet2 JSONObject jo2 = new JSONObject().put("name", name2).put("subnet", subnet2); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name2, "POST", jo2.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name2, "PUT", jo2.toString()); Assert.assertEquals(201, httpResponseCode.intValue()); // Test POST nodePorts jo2.append("nodePorts", nodePortsJson2); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name2 + "/node-ports", "POST", jo2.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name2 + "/nodePorts", "PUT", jo2.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test POST subnet3 JSONObject jo3 = new JSONObject().put("name", name3).put("subnet", subnet3); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name3, "POST", jo3.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name3, "PUT", jo3.toString()); Assert.assertEquals(201, httpResponseCode.intValue()); // Test POST nodePorts jo3.append("nodePorts", nodePortsJson3); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "POST", jo3.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "PUT", jo3.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test PUT nodePorts jo3.remove("nodePorts"); jo3.append("nodePorts", nodePortsJson3_1); - result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "PUT", jo3.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "POST", jo3.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test GET all subnets in default container - result = getJsonResult(baseURL + "default/subnet/all"); + result = getJsonResult(baseURL + "default/subnets"); jt = new JSONTokener(result); json = new JSONObject(jt); JSONArray subnetConfigArray = json.getJSONArray("subnetConfig"); @@ -419,7 +419,7 @@ public class NorthboundIT { String nextHop2 = "1.1.1.1"; // Test GET static routes in default container, expecting no results - String result = getJsonResult(baseURL + "default"); + String result = getJsonResult(baseURL + "default/routes"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); JSONArray staticRoutes = json.getJSONArray("staticRoute"); @@ -428,15 +428,15 @@ public class NorthboundIT { // Test insert static route String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\"" + prefix1 + "\", \"nextHop\":\"" + nextHop1 + "\"}"; - result = getJsonResult(baseURL + "default/route/" + name1, "POST", requestBody); + result = getJsonResult(baseURL + "default/route/" + name1, "PUT", requestBody); Assert.assertEquals(201, httpResponseCode.intValue()); requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2 + "\", \"nextHop\":\"" + nextHop2 + "\"}"; - result = getJsonResult(baseURL + "default/route/" + name2, "POST", requestBody); + result = getJsonResult(baseURL + "default/route/" + name2, "PUT", requestBody); Assert.assertEquals(201, httpResponseCode.intValue()); // Test Get all static routes - result = getJsonResult(baseURL + "default"); + result = getJsonResult(baseURL + "default/routes"); jt = new JSONTokener(result); json = new JSONObject(jt); JSONArray staticRouteArray = json.getJSONArray("staticRoute"); @@ -475,9 +475,9 @@ public class NorthboundIT { // Test delete static route result = getJsonResult(baseURL + "default/route/" + name1, "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); - result = getJsonResult(baseURL + "default"); + result = getJsonResult(baseURL + "default/routes"); jt = new JSONTokener(result); json = new JSONObject(jt); @@ -490,7 +490,7 @@ public class NorthboundIT { @Test public void testSwitchManager() throws JSONException { System.out.println("Starting SwitchManager JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switchmanager/default/"; // define Node/NodeConnector attributes for test int nodeId_1 = 51966; @@ -599,7 +599,7 @@ public class NorthboundIT { // Delete state property of nodeconnector1 result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1 + "/STUB/" + nodeConnectorId_1 + "/property/state", "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); @@ -613,7 +613,7 @@ public class NorthboundIT { // Delete capabilities property of nodeconnector2 result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2 + "/STUB/" + nodeConnectorId_2 + "/property/capabilities", "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); result = getJsonResult(baseURL + "node/STUB/" + nodeId_2); jt = new JSONTokener(result); @@ -834,19 +834,19 @@ public class NorthboundIT { @Test public void testFlowProgrammer() throws JSONException { System.out.println("Starting FlowProgrammer JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flowprogrammer/default/"; // Attempt to get a flow that doesn't exit. Should return 404 // status. - String result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET"); + String result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "GET"); Assert.assertTrue(result.equals("404")); // test add flow1 String fc = "{\"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); // test get returns flow that was added. - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET"); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "GET"); // check that result came out fine. Assert.assertTrue(httpResponseCode == 200); JSONTokener jt = new JSONTokener(result); @@ -860,17 +860,17 @@ public class NorthboundIT { Assert.assertEquals(node.getString("id"), "51966"); // test adding same flow again fails due to repeat name..return 409 // code - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc); Assert.assertTrue(result.equals("409")); fc = "{\"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "PUT", fc); // test should return 409 for error due to same flow being added. Assert.assertTrue(result.equals("409")); // add second flow that's different fc = "{\"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); // check that request returns both flows given node. @@ -892,10 +892,10 @@ public class NorthboundIT { Assert.assertTrue(count == 2); // delete a flow, check that it's no longer in list. - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "DELETE"); - Assert.assertTrue(httpResponseCode == 200); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "DELETE"); + Assert.assertTrue(httpResponseCode == 204); - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "GET"); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "GET"); Assert.assertTrue(result.equals("404")); } @@ -970,7 +970,7 @@ public class NorthboundIT { Integer nodeConnectorId_2 = 34; String vlan_2 = "123"; - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/hosttracker/default"; // test PUT method: addHost() JSONObject fc_json = new JSONObject(); @@ -983,7 +983,7 @@ public class NorthboundIT { fc_json.put("staticHost", "true"); fc_json.put("networkAddress", networkAddress_1); - String result = getJsonResult(baseURL + "/" + networkAddress_1, "PUT", fc_json.toString()); + String result = getJsonResult(baseURL + "/address/" + networkAddress_1, "PUT", fc_json.toString()); Assert.assertTrue(httpResponseCode == 201); fc_json = new JSONObject(); @@ -996,7 +996,7 @@ public class NorthboundIT { fc_json.put("staticHost", "true"); fc_json.put("networkAddress", networkAddress_2); - result = getJsonResult(baseURL + "/" + networkAddress_2 , "PUT", fc_json.toString()); + result = getJsonResult(baseURL + "/address/" + networkAddress_2 , "PUT", fc_json.toString()); Assert.assertTrue(httpResponseCode == 201); // define variables for decoding returned strings @@ -1005,7 +1005,7 @@ public class NorthboundIT { // the two hosts should be in inactive host DB // test GET method: getInactiveHosts() - result = getJsonResult(baseURL + "/inactive", "GET"); + result = getJsonResult(baseURL + "/hosts/inactive", "GET"); Assert.assertTrue(httpResponseCode == 200); JSONTokener jt = new JSONTokener(result); @@ -1041,7 +1041,7 @@ public class NorthboundIT { } // test GET method: getActiveHosts() - no host expected - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1063,7 +1063,7 @@ public class NorthboundIT { // verify the host shows up in active host DB - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1073,7 +1073,7 @@ public class NorthboundIT { // test GET method for getHostDetails() - result = getJsonResult(baseURL + "/" + networkAddress_1, "GET"); + result = getJsonResult(baseURL + "/address/" + networkAddress_1, "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1091,13 +1091,13 @@ public class NorthboundIT { // test DELETE method for deleteFlow() - result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE"); + result = getJsonResult(baseURL + "/address/" + networkAddress_1, "DELETE"); Assert.assertTrue(httpResponseCode == 204); // verify host_1 removed from active host DB // test GET method: getActiveHosts() - no host expected - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1246,11 +1246,11 @@ public class NorthboundIT { .put("dstNodeConnector", nodeConnectorType_2 + "|" + nodeConnectorId_2 + "@" + nodeType_2 + "|" + nodeId_2); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "/user-link", "PUT", jo.toString()); + result = getJsonResult(baseURL + "/userLink/userLink_1", "PUT", jo.toString()); Assert.assertTrue(httpResponseCode == 201); // === test GET method for getUserLinks() - result = getJsonResult(baseURL + "/user-link", "GET"); + result = getJsonResult(baseURL + "/userLinks", "GET"); Assert.assertTrue(httpResponseCode == 200); if (debugMsg) { System.out.println("result:" + result); @@ -1295,12 +1295,12 @@ public class NorthboundIT { // === test DELETE method for deleteUserLink() String userName = "userLink_1"; - result = getJsonResult(baseURL + "/user-link/" + userName, "DELETE"); - Assert.assertTrue(httpResponseCode == 200); + result = getJsonResult(baseURL + "/userLink/" + userName, "DELETE"); + Assert.assertTrue(httpResponseCode == 204); // execute another getUserLinks() request to verify that userLink_1 is // removed - result = getJsonResult(baseURL + "/user-link", "GET"); + result = getJsonResult(baseURL + "/userLinks", "GET"); Assert.assertTrue(httpResponseCode == 200); if (debugMsg) { System.out.println("result:" + result); diff --git a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java index 65e68aab7d..07f125dae3 100644 --- a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java +++ b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java @@ -16,6 +16,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; +import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -113,7 +114,7 @@ public class StaticRoutingNorthbound { * Example: * * Request URL: - * GET http://localhost:8080/controller/nb/v2/staticroute/default + * GET http://localhost:8080/controller/nb/v2/staticroute/default/routes * * Response in XML: * <list> @@ -129,7 +130,7 @@ public class StaticRoutingNorthbound { * * */ - @Path("/{containerName}") + @Path("/{containerName}/routes") @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(StaticRoutes.class) @@ -204,7 +205,8 @@ public class StaticRoutingNorthbound { /** * - * Add a new Static Route + * Add a new Static Route. If a route by the given name already exists, this + * method will return a non-successful status response. * * @param containerName Name of the Container. The Container name for the base controller is "default". * @param route Name of the Static Route configuration @@ -214,7 +216,7 @@ public class StaticRoutingNorthbound { * Example: * * Request URL: - * POST http://localhost:8080/controller/nb/v2/staticroute/default/route/route-1 + * PUT http://localhost:8080/controller/nb/v2/staticroute/default/route/route-1 * * Request payload in JSON: * {"name":"route-1","prefix":"10.10.1.0/24","nextHop":"1.1.1.1"} @@ -222,7 +224,7 @@ public class StaticRoutingNorthbound { * */ @Path("/{containerName}/route/{route}") - @POST + @PUT @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes( { @ResponseCode(code = 201, condition = "Created Static Route successfully"), @@ -284,7 +286,7 @@ public class StaticRoutingNorthbound { @Path("/{containerName}/route/{route}") @DELETE @StatusCodes( { - @ResponseCode(code = 200, condition = "Operation successful"), + @ResponseCode(code = 204, condition = "Static route removed successfully"), @ResponseCode(code = 404, condition = "Container Name or Configuration Name not found"), @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active") }) public Response removeStaticRoute( @@ -311,9 +313,9 @@ public class StaticRoutingNorthbound { Status status = staticRouting.removeStaticRoute(route); if (status.isSuccess()) { NorthboundUtils.auditlog("Static Route", username, "removed", route, containerName); - return Response.ok().build(); + return Response.noContent().build(); } - throw new ResourceNotFoundException(status.getDescription()); + return NorthboundUtils.getResponse(status); } private void handleDefaultDisabled(String containerName) { diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java index a07f6435fe..a47bfa70b7 100644 --- a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java +++ b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java @@ -50,11 +50,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; * Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
- * HTTPS Authentication is disabled by default. Administrator can enable it in - * tomcat-server.xml after adding a proper keystore / SSL certificate from a - * trusted authority.
- * More info : - * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * HTTPS Authentication is disabled by default. * */ @Path("/") diff --git a/opendaylight/northbound/subnets/enunciate.xml b/opendaylight/northbound/subnets/enunciate.xml index 5ff13ffe80..abdc40a174 100644 --- a/opendaylight/northbound/subnets/enunciate.xml +++ b/opendaylight/northbound/subnets/enunciate.xml @@ -3,10 +3,10 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> - + - + diff --git a/opendaylight/northbound/subnets/pom.xml b/opendaylight/northbound/subnets/pom.xml index 9feb95fce0..4715664132 100644 --- a/opendaylight/northbound/subnets/pom.xml +++ b/opendaylight/northbound/subnets/pom.xml @@ -76,7 +76,7 @@ - /controller/nb/v2/subnet + /controller/nb/v2/subnetservice ${project.basedir}/src/main/resources/META-INF diff --git a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java index 50024fd739..b16c8f9ea6 100644 --- a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java +++ b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.subnets.northbound; import java.util.HashSet; + import java.util.List; import java.util.Set; @@ -45,6 +46,19 @@ import org.opendaylight.controller.switchmanager.SubnetConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * This class provides REST APIs to manage subnets. + * + *
+ *
+ * Authentication scheme : HTTP Basic
+ * Authentication realm : opendaylight
+ * Transport : HTTP and HTTPS
+ *
+ * HTTPS Authentication is disabled by default. + * + */ + @Path("/") public class SubnetsNorthbound { protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class); @@ -100,7 +114,7 @@ public class SubnetsNorthbound { *
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/all
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnets
      *
      * Response in XML:
      * <subnetConfig>
@@ -131,7 +145,7 @@ public class SubnetsNorthbound {
      * }
      * 
*/ - @Path("/{containerName}/subnet/all") + @Path("/{containerName}/subnets") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @@ -165,7 +179,7 @@ public class SubnetsNorthbound { *
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * Response in XML:
      * <subnetConfig>
@@ -213,7 +227,8 @@ public class SubnetsNorthbound {
     }
 
     /**
-     * Add a subnet to a container
+     * Add a subnet to a container. If a subnet by the given name already exists
+     * this method will return a non-successful response.
      *
      * @param containerName
      *            name of the container to which subnet needs to be added
@@ -227,7 +242,7 @@ public class SubnetsNorthbound {
      *         
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * Request XML:
      *  <subnetConfig>
@@ -244,7 +259,7 @@ public class SubnetsNorthbound {
      */
 
     @Path("/{containerName}/subnet/{subnetName}")
-    @POST
+    @PUT
     @StatusCodes({ @ResponseCode(code = 201, condition = "Subnet created successfully"),
             @ResponseCode(code = 400, condition = "Invalid data passed"),
             @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
@@ -297,7 +312,7 @@ public class SubnetsNorthbound {
      *
      *         
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1
      *
      * 
*/ @@ -345,7 +360,7 @@ public class SubnetsNorthbound { *
      * Example:
      *
-     * Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     * Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      *  Request in XML:
      *  <subnetConfig>
@@ -364,8 +379,8 @@ public class SubnetsNorthbound {
      * }
      * 
*/ - @Path("/{containerName}/subnet/{subnetName}/node-ports") - @PUT + @Path("/{containerName}/subnet/{subnetName}/nodePorts") + @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @ResponseCode(code = 200, condition = "Ports replaced successfully"), @@ -442,7 +457,7 @@ public class SubnetsNorthbound { } /** - * Add ports to a subnet in the container + * Add ports to a subnet in the container. * * @param containerName * name of the container that has the subnet to which node ports @@ -455,7 +470,7 @@ public class SubnetsNorthbound { * *
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      * Request XML:
      *  <subnetConfig>
@@ -475,8 +490,8 @@ public class SubnetsNorthbound {
      *
      * 
*/ - @Path("/{containerName}/subnet/{subnetName}/node-ports") - @POST + @Path("/{containerName}/subnet/{subnetName}/nodePorts") + @PUT @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @ResponseCode(code = 200, condition = "Added node ports to subnet successfully"), @@ -557,7 +572,7 @@ public class SubnetsNorthbound { * *
      * Example:
-     *            Request URL: http://localhost:8080/controller/nb/v2/subnet/default/subnet/subnet1/node-ports
+     *            Request URL: http://localhost:8080/controller/nb/v2/subnetservice/default/subnet/subnet1/nodePorts
      *
      * Request XML:
      *  <subnetConfig>
@@ -573,7 +588,7 @@ public class SubnetsNorthbound {
      *
      * 
*/ - @Path("/{containerName}/subnet/{subnetName}/node-ports") + @Path("/{containerName}/subnet/{subnetName}/nodePorts") @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @@ -635,7 +650,7 @@ public class SubnetsNorthbound { } } if (successful) { - return Response.status(Response.Status.NO_CONTENT).build(); + return Response.noContent().build(); } throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString()); } diff --git a/opendaylight/northbound/switchmanager/enunciate.xml b/opendaylight/northbound/switchmanager/enunciate.xml index 8a8bfdb029..6f2dd4d0e7 100644 --- a/opendaylight/northbound/switchmanager/enunciate.xml +++ b/opendaylight/northbound/switchmanager/enunciate.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> - + diff --git a/opendaylight/northbound/switchmanager/pom.xml b/opendaylight/northbound/switchmanager/pom.xml index 965075a271..6b320b1992 100644 --- a/opendaylight/northbound/switchmanager/pom.xml +++ b/opendaylight/northbound/switchmanager/pom.xml @@ -60,7 +60,7 @@ org.codehaus.jackson.jaxrs, !org.codehaus.enunciate.jaxrs - /controller/nb/v2/switch + /controller/nb/v2/switchmanager ${project.basedir}/src/main/resources/META-INF diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java index 1edd945dfa..f4d302b2d1 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java @@ -119,7 +119,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/nodes + * http://localhost:8080/controller/nb/v2/switchmanager/default/nodes * * Response in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -194,7 +194,7 @@ public class SwitchNorthbound { List res = new ArrayList(); Set nodes = switchManager.getNodes(); if (nodes == null) { - return null; + return new Nodes(res); } for (Node node : nodes) { @@ -212,7 +212,9 @@ public class SwitchNorthbound { } /** - * Add a Description, Tier and Forwarding mode property to a node. + * Add a Description, Tier and Forwarding mode property to a node. This + * method returns a non-successful response if a node by that name already + * exists. * * @param containerName * Name of the Container (Eg. 'default') @@ -237,7 +239,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:03/property/description/Switch3 + * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:03/property/description/Switch3 * *
*/ @@ -316,7 +318,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:03/property/forwarding + * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:03/property/forwarding * *
*/ @@ -325,7 +327,7 @@ public class SwitchNorthbound { @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ - @ResponseCode(code = 200, condition = "Operation successful"), + @ResponseCode(code = 204, condition = "Property removed successfully"), @ResponseCode(code = 400, condition = "The nodeId or configuration is invalid"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"), @@ -369,7 +371,8 @@ public class SwitchNorthbound { SwitchConfig newSwitchConfig = new SwitchConfig(node.toString(), nodeProperties); status = switchManager.updateNodeConfig(newSwitchConfig); if(status.isSuccess()){ - NorthboundUtils.auditlog("Static Route", username, "updated", nodeId, containerName); + NorthboundUtils.auditlog("Node Property", username, "removed", propertyName + " from " + nodeId, containerName); + return Response.noContent().build(); } } } @@ -401,7 +404,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/node/OF/00:00:00:00:00:00:00:01 + * http://localhost:8080/controller/nb/v2/switchmanager/default/node/OF/00:00:00:00:00:00:00:01 * * Response in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -489,7 +492,9 @@ public class SwitchNorthbound { } /** - * Add Bandwidth property to a node connector + * Add node-connector property to a node connector. This method returns a + * non-successful response if a node connector by the given name already + * exists. * * @param containerName * Name of the Container (Eg. 'default') @@ -521,7 +526,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth/1 + * http://localhost:8080/controller/nb/v2/switchmanager/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth/1 * * */ @@ -610,7 +615,7 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth + * http://localhost:8080/controller/nb/v2/switchmanager/default/nodeconnector/OF/00:00:00:00:00:00:00:01/OF/2/property/bandwidth * * */ @@ -619,7 +624,7 @@ public class SwitchNorthbound { @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ - @ResponseCode(code = 200, condition = "Operation successful"), + @ResponseCode(code = 204, condition = "Property removed successfully"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"), @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") }) @@ -657,7 +662,7 @@ public class SwitchNorthbound { Status ret = switchManager.removeNodeConnectorProp(nc, propertyName); if (ret.isSuccess()) { NorthboundUtils.auditlog("Node Connector Property", username, "removed", nc + " from " + nodeConnectorId, containerName); - return Response.ok().build(); + return Response.noContent().build(); } throw new ResourceNotFoundException(ret.getDescription()); } @@ -674,11 +679,11 @@ public class SwitchNorthbound { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/switch/default/switch-config + * http://localhost:8080/controller/nb/v2/switchmanager/default/save * * */ - @Path("/{containerName}/switch-config") + @Path("/{containerName}/save") @POST @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ diff --git a/opendaylight/northbound/topology/enunciate.xml b/opendaylight/northbound/topology/enunciate.xml index b7c451c8e6..fed0f68e30 100644 --- a/opendaylight/northbound/topology/enunciate.xml +++ b/opendaylight/northbound/topology/enunciate.xml @@ -7,6 +7,6 @@ - + diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java index 508ffafe6f..ff26bfd21f 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java @@ -52,11 +52,7 @@ import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; * Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
- * HTTPS Authentication is disabled by default. Administrator can enable it in - * tomcat-server.xml after adding a proper keystore / SSL certificate from a - * trusted authority.
- * More info : - * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * HTTPS Authentication is disabled by default. */ @Path("/") @@ -81,7 +77,7 @@ public class TopologyNorthboundJAXRS { * The container for which we want to retrieve the topology (Eg. * 'default') * - * @return A List of EdgeProps each EdgeProp represent an Edge of the grap + * @return A List of EdgeProps each EdgeProp represent an Edge of the graph * with the corresponding properties attached to it. * *
@@ -222,7 +218,7 @@ public class TopologyNorthboundJAXRS {
      * Example:
      *
      * RequestURL:
-     * http://localhost:8080/controller/nb/v2/topology/default/user-link
+     * http://localhost:8080/controller/nb/v2/topology/default/userLinks
      *
      * Response in XML:
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
@@ -241,7 +237,7 @@ public class TopologyNorthboundJAXRS {
      *
      * 
*/ - @Path("/{containerName}/user-link") + @Path("/{containerName}/userLinks") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(TopologyUserLinks.class) @@ -278,6 +274,8 @@ public class TopologyNorthboundJAXRS { * * @param containerName * Name of the Container (Eg. 'default') + * @param name + * Name of the user link * @param TopologyUserLinkConfig * in JSON or XML format * @return Response as dictated by the HTTP Response Status code @@ -287,7 +285,7 @@ public class TopologyNorthboundJAXRS { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/topology/default/user-link + * http://localhost:8080/controller/nb/v2/topology/default/userLink/link1 * * Request in XML: * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> @@ -303,7 +301,7 @@ public class TopologyNorthboundJAXRS { * * */ - @Path("/{containerName}/user-link") + @Path("/{containerName}/userLink/{name}") @PUT @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @@ -315,6 +313,7 @@ public class TopologyNorthboundJAXRS { @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") }) public Response addUserLink( @PathParam(value = "containerName") String containerName, + @PathParam(value = "name") String name, @TypeHint(TopologyUserLinkConfig.class) TopologyUserLinkConfig userLinkConfig) { if (!NorthboundUtils.isAuthorized( @@ -352,16 +351,16 @@ public class TopologyNorthboundJAXRS { * Example: * * RequestURL: - * http://localhost:8080/controller/nb/v2/topology/default/user-link/config1 + * http://localhost:8080/controller/nb/v2/topology/default/userLink/config1 * * */ - @Path("/{containerName}/user-link/{name}") + @Path("/{containerName}/userLink/{name}") @DELETE @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ - @ResponseCode(code = 200, condition = "Operation successful"), + @ResponseCode(code = 204, condition = "User link removed successfully"), @ResponseCode(code = 404, condition = "The Container Name or Link Configuration Name was not found"), @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") }) public Response deleteUserLink( @@ -384,8 +383,8 @@ public class TopologyNorthboundJAXRS { Status ret = topologyManager.deleteUserLink(name); if (ret.isSuccess()) { NorthboundUtils.auditlog("User Link", username, "removed", name, containerName); - return Response.ok().build(); + return Response.noContent().build(); } - throw new ResourceNotFoundException(ret.getDescription()); + return NorthboundUtils.getResponse(ret); } } -- 2.36.6