* 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;
}
diff --git a/src/main/java/net/floodlightcontroller/util/DataPath.java b/src/main/java/net/floodlightcontroller/util/DataPath.java
index 34fc1f2..ad6cdb8 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPath.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPath.java
@@ -76,18 +76,18 @@
* Convert the data path to a string.
*
* The string has the following form:
- * [src:01:01:01:01:01:01:01:01/1111 flowEntry:<entry1> flowEntry:<entry2> flowEntry:<entry3> dst:02:02:02:02:02:02:02:02/2222]
+ * [src=01:01:01:01:01:01:01:01/1111 flowEntry=<entry1> flowEntry=<entry2> flowEntry=<entry3> dst=02:02:02:02:02:02:02:02/2222]
*
* @return the data path as a string.
*/
@Override
public String toString() {
- String ret = "[src:" + this.srcPort.toString();
+ String ret = "[src=" + this.srcPort.toString();
for (FlowEntry fe : flowEntries) {
- ret += " flowEntry:" + fe.toString();
+ ret += " flowEntry=" + fe.toString();
}
- ret += " dst:" + this.dstPort.toString() + "]";
+ ret += " dst=" + this.dstPort.toString() + "]";
return ret;
}
diff --git a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
index 9dd7dbb..92cf2dd 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
@@ -67,14 +67,14 @@
* Convert the data path endpoints to a string.
*
* The string has the following form:
- * [src:01:01:01:01:01:01:01:01/1111 dst:02:02:02:02:02:02:02:02/2222]
+ * [src=01:01:01:01:01:01:01:01/1111 dst=02:02:02:02:02:02:02:02/2222]
*
* @return the data path endpoints as a string.
*/
@Override
public String toString() {
- String ret = "[src:" + this.srcPort.toString() +
- " dst:" + this.dstPort.toString() + "]";
+ String ret = "[src=" + this.srcPort.toString() +
+ " dst=" + this.dstPort.toString() + "]";
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntry.java b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
index d45d87f..42ec935 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntry.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
@@ -219,22 +219,22 @@
* Convert the flow entry to a string.
*
* The string has the following form:
- * [flowEntryId:XXX flowEntryMatch:XXX flowEntryActions:XXX dpid:XXX
- * inPort:XXX outPort:XXX flowEntryUserState:XXX flowEntrySwitchState:XXX
- * flowEntryErrorState:XXX]
+ * [flowEntryId=XXX flowEntryMatch=XXX flowEntryActions=XXX dpid=XXX
+ * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX
+ * flowEntryErrorState=XXX]
* @return the flow entry as a string.
*/
@Override
public String toString() {
- String ret = "[flowEntryId:" + this.flowEntryId.toString();
- ret += " flowEntryMatch:" + this.flowEntryMatch.toString();
- ret += " flowEntryActions:" + this.flowEntryActions.toString();
- ret += " dpid:" + this.dpid.toString();
- ret += " inPort:" + this.inPort.toString();
- ret += " outPort:" + this.outPort.toString();
- ret += " flowEntryUserState:" + this.flowEntryUserState;
- ret += " flowEntrySwitchState:" + this.flowEntrySwitchState;
- ret += " flowEntryErrorState:" + this.flowEntryErrorState.toString();
+ String ret = "[flowEntryId=" + this.flowEntryId.toString();
+ ret += " flowEntryMatch=" + this.flowEntryMatch.toString();
+ ret += " flowEntryActions=" + this.flowEntryActions.toString();
+ ret += " dpid=" + this.dpid.toString();
+ ret += " inPort=" + this.inPort.toString();
+ ret += " outPort=" + this.outPort.toString();
+ ret += " flowEntryUserState=" + this.flowEntryUserState;
+ ret += " flowEntrySwitchState=" + this.flowEntrySwitchState;
+ ret += " flowEntryErrorState=" + this.flowEntryErrorState.toString();
ret += "]";
return ret;
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java b/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
index 0dfae09..f9ca8ba 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
@@ -61,13 +61,13 @@
* Convert the error type and code to a string.
*
* The string has the following form:
- * [type:1 code:2]
+ * [type=1 code=2]
*
* @return the error type and code as a string.
*/
@Override
public String toString() {
- String ret = "[type:" + this.type + " code:" + code + "]";
+ String ret = "[type=" + this.type + " code=" + code + "]";
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
index ddc65d0..0e3775e 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
@@ -100,16 +100,16 @@
* Convert the matching filter to a string.
*
* The string has the following form:
- * [srcMac:XXX dstMac:XXX srcIPv4Net:XXX dstIPv4Net:XXX]
+ * [srcMac=XXX dstMac=XXX srcIPv4Net=XXX dstIPv4Net=XXX]
*
* @return the matching filter as a string.
*/
@Override
public String toString() {
- String ret = "[srcMac: " + this.srcMac.toString();
- ret += " dstMac:" + this.dstMac.toString();
- ret += " srcIPv4Net:" + this.srcIPv4Net.toString();
- ret += " dstIPv4Net:" + this.dstIPv4Net.toString();
+ String ret = "[srcMac=" + this.srcMac.toString();
+ ret += " dstMac=" + this.dstMac.toString();
+ ret += " srcIPv4Net=" + this.srcIPv4Net.toString();
+ ret += " dstIPv4Net=" + this.dstIPv4Net.toString();
ret += "]";
return ret;
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowPath.java b/src/main/java/net/floodlightcontroller/util/FlowPath.java
index b67fabe..f91bb4a 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowPath.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowPath.java
@@ -24,6 +24,13 @@
}
/**
+ * Constructor from a string.
+ */
+ public FlowPath(String str) {
+ // TODO: Implement it.
+ }
+
+ /**
* Get the flow path Flow ID.
*
* @return the flow path Flow ID.
@@ -74,13 +81,17 @@
/**
* Convert the flow path to a string.
*
+ * The string has the following form:
+ * [flowId=XXX installerId=XXX dataPath=XXX]
+ *
* @return the flow path as a string.
*/
@Override
public String toString() {
- String ret = "[flowId:" + this.flowId.toString();
- ret += " installerId:" + this.installerId.toString();
- ret += " dataPath:" + this.dataPath.toString();
+ String ret = "[flowId=" + this.flowId.toString();
+ ret += " installerId=" + this.installerId.toString();
+ ret += " dataPath=" + this.dataPath.toString();
+ ret += "]";
return ret;
}
}