use of org.onosproject.net.flow.FlowEntry.FlowEntryState in project onos by opennetworkinglab.
the class VirtualFlowsListCommand method compilePredicate.
/**
* Compiles a predicate to find matching flows based on the command
* arguments.
*/
private void compilePredicate() {
if (state != null && !state.equals(ANY)) {
final FlowEntryState feState = FlowEntryState.valueOf(state.toUpperCase());
predicate = predicate.and(f -> f.state().equals(feState));
}
if (table != null) {
final int tableId = Integer.parseInt(table);
predicate = predicate.and(f -> f.tableId() == tableId);
}
}
use of org.onosproject.net.flow.FlowEntry.FlowEntryState in project onos by opennetworkinglab.
the class FlowsListCommand method compilePredicate.
/**
* Compiles a predicate to find matching flows based on the command
* arguments.
*/
private void compilePredicate() {
if (state != null && !state.equals(ANY)) {
final FlowEntryState feState = FlowEntryState.valueOf(state.toUpperCase());
predicate = predicate.and(f -> f.state().equals(feState));
}
if (table != null) {
final int tableId = Integer.parseInt(table);
predicate = predicate.and(f -> f.tableId() == tableId);
}
}
use of org.onosproject.net.flow.FlowEntry.FlowEntryState in project onos by opennetworkinglab.
the class FlowRuleManagerTest method validateState.
private boolean validateState(Map<FlowRule, FlowEntryState> expected) {
Map<FlowRule, FlowEntryState> expectedToCheck = new HashMap<>(expected);
Iterable<FlowEntry> rules = service.getFlowEntries(DID);
for (FlowEntry f : rules) {
assertTrue("Unexpected FlowRule " + f, expectedToCheck.containsKey(f));
assertEquals("FlowEntry" + f, expectedToCheck.get(f), f.state());
expectedToCheck.remove(f);
}
assertEquals(Collections.emptySet(), expectedToCheck.entrySet());
return true;
}
use of org.onosproject.net.flow.FlowEntry.FlowEntryState in project onos by opennetworkinglab.
the class FlowEntryBuilder method createFlowEntryForFlowMod.
private FlowEntry createFlowEntryForFlowMod(FlowEntryState... state) {
FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED;
FlowRule.Builder builder = DefaultFlowRule.builder().forDevice(deviceId).withSelector(buildSelector()).withTreatment(buildTreatment()).withPriority(flowMod.getPriority()).withIdleTimeout(flowMod.getIdleTimeout()).withCookie(flowMod.getCookie().getValue());
if (flowMod.getVersion() != OFVersion.OF_10) {
builder.forTable(flowMod.getTableId().getValue());
}
if (afsc != null) {
FlowEntry.FlowLiveType liveType = FlowEntry.FlowLiveType.IMMEDIATE;
return new DefaultFlowEntry(builder.build(), flowState, 0, liveType, 0, 0);
} else {
return new DefaultFlowEntry(builder.build(), flowState, 0, 0, 0);
}
}
use of org.onosproject.net.flow.FlowEntry.FlowEntryState in project onos by opennetworkinglab.
the class FlowRuleStatusCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
FlowEntryState[] states = FlowEntryState.values();
SortedSet<String> strings = delegate.getStrings();
for (int i = 0; i < states.length; i++) {
strings.add(states[i].toString().toLowerCase());
}
strings.add(FlowsListCommand.ANY);
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
Aggregations