* Update the Flow Path REST API to call the appropriate methods
in class FlowManager.
* Replace ':' with '=" as a separator between
field name and field value in the toString() methods
of the data containers in floodlightcontroller/util/ .
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
index 35367eb..f32d124 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
@@ -1,6 +1,8 @@
package net.floodlightcontroller.flowcache.web;
import net.floodlightcontroller.flowcache.IFlowService;
+import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.FlowPath;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
@@ -12,8 +14,8 @@
protected static Logger log = LoggerFactory.getLogger(AddFlowResource.class);
@Get("json")
- public Boolean retrieve() {
- Boolean result = false;
+ public FlowId retrieve() {
+ FlowId result = new FlowId();
IFlowService flowService =
(IFlowService)getContext().getAttributes().
@@ -26,10 +28,13 @@
// Extract the arguments
String flowPathStr = (String) getRequestAttributes().get("flow");
+ FlowPath flowPath = new FlowPath(flowPathStr);
+
log.debug("Add Flow Path: " + flowPathStr);
- // TODO: Implement it.
- result = true;
+ if (flowService.addFlow(flowPath, result) != true) {
+ result = new FlowId(); // Error: Empty Flow Id
+ }
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
index f323a54..cefad18 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
@@ -1,6 +1,7 @@
package net.floodlightcontroller.flowcache.web;
import net.floodlightcontroller.flowcache.IFlowService;
+import net.floodlightcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
@@ -26,11 +27,11 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- long flowId = HexString.toLong(flowIdStr);
+ FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
+
log.debug("Delete Flow Id: " + flowIdStr);
- // TODO: Implement it.
- result = true;
+ result = flowService.deleteFlow(flowId);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/FlowWebRoutable.java b/src/main/java/net/floodlightcontroller/flowcache/web/FlowWebRoutable.java
index b1188c8..0859397 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/FlowWebRoutable.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/FlowWebRoutable.java
@@ -16,8 +16,8 @@
router.attach("/add/{flow}/json", AddFlowResource.class);
router.attach("/delete/{flow-id}/json", DeleteFlowResource.class);
router.attach("/get/{flow-id}/json", GetFlowByIdResource.class);
- router.attach("/get/{installer-id}/{data-path-endpoints}/json", GetFlowByInstallerIdResource.class);
- router.attach("/getall/{data-path-endpoints}/json", GetAllFlowsByEndpointsResource.class);
+ router.attach("/get/{installer-id}/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", GetFlowByInstallerIdResource.class);
+ router.attach("/getall/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", GetAllFlowsByEndpointsResource.class);
router.attach("/getall/json", GetAllFlowsResource.class);
return router;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
index 211a051..4e96c0c 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
@@ -3,8 +3,13 @@
import java.util.ArrayList;
import net.floodlightcontroller.flowcache.IFlowService;
+import net.floodlightcontroller.util.DataPathEndpoints;
+import net.floodlightcontroller.util.Dpid;
import net.floodlightcontroller.util.FlowPath;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
+import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -27,10 +32,24 @@
}
// Extract the arguments
- String dataPathEndpointsStr = (String) getRequestAttributes().get("data-path-endpoints");
- log.debug("Get All Flows Endpoints: " + dataPathEndpointsStr);
+ String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
+ String srcPortStr = (String) getRequestAttributes().get("src-port");
+ String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
+ String dstPortStr = (String) getRequestAttributes().get("dst-port");
- // TODO: Implement it.
+ log.debug("Get All Flows Endpoints: " + srcDpidStr + "--" +
+ srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
+
+ Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Port srcPort = new Port(Short.parseShort(srcPortStr));
+ Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Port dstPort = new Port(Short.parseShort(dstPortStr));
+ SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
+ SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
+ DataPathEndpoints dataPathEndpoints =
+ new DataPathEndpoints(srcSwitchPort, dstSwitchPort);
+
+ flowService.getAllFlows(dataPathEndpoints, result);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
index 9d95651..5bf3a50 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
@@ -29,7 +29,7 @@
// Extract the arguments
log.debug("Get All Flows Endpoints");
- // TODO: Implement it.
+ flowService.getAllFlows(result);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
index 99f880c..2863c79 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
@@ -1,6 +1,7 @@
package net.floodlightcontroller.flowcache.web;
import net.floodlightcontroller.flowcache.IFlowService;
+import net.floodlightcontroller.util.FlowId;
import net.floodlightcontroller.util.FlowPath;
import org.openflow.util.HexString;
@@ -27,10 +28,11 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- long flowId = HexString.toLong(flowIdStr);
+ FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
+
log.debug("Get Flow Id: " + flowIdStr);
- // TODO: Implement it.
+ flowService.getFlow(flowId, result);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
index 32d20cc..6b5f7f4 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.flowcache.web;
import net.floodlightcontroller.flowcache.IFlowService;
+import net.floodlightcontroller.util.CallerId;
+import net.floodlightcontroller.util.DataPathEndpoints;
+import net.floodlightcontroller.util.Dpid;
import net.floodlightcontroller.util.FlowPath;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
+import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -25,11 +31,27 @@
}
// Extract the arguments
- String installerIdStr = (String) getRequestAttributes().get("installer-id");
- String dataPathEndpointsStr = (String) getRequestAttributes().get("data-path-endpoints");
- log.debug("Get Flow Installer: " + installerIdStr + " Endpoints: " + dataPathEndpointsStr);
+ String installerIdStr = (String) getRequestAttributes().get("installer-id");
+ String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
+ String srcPortStr = (String) getRequestAttributes().get("src-port");
+ String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
+ String dstPortStr = (String) getRequestAttributes().get("dst-port");
- // TODO: Implement it.
+ log.debug("Get Flow By Installer: " + installerIdStr + " Endpoints: " +
+ srcDpidStr + "--" + srcPortStr + "--" +
+ dstDpidStr + "--" + dstPortStr);
+
+ CallerId installerId = new CallerId(installerIdStr);
+ Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Port srcPort = new Port(Short.parseShort(srcPortStr));
+ Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Port dstPort = new Port(Short.parseShort(dstPortStr));
+ SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
+ SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
+ DataPathEndpoints dataPathEndpoints =
+ new DataPathEndpoints(srcSwitchPort, dstSwitchPort);
+
+ flowService.getFlow(installerId, dataPathEndpoints, result);
return result;
}