<instructions>
<Export-Package>
org.opendaylight.controller.northbound.commons.exception,
+ org.opendaylight.controller.northbound.commons.types,
org.opendaylight.controller.northbound.commons.utils,
org.opendaylight.controller.northbound.commons
</Export-Package>
<Import-Package>
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,
--- /dev/null
+/**
+ * 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<String> list;
+
+ public StringList() {
+ }
+
+ public StringList(List<String> list) {
+ this.list = list;
+ }
+
+ public List<String> getList() {
+ return list;
+ }
+
+}
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
<services>
- <rest defaultRestSubcontext="/controller/nb/v2/flow"/>
+ <rest defaultRestSubcontext="/controller/nb/v2/flowprogrammer"/>
</services>
<modules>
</Import-Package>
<Export-Package>
</Export-Package>
- <Web-ContextPath>/controller/nb/v2/flow</Web-ContextPath>
+ <Web-ContextPath>/controller/nb/v2/flowprogrammer</Web-ContextPath>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
</configuration>
import org.opendaylight.controller.switchmanager.ISwitchManager;
/**
- * Flow Configuration Northbound API
+ * Flow Configuration Northbound API provides capabilities to program flows.
*
* <br>
* <br>
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * 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.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
*
*/
@Path("/")
* 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"?>
* 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"?>
* 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"?>
*
* </pre>
*/
- @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)
}
/**
- * 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')
* 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>
* </pre>
*/
- @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+ @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
* 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
*
* </pre>
*/
- @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"),
Status status = frm.removeStaticFlow(name, node);
if (status.isSuccess()) {
NorthboundUtils.auditlog("Flow", username, "removed", name, containerName);
+ return Response.noContent().build();
}
return NorthboundUtils.getResponse(status);
}
* 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
*
* </pre>
*/
- @Path("/{containerName}/node/{nodeType}/{nodeId}/static-flow/{name}")
+ @Path("/{containerName}/node/{nodeType}/{nodeId}/staticFlow/{name}")
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
org.codehaus.jackson.jaxrs,
!org.codehaus.enunciate.jaxrs
</Import-Package>
- <Web-ContextPath>/controller/nb/v2/host</Web-ContextPath>
+ <Web-ContextPath>/controller/nb/v2/hosttracker</Web-ContextPath>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
</configuration>
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * 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.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
*
*/
*
* RequestURL:
*
- * http://localhost:8080/controller/nb/v2/host/default
+ * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/active
*
* Response in XML
*
* }
* </pre>
*/
- @Path("/{containerName}")
+ @Path("/{containerName}/hosts/active")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
*
* RequestURL:
*
- * http://localhost:8080/controller/nb/v2/host/default/inactive
+ * http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/inactive
*
* Response in XML
*
* }
* </pre>
*/
- @Path("/{containerName}/inactive")
+ @Path("/{containerName}/hosts/inactive")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
*
* 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
*
* }
* </pre>
*/
- @Path("/{containerName}/{networkAddress}")
+ @Path("/{containerName}/address/{networkAddress}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(HostConfig.class)
}
/**
- * 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
*
* 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
*
* </pre>
*/
- @Path("/{containerName}/{networkAddress}")
+ @Path("/{containerName}/address/{networkAddress}")
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
* @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({
@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";
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");
// 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
// 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");
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");
// 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");
// 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);
@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;
// 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);
// 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);
@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);
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.
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"));
}
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();
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();
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
// 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);
}
// 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);
// 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);
// 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);
// 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);
.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);
// === 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);
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;
* 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>
*
* </pre>
*/
- @Path("/{containerName}")
+ @Path("/{containerName}/routes")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(StaticRoutes.class)
/**
*
- * 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
* 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"}
* </pre>
*/
@Path("/{containerName}/route/{route}")
- @POST
+ @PUT
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes( {
@ResponseCode(code = 201, condition = "Created Static Route successfully"),
@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(
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) {
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * 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.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
*
*/
@Path("/")
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
<services>
- <rest defaultRestSubcontext="/controller/nb/v2/subnet"/>
+ <rest defaultRestSubcontext="/controller/nb/v2/subnetservice"/>
</services>
<modules>
- <docs docsDir="rest" title="REST API" includeExampleXml="true" includeExampleJson="true"/>
+ <docs docsDir="rest" title="Subnet Service REST API" includeExampleXml="true" includeExampleJson="true"/>
</modules>
</enunciate>
</Import-Package>
<Export-Package>
</Export-Package>
- <Web-ContextPath>/controller/nb/v2/subnet</Web-ContextPath>
+ <Web-ContextPath>/controller/nb/v2/subnetservice</Web-ContextPath>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
</configuration>
package org.opendaylight.controller.subnets.northbound;
import java.util.HashSet;
+
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * This class provides REST APIs to manage subnets.
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default.
+ *
+ */
+
@Path("/")
public class SubnetsNorthbound {
protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class);
* <pre>
* 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>
* }
* </pre>
*/
- @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"),
* <pre>
* 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>
}
/**
- * 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
* <pre>
* 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>
*/
@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"),
*
* <pre>
* 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
*
* </pre>
*/
* <pre>
* 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>
* }
* </pre>
*/
- @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"),
}
/**
- * 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
*
* <pre>
* 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>
*
* </pre>
*/
- @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"),
*
* <pre>
* 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>
*
* </pre>
*/
- @Path("/{containerName}/subnet/{subnetName}/node-ports")
+ @Path("/{containerName}/subnet/{subnetName}/nodePorts")
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
}
}
if (successful) {
- return Response.status(Response.Status.NO_CONTENT).build();
+ return Response.noContent().build();
}
throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString());
}
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
<services>
- <rest defaultRestSubcontext="/controller/nb/v2/switch"/>
+ <rest defaultRestSubcontext="/controller/nb/v2/switchmanager"/>
</services>
<modules>
org.codehaus.jackson.jaxrs,
!org.codehaus.enunciate.jaxrs
</Import-Package>
- <Web-ContextPath>/controller/nb/v2/switch</Web-ContextPath>
+ <Web-ContextPath>/controller/nb/v2/switchmanager</Web-ContextPath>
</instructions>
<manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
</configuration>
* 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"?>
List<NodeProperties> res = new ArrayList<NodeProperties>();
Set<Node> nodes = switchManager.getNodes();
if (nodes == null) {
- return null;
+ return new Nodes(res);
}
for (Node node : nodes) {
}
/**
- * 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')
* 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
*
* </pre>
*/
* 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
*
* </pre>
*/
@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"),
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();
}
}
}
* 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"?>
}
/**
- * 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')
* 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
*
* </pre>
*/
* 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
*
* </pre>
*/
@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") })
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());
}
* Example:
*
* RequestURL:
- * http://localhost:8080/controller/nb/v2/switch/default/switch-config
+ * http://localhost:8080/controller/nb/v2/switchmanager/default/save
*
* </pre>
*/
- @Path("/{containerName}/switch-config")
+ @Path("/{containerName}/save")
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
</services>
<modules>
- <docs docsDir="rest" title="REST API" includeExampleXml="true" includeExampleJson="true"/>
+ <docs docsDir="rest" title="Topology REST API" includeExampleXml="true" includeExampleJson="true"/>
</modules>
</enunciate>
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * 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.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
*/
@Path("/")
* 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.
*
* <pre>
* 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"?>
*
* </pre>
*/
- @Path("/{containerName}/user-link")
+ @Path("/{containerName}/userLinks")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(TopologyUserLinks.class)
*
* @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
* 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"?>
*
* </pre>
*/
- @Path("/{containerName}/user-link")
+ @Path("/{containerName}/userLink/{name}")
@PUT
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@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(
* Example:
*
* RequestURL:
- * http://localhost:8080/controller/nb/v2/topology/default/user-link/config1
+ * http://localhost:8080/controller/nb/v2/topology/default/userLink/config1
*
* </pre>
*/
- @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(
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);
}
}