Added new field FlowPath.flowPathUserState
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
index dadda71..6f13080 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
@@ -206,6 +206,13 @@
@Property("flow_path_type")
public void setFlowPathType(String flowPathType);
+ @JsonProperty("flowPathUserState")
+ @Property("user_state")
+ public String getFlowPathUserState();
+
+ @Property("user_state")
+ public void setFlowPathUserState(String userState);
+
@JsonProperty("flowPathFlags")
@Property("flow_path_flags")
public Long getFlowPathFlags();
@@ -358,13 +365,6 @@
@JsonIgnore
@Property("state")
public String getState();
-
- @JsonIgnore
- @Property("user_state")
- public String getUserState();
-
- @Property("user_state")
- public void setUserState(String userState);
}
public interface IFlowEntry extends IBaseObject {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index 5336520..5bc35d2 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -78,6 +78,7 @@
// Set the Flow attributes:
// - flowPath.installerId()
// - flowPath.flowPathType()
+ // - flowPath.flowPathUserState()
// - flowPath.flowPathFlags()
// - flowPath.dataPath().srcPort()
// - flowPath.dataPath().dstPort()
@@ -96,6 +97,7 @@
//
flowObj.setInstallerId(flowPath.installerId().toString());
flowObj.setFlowPathType(flowPath.flowPathType().toString());
+ flowObj.setFlowPathUserState(flowPath.flowPathUserState().toString());
flowObj.setFlowPathFlags(flowPath.flowPathFlags().flags());
flowObj.setSrcSwitch(flowPath.dataPath().srcPort().dpid().toString());
flowObj.setSrcPort(flowPath.dataPath().srcPort().port().value());
@@ -140,9 +142,9 @@
flowObj.setDataPathSummary(flowPath.dataPath().dataPathSummary());
if (found)
- flowObj.setUserState("FE_USER_MODIFY");
+ flowObj.setFlowPathUserState("FP_USER_MODIFY");
else
- flowObj.setUserState("FE_USER_ADD");
+ flowObj.setFlowPathUserState("FP_USER_ADD");
// Flow edges:
// HeadFE
@@ -421,7 +423,7 @@
// Find and mark for deletion all Flow Entries,
// and the Flow itself.
//
- flowObj.setUserState("FE_USER_DELETE");
+ flowObj.setFlowPathUserState("FP_USER_DELETE");
Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
boolean empty = true; // TODO: an ugly hack
for (IFlowEntry flowEntryObj : flowEntries) {
@@ -746,6 +748,7 @@
String flowIdStr = flowObj.getFlowId();
String installerIdStr = flowObj.getInstallerId();
String flowPathType = flowObj.getFlowPathType();
+ String flowPathUserState = flowObj.getFlowPathUserState();
Long flowPathFlags = flowObj.getFlowPathFlags();
String srcSwitchStr = flowObj.getSrcSwitch();
Short srcPortShort = flowObj.getSrcPort();
@@ -755,6 +758,7 @@
if ((flowIdStr == null) ||
(installerIdStr == null) ||
(flowPathType == null) ||
+ (flowPathUserState == null) ||
(flowPathFlags == null) ||
(srcSwitchStr == null) ||
(srcPortShort == null) ||
@@ -768,6 +772,7 @@
flowPath.setFlowId(new FlowId(flowIdStr));
flowPath.setInstallerId(new CallerId(installerIdStr));
flowPath.setFlowPathType(FlowPathType.valueOf(flowPathType));
+ flowPath.setFlowPathUserState(FlowPathUserState.valueOf(flowPathUserState));
flowPath.setFlowPathFlags(new FlowPathFlags(flowPathFlags));
flowPath.dataPath().srcPort().setDpid(new Dpid(srcSwitchStr));
flowPath.dataPath().srcPort().setPort(new Port(srcPortShort));
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index 31a6bf4..fba680d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -273,9 +273,9 @@
// Test whether we need to complete the Flow cleanup,
// if the Flow has been deleted by the user.
//
- String flowUserState = flowPathObj.getUserState();
- if ((flowUserState != null)
- && flowUserState.equals("FE_USER_DELETE")) {
+ String flowPathUserStateStr = flowPathObj.getFlowPathUserState();
+ if ((flowPathUserStateStr != null)
+ && flowPathUserStateStr.equals("FP_USER_DELETE")) {
Iterable<IFlowEntry> flowEntries = flowPathObj.getFlowEntries();
final boolean empty = !flowEntries.iterator().hasNext();
if (empty)
@@ -302,6 +302,7 @@
SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
FlowPathType flowPathType = FlowPathType.valueOf(flowPathTypeStr);
+ FlowPathUserState flowPathUserState = FlowPathUserState.valueOf(flowPathUserStateStr);
FlowPathFlags flowPathFlags = new FlowPathFlags(flowPathFlagsLong);
counterMyFlowPaths++;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java
index 7892483..2683e86 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java
@@ -13,6 +13,7 @@
private FlowId flowId; // The Flow ID
private CallerId installerId; // The Caller ID of the path installer
private FlowPathType flowPathType; // The Flow Path type
+ private FlowPathUserState flowPathUserState; // The Flow Path User state
private FlowPathFlags flowPathFlags; // The Flow Path flags
private DataPath dataPath; // The data path
private FlowEntryMatch flowEntryMatch; // Common Flow Entry Match for all
@@ -25,6 +26,7 @@
*/
public FlowPath() {
flowPathType = FlowPathType.FP_TYPE_UNKNOWN;
+ flowPathUserState = FlowPathUserState.FP_USER_UNKNOWN;
flowPathFlags = new FlowPathFlags();
dataPath = new DataPath();
flowEntryActions = new FlowEntryActions();
@@ -38,6 +40,7 @@
this.setFlowId(new FlowId(flowObj.getFlowId()));
this.setInstallerId(new CallerId(flowObj.getInstallerId()));
this.setFlowPathType(FlowPathType.valueOf(flowObj.getFlowPathType()));
+ this.setFlowPathUserState(FlowPathUserState.valueOf(flowObj.getFlowPathUserState()));
this.setFlowPathFlags(new FlowPathFlags(flowObj.getFlowPathFlags()));
this.dataPath().srcPort().setDpid(new Dpid(flowObj.getSrcSwitch()));
this.dataPath().srcPort().setPort(new Port(flowObj.getSrcPort()));
@@ -241,6 +244,24 @@
}
/**
+ * Get the flow path user state.
+ *
+ * @return the flow path user state.
+ */
+ @JsonProperty("flowPathUserState")
+ public FlowPathUserState flowPathUserState() { return flowPathUserState; }
+
+ /**
+ * Set the flow path user state.
+ *
+ * @param flowPathUserState the flow path user state to set.
+ */
+ @JsonProperty("flowPathUserState")
+ public void setFlowPathUserState(FlowPathUserState flowPathUserState) {
+ this.flowPathUserState = flowPathUserState;
+ }
+
+ /**
* Get the flow path flags.
*
* @return the flow path flags.
@@ -320,8 +341,9 @@
* Convert the flow path to a string.
*
* The string has the following form:
- * [flowId=XXX installerId=XXX flowPathType = XXX flowPathFlags=XXX
- * dataPath=XXX flowEntryMatch=XXX flowEntryActions=XXX]
+ * [flowId=XXX installerId=XXX flowPathType = XXX flowPathUserState = XXX
+ * flowPathFlags=XXX dataPath=XXX flowEntryMatch=XXX
+ * flowEntryActions=XXX]
*
* @return the flow path as a string.
*/
@@ -330,6 +352,7 @@
String ret = "[flowId=" + this.flowId.toString();
ret += " installerId=" + this.installerId.toString();
ret += " flowPathType=" + this.flowPathType;
+ ret += " flowPathUserState=" + this.flowPathUserState;
ret += " flowPathFlags=" + this.flowPathFlags.toString();
if (dataPath != null)
ret += " dataPath=" + this.dataPath.toString();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowPathUserState.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPathUserState.java
new file mode 100644
index 0000000..96b6345
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPathUserState.java
@@ -0,0 +1,11 @@
+package net.onrc.onos.ofcontroller.util;
+
+/**
+ * The Flow Path state as set by the user (via the ONOS API).
+ */
+public enum FlowPathUserState {
+ FP_USER_UNKNOWN, // Initialization value: state unknown
+ FP_USER_ADD, // Flow path that is added
+ FP_USER_MODIFY, // Flow path that is modified
+ FP_USER_DELETE // Flow path that is deleted
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/KryoFactory.java
index 45a43bf..eeb307f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/KryoFactory.java
@@ -114,6 +114,7 @@
kryo.register(FlowPath.class);
kryo.register(FlowPathFlags.class);
kryo.register(FlowPathType.class);
+ kryo.register(FlowPathUserState.class);
kryo.register(IPv4.class);
kryo.register(IPv4Net.class);
kryo.register(IPv6.class);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
index db39153..9a1e34a 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
@@ -122,6 +122,24 @@
/**
* Desc:
+ * Test method for get and set FlowPathUserState method.
+ * Condition:
+ * N/A
+ * Expect:
+ * 1. Should set the Flow Path User State.
+ * 2. Should get the Flow Path User State.
+ */
+ @Test
+ public void testSetGetFlowPathUserState() {
+ String flowId = "xx";
+ String flowPathUserState = "FP_USER_ADD";
+ flowPath.setFlowId(flowId);
+ flowPath.setFlowPathUserState(flowPathUserState);
+ assertEquals(flowPath.getFlowPathUserState(), flowPathUserState);
+ }
+
+ /**
+ * Desc:
* Test method for get and set FlowPathFlags method.
* Condition:
* N/A
@@ -475,24 +493,6 @@
/**
* Desc:
- * Test method for set and get UserState.
- * Condition:
- * N/A
- * Expect:
- * 1. Should set UserState.
- * 2. Should get UserState.
- */
- @Test
- public void testSetGetUserState() {
- String flowId = "xx";
- String userStatus = "Good";
- flowPath.setFlowId(flowId);
- flowPath.setUserState(userStatus);
- assertEquals(flowPath.getUserState(), userStatus);
- }
-
- /**
- * Desc:
* Test method for get Switches.
* Condition:
* N/A
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
index cf6501a..dfe6ccf 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
@@ -416,8 +416,9 @@
public static class TestFlowPath implements IFlowPath {
private String state,type,flowId,installerId,srcSw,dstSw;
private String flowPathType;
+ private String flowPathUserState;
private Long flowPathFlags;
- private String dataPathSummary,userState;
+ private String dataPathSummary;
private Short srcPort,dstPort;
private String matchSrcMac,matchDstMac;
private Short matchEthernetFrameType;
@@ -433,8 +434,9 @@
private String stateToUpdate,typeToUpdate,flowIdToUpdate,installerIdToUpdate,srcSwToUpdate,dstSwToUpdate;
private String flowPathTypeToUpdate;
+ private String flowPathUserStateToUpdate;
private Long flowPathFlagsToUpdate;
- private String dataPathSummaryToUpdate,userStateToUpdate;
+ private String dataPathSummaryToUpdate;
private Short srcPortToUpdate,dstPortToUpdate;
private String matchSrcMacToUpdate,matchDstMacToUpdate;
private Short matchEthernetFrameTypeToUpdate;
@@ -472,11 +474,11 @@
if(flowIdToUpdate != null) { flowId = flowIdToUpdate; }
if(installerIdToUpdate != null) { installerId = installerIdToUpdate; }
if(flowPathTypeToUpdate != null) { flowPathType = flowPathTypeToUpdate; }
+ if(flowPathUserStateToUpdate != null) { flowPathUserState = flowPathUserStateToUpdate; }
if(flowPathFlagsToUpdate != null) { flowPathFlags = flowPathFlagsToUpdate; }
if(srcSwToUpdate != null) { srcSw = srcSwToUpdate; }
if(dstSwToUpdate != null) { dstSw = dstSwToUpdate; }
if(dataPathSummaryToUpdate != null) { dataPathSummary = dataPathSummaryToUpdate; }
- if(userStateToUpdate != null) { userState = userStateToUpdate; }
if(srcPortToUpdate != null) { srcPort = srcPortToUpdate; }
if(dstPortToUpdate != null) { dstPort = dstPortToUpdate; }
if(matchSrcMacToUpdate != null) { matchSrcMac = matchSrcMacToUpdate; }
@@ -503,8 +505,9 @@
stateToUpdate = typeToUpdate = flowIdToUpdate = installerIdToUpdate = null;
flowPathTypeToUpdate = null;
+ flowPathUserStateToUpdate = null;
flowPathFlagsToUpdate = null;
- srcSwToUpdate = dstSwToUpdate = dataPathSummaryToUpdate = userStateToUpdate = null;
+ srcSwToUpdate = dstSwToUpdate = dataPathSummaryToUpdate = null;
srcPortToUpdate = dstPortToUpdate = null;
matchSrcMacToUpdate = matchDstMacToUpdate = null;
matchEthernetFrameTypeToUpdate = null;
@@ -522,11 +525,11 @@
public void setFlowIdForTest(String flowId) { this.flowId = flowId; }
public void setInstallerIdForTest(String installerId) { this.installerId = installerId; }
public void setFlowPathTypeForTest(String flowPathType) { this.flowPathType = flowPathType; }
+ public void setFlowPathUserStateForTest(String flowPathUserState) { this.flowPathUserState = flowPathUserState; }
public void setFlowPathFlagsForTest(Long flowPathFlags) { this.flowPathFlags = flowPathFlags; }
public void setSrcSwForTest(String srcSw) { this.srcSw = srcSw; }
public void setDstSwForTest(String dstSw) { this.dstSw = dstSw; }
public void setDataPathSummaryForTest(String dataPathSummary) { this.dataPathSummary = dataPathSummary; }
- public void setUserStateForTest(String userState) { this.userState = userState; }
public void setSrcPortForTest(Short srcPort) { this.srcPort = srcPort; }
public void setDstPortForTest(Short dstPort) { this.dstPort = dstPort; }
public void setMatchSrcMacForTest(String matchSrcMac) { this.matchSrcMac = matchSrcMac; }
@@ -581,6 +584,12 @@
public void setFlowPathType(String flowPathType) { flowPathTypeToUpdate = flowPathType; }
@Override
+ public String getFlowPathUserState() { return flowPathUserState; }
+
+ @Override
+ public void setFlowPathUserState(String flowPathUserState) { flowPathUserStateToUpdate = flowPathUserState; }
+
+ @Override
public Long getFlowPathFlags() { return flowPathFlags; }
@Override
@@ -717,12 +726,6 @@
@Override
public Iterable<ISwitchObject> getSwitches() { return switches; }
-
- @Override
- public String getUserState() { return userState; }
-
- @Override
- public void setUserState(String userState) { userStateToUpdate = userState; }
}
public static class TestFlowEntry implements IFlowEntry {
diff --git a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
index 3e61119..7fd0f67 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
@@ -88,12 +88,14 @@
}
private IFlowPath createIFlowPathMock(long flowId, String installerID,
- String flowPathType, long flowPathFlags,
- long srcDpid, int srcPort, long dstDpid, int dstPort) {
+ String flowPathType, String flowPathUserState,
+ long flowPathFlags, long srcDpid, int srcPort,
+ long dstDpid, int dstPort) {
IFlowPath iFlowPath = createNiceMock(IFlowPath.class);
expect(iFlowPath.getFlowId()).andReturn(new FlowId(flowId).toString()).anyTimes();
expect(iFlowPath.getInstallerId()).andReturn(installerID).anyTimes();
expect(iFlowPath.getFlowPathType()).andReturn(flowPathType).anyTimes();
+ expect(iFlowPath.getFlowPathUserState()).andReturn(flowPathUserState).anyTimes();
expect(iFlowPath.getFlowPathFlags()).andReturn(new Long(flowPathFlags)).anyTimes();
expect(iFlowPath.getSrcSwitch()).andReturn(new Dpid(srcDpid).toString()).anyTimes();
expect(iFlowPath.getSrcPort()).andReturn(new Short((short)srcPort)).anyTimes();
@@ -103,7 +105,8 @@
}
private FlowPath createTestFlowPath(long flowId, String installerId,
- String flowPathType, final long flowPathFlags,
+ String flowPathType, String flowPathUserState,
+ final long flowPathFlags,
final long srcDpid, final int srcPort,
final long dstDpid, final int dstPort
) {
@@ -111,6 +114,7 @@
flowPath.setFlowId(new FlowId(flowId));
flowPath.setInstallerId(new CallerId(installerId));
flowPath.setFlowPathType(FlowPathType.valueOf(flowPathType));
+ flowPath.setFlowPathUserState(FlowPathUserState.valueOf(flowPathUserState));
flowPath.setFlowPathFlags(new FlowPathFlags(flowPathFlags));
flowPath.setDataPath(new DataPath() {{
setSrcPort(new SwitchPort(new Dpid(srcDpid), new Port((short)srcPort)));
@@ -121,9 +125,9 @@
}
private ArrayList<FlowPath> createTestFlowPaths() {
- FlowPath flowPath1 = createTestFlowPath(1, "foo caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
- FlowPath flowPath2 = createTestFlowPath(2, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
- FlowPath flowPath3 = createTestFlowPath(3, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 5, 2, 2);
+ FlowPath flowPath1 = createTestFlowPath(1, "foo caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
+ FlowPath flowPath2 = createTestFlowPath(2, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
+ FlowPath flowPath3 = createTestFlowPath(3, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 5, 2, 2);
ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
flowPaths.add(flowPath1);
@@ -197,6 +201,7 @@
flowPath.setFlowId(new FlowId(0x100));
flowPath.setInstallerId(new CallerId("installer id"));
flowPath.setFlowPathType(FlowPathType.valueOf("FP_TYPE_SHORTEST_PATH"));
+ flowPath.setFlowPathUserState(FlowPathUserState.valueOf("FP_USER_ADD"));
flowPath.setFlowPathFlags(new FlowPathFlags(0));
flowPath.setDataPath(dataPath);
flowPath.setFlowEntryMatch(match);
@@ -209,13 +214,13 @@
createdFlowPath.setType("flow");
createdFlowPath.setInstallerId("installer id");
createdFlowPath.setFlowPathType("FP_TYPE_SHORTEST_PATH");
+ createdFlowPath.setFlowPathUserState("FP_USER_ADD");
createdFlowPath.setFlowPathFlags(new Long((long)0));
createdFlowPath.setSrcSwitch("00:00:00:00:00:00:12:34");
createdFlowPath.setSrcPort(new Short((short)1));
createdFlowPath.setDstSwitch("00:00:00:00:00:00:56:78");
createdFlowPath.setDstPort(new Short((short)2));
createdFlowPath.setDataPathSummary("data path summary");
- createdFlowPath.setUserState("FE_USER_ADD");
expectPrivate(fm, addFlowEntry, createdFlowPath, flowEntry1)
.andReturn(createdFlowEntry1);
@@ -357,7 +362,7 @@
public final void testGetFlowSuccessNormally() throws Exception {
// instantiate required objects
FlowManager fm = new FlowManager();
- IFlowPath iFlowPath = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
// setup expectations
expectInitWithContext();
@@ -372,12 +377,14 @@
FlowPath flowPath = fm.getFlow(new FlowId(1));
String installerId = flowPath.installerId().toString();
String flowPathType = flowPath.flowPathType().toString();
+ String flowPathUserState = flowPath.flowPathUserState().toString();
long flowPathFlags = flowPath.flowPathFlags().flags();
//verify the test
verifyAll();
assertEquals("caller id", installerId);
assertEquals("FP_TYPE_SHORTEST_PATH", flowPathType);
+ assertEquals("FP_USER_ADD", flowPathUserState);
assertEquals(0L, flowPathFlags);
}
@@ -460,9 +467,9 @@
final String getAllFlowsWithoutFlowEntries = "getAllFlowsWithoutFlowEntries";
// create mock objects
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, getAllFlowsWithoutFlowEntries);
- IFlowPath flowPath1 = createIFlowPathMock(1, "", "FP_TYPE_SHORTEST_PATH", 0, 1, 2, 3, 4);
- IFlowPath flowPath2 = createIFlowPathMock(5, "", "FP_TYPE_SHORTEST_PATH", 0, 2, 3, 4, 5);
- IFlowPath flowPath3 = createIFlowPathMock(10, "", "FP_TYPE_SHORTEST_PATH", 0, 3, 4, 5, 6);
+ IFlowPath flowPath1 = createIFlowPathMock(1, "", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 2, 3, 4);
+ IFlowPath flowPath2 = createIFlowPathMock(5, "", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 2, 3, 4, 5);
+ IFlowPath flowPath3 = createIFlowPathMock(10, "", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 3, 4, 5, 6);
// instantiate required objects
ArrayList<IFlowPath> flows = new ArrayList<IFlowPath>();
@@ -495,8 +502,8 @@
@Test
public final void testGetAllFlowsSuccessNormally() throws Exception {
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
- IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 2, 5, 3, 5);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 2, 5, 3, 5);
// instantiate required objects
ArrayList<IFlowPath> flowPaths = new ArrayList<IFlowPath>();
@@ -548,6 +555,7 @@
paramFlow.setFlowId(new FlowId(100));
paramFlow.setInstallerId(new CallerId("installer id"));
paramFlow.setFlowPathType(FlowPathType.valueOf("FP_TYPE_SHORTEST_PATH"));
+ paramFlow.setFlowPathUserState(FlowPathUserState.valueOf("FP_USER_ADD"));
paramFlow.setFlowPathFlags(new FlowPathFlags(0));
paramFlow.setDataPath(dataPath);
paramFlow.setFlowEntryMatch(match);
@@ -564,6 +572,7 @@
assertEquals(flowPath.flowId().value(), 100);
assertEquals(flowPath.installerId().toString(), "installer id");
assertEquals(flowPath.flowPathType().toString(), "PF_TYPE_SHORTEST_PATH");
+ assertEquals(flowPath.flowPathUserState().toString(), "PF_USER_STATE");
assertEquals(flowPath.flowPathFlags().flags(), 0);
assertEquals(flowPath.dataPath().srcPort().toString(),
new SwitchPort(new Dpid(1), new Port((short)3)).toString());
@@ -586,6 +595,7 @@
assertEquals(paramFlow.flowId().value(), resultFlow.flowId().value());
assertEquals(paramFlow.installerId().toString(), resultFlow.installerId().toString());
assertEquals(paramFlow.flowPathType().toString(), resultFlow.flowPathType().toString());
+ assertEquals(paramFlow.flowPathUserState().toString(), resultFlow.flowPathUserState().toString());
assertEquals(paramFlow.flowPathFlags().flags(), resultFlow.flowPathFlags().flags());
assertEquals(paramFlow.dataPath().toString(), resultFlow.dataPath().toString());
assertEquals(paramFlow.flowEntryMatch().toString(), resultFlow.flowEntryMatch().toString());
@@ -784,7 +794,7 @@
@Test
public final void testClearFlowSuccessNormally() throws Exception {
// create mock objects
- IFlowPath flowPath = createIFlowPathMock(123, "id", "FP_TYPE_SHORTEST_PATH", 0, 1, 2, 3, 4);
+ IFlowPath flowPath = createIFlowPathMock(123, "id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 2, 3, 4);
IFlowEntry flowEntry1 = createMock(IFlowEntry.class);
IFlowEntry flowEntry2 = createMock(IFlowEntry.class);
IFlowEntry flowEntry3 = createMock(IFlowEntry.class);
@@ -827,8 +837,8 @@
@Test
public final void testGetAllFlowsWithoutFlowEntriesSuccessNormally() throws Exception {
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
- IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 2, 5, 3, 5);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 2, 5, 3, 5);
// instantiate required objects
ArrayList<IFlowPath> flowPaths = new ArrayList<IFlowPath>();
@@ -864,7 +874,7 @@
final String addFlowEntry = "addFlowEntry";
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 1, 2, 2);
IFlowEntry iFlowEntry1 = createMock(IFlowEntry.class);
IFlowEntry iFlowEntry2 = createMock(IFlowEntry.class);
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, addFlowEntry);
@@ -938,7 +948,7 @@
public final void testInstallFlowEntryWithIFlowPathSuccessNormally() throws Exception {
// create mock object
IOFSwitch iofSwitch = createNiceMock(IOFSwitch.class);
- IFlowPath iFlowPath = createIFlowPathMock(1, "id", "FP_TYPE_SHORTEST_PATH", 0, 1, 2, 3, 4);
+ IFlowPath iFlowPath = createIFlowPathMock(1, "id", "FP_TYPE_SHORTEST_PATH", "FP_USER_ADD", 0, 1, 2, 3, 4);
IFlowEntry iFlowEntry = createMock(IFlowEntry.class);
BasicFactory basicFactory = createMock(BasicFactory.class);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/util/FlowPathTest.java b/src/test/java/net/onrc/onos/ofcontroller/util/FlowPathTest.java
index 7f18667..bd42ac8 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/util/FlowPathTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/util/FlowPathTest.java
@@ -17,6 +17,7 @@
iFlowPath.setFlowIdForTest("0x1234");
iFlowPath.setInstallerIdForTest("installerId");
iFlowPath.setFlowPathTypeForTest("FP_TYPE_SHORTEST_PATH");
+ iFlowPath.setFlowPathUserStateForTest("FP_USER_ADD");
iFlowPath.setFlowPathFlagsForTest(0L);
iFlowPath.setSrcSwForTest("CA:FE");
iFlowPath.setSrcPortForTest((short)1);
@@ -40,6 +41,7 @@
public void testFlowPath(){
FlowPath flowPath = new FlowPath();
assertTrue ( flowPath.flowPathType() == FlowPathType.FP_TYPE_UNKNOWN);
+ assertTrue ( flowPath.flowPathUserState() == FlowPathUserState.FP_USER_UNKNOWN);
assertFalse( flowPath.flowPathFlags().isDiscardFirstHopEntry() );
assertFalse( flowPath.flowPathFlags().isKeepOnlyFirstHopEntry() );
assertTrue( flowPath.flowEntryActions().isEmpty() );
@@ -51,6 +53,7 @@
iFlowPath.setFlowIdForTest("0x1234");
iFlowPath.setInstallerIdForTest("installerId");
iFlowPath.setFlowPathTypeForTest("FP_TYPE_SHORTEST_PATH");
+ iFlowPath.setFlowPathUserStateForTest("FP_USER_ADD");
iFlowPath.setFlowPathFlagsForTest(0L);
iFlowPath.setSrcSwForTest("CA:FE");
iFlowPath.setSrcPortForTest((short)1);
@@ -95,6 +98,7 @@
assertEquals(flowPath.flowId().value(), 0x1234);
assertEquals(flowPath.installerId().value(), "installerId");
assertEquals(flowPath.flowPathType(), FlowPathType.FP_TYPE_SHORTEST_PATH);
+ assertEquals(flowPath.flowPathUserState(), FlowPathUserState.FP_USER_ADD);
assertEquals(flowPath.flowPathFlags().flags(), 0);
assertEquals(flowPath.dataPath().srcPort().dpid().value(), 0xCAFE);
assertEquals(flowPath.dataPath().srcPort().port().value(), 1);
@@ -147,6 +151,14 @@
}
@Test
+ public void testSetFlowPathUserState(){
+ FlowPath flowPath = new FlowPath();
+ FlowPathUserState state = FlowPathUserState.FP_USER_ADD;
+ flowPath.setFlowPathUserState( state );
+ assertTrue( flowPath.flowPathUserState() == FlowPathUserState.FP_USER_ADD );
+ }
+
+ @Test
public void testFlowPathFlags(){
FlowPath flowPath = new FlowPath();
FlowPathFlags flags = new FlowPathFlags();
@@ -177,7 +189,7 @@
@Test
public void testToString(){
- assertEquals("[flowId=0x1234 installerId=installerId flowPathType=FP_TYPE_SHORTEST_PATH flowPathFlags=[flags=] dataPath=[src=00:00:00:00:00:00:ca:fe/1 flowEntry=[flowEntryId=0x14 flowEntryMatch=[] flowEntryActions=[[type=ACTION_OUTPUT action=[port=23 maxLen=24]];[type=ACTION_OUTPUT action=[port=25 maxLen=26]];] dpid=00:00:00:00:00:00:be:ef flowEntryUserState=FE_USER_MODIFY flowEntrySwitchState=FE_SWITCH_UPDATE_IN_PROGRESS] dst=00:00:00:00:00:00:ba:be/2] flowEntryMatch=[] flowEntryActions=[[type=ACTION_OUTPUT action=[port=10 maxLen=11]];[type=ACTION_OUTPUT action=[port=12 maxLen=13]];]]", flowPath.toString());
+ assertEquals("[flowId=0x1234 installerId=installerId flowPathType=FP_TYPE_SHORTEST_PATH flowPathUserState=FP_USER_ADD flowPathFlags=[flags=] dataPath=[src=00:00:00:00:00:00:ca:fe/1 flowEntry=[flowEntryId=0x14 flowEntryMatch=[] flowEntryActions=[[type=ACTION_OUTPUT action=[port=23 maxLen=24]];[type=ACTION_OUTPUT action=[port=25 maxLen=26]];] dpid=00:00:00:00:00:00:be:ef flowEntryUserState=FE_USER_MODIFY flowEntrySwitchState=FE_SWITCH_UPDATE_IN_PROGRESS] dst=00:00:00:00:00:00:ba:be/2] flowEntryMatch=[] flowEntryActions=[[type=ACTION_OUTPUT action=[port=10 maxLen=11]];[type=ACTION_OUTPUT action=[port=12 maxLen=13]];]]", flowPath.toString());
}
@Test
diff --git a/web/add_flow.py b/web/add_flow.py
index 0efa550..6b9d5d0 100755
--- a/web/add_flow.py
+++ b/web/add_flow.py
@@ -354,6 +354,7 @@
flow_path['installerId'] = installer_id
# NOTE: The 'flowPathType' might be rewritten later
flow_path['flowPathType'] = 'FP_TYPE_EXPLICIT_PATH'
+ flow_path['flowPathUserState'] = 'FP_USER_ADD'
flow_path['flowPathFlags'] = flowPathFlags
if (len(match) > 0):
diff --git a/web/get_flow.py b/web/get_flow.py
index b17f417..c45d853 100755
--- a/web/get_flow.py
+++ b/web/get_flow.py
@@ -162,6 +162,7 @@
flowId = parsedResult['flowId']['value']
installerId = parsedResult['installerId']['value']
flowPathType = parsedResult['flowPathType']
+ flowPathUserState = parsedResult['flowPathUserState']
flowPathFlags = parsedResult['flowPathFlags']['flags']
srcSwitch = parsedResult['dataPath']['srcPort']['dpid']['value']
srcPort = parsedResult['dataPath']['srcPort']['port']['value']
@@ -180,7 +181,7 @@
flowPathFlagsStr += ","
flowPathFlagsStr += "KEEP_ONLY_FIRST_HOP_ENTRY"
- print "FlowPath: (flowId = %s installerId = %s flowPathType = %s flowPathFlags = 0x%x(%s) src = %s/%s dst = %s/%s)" % (flowId, installerId, flowPathType, flowPathFlags, flowPathFlagsStr, srcSwitch, srcPort, dstSwitch, dstPort)
+ print "FlowPath: (flowId = %s installerId = %s flowPathType = %s flowPathUserState = %s flowPathFlags = 0x%x(%s) src = %s/%s dst = %s/%s)" % (flowId, installerId, flowPathType, flowPathUserState, flowPathFlags, flowPathFlagsStr, srcSwitch, srcPort, dstSwitch, dstPort)
#
# Print the common match conditions