use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class ECFlowRuleStoreTest method testPurgeFlow.
/**
* Tests purge flow for a device.
*/
@Test
public void testPurgeFlow() {
FlowEntry flowEntry = new DefaultFlowEntry(flowRule);
flowStoreImpl.addOrUpdateFlowRule(flowEntry);
FlowEntry flowEntry1 = new DefaultFlowEntry(flowRule1);
flowStoreImpl.addOrUpdateFlowRule(flowEntry1);
assertFlowsOnDevice(deviceId, 2);
flowStoreImpl.purgeFlowRule(deviceId);
assertFlowsOnDevice(deviceId, 0);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class ECFlowRuleStoreTest method testAddFlow.
/**
* Tests adding a flowrule.
*/
@Test
public void testAddFlow() {
FlowEntry flowEntry = new DefaultFlowEntry(flowRule);
FlowRuleOperation op = new FlowRuleOperation(flowRule, FlowRuleOperation.Type.ADD);
Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = ArrayListMultimap.create();
perDeviceBatches.put(op.rule().deviceId(), new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, op.rule()));
FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), deviceId, 1);
flowStoreImpl.storeBatch(b);
FlowEntry flowEntry1 = flowStoreImpl.getFlowEntry(flowRule);
assertEquals("PENDING_ADD", flowEntry1.state().toString());
flowStoreImpl.addOrUpdateFlowRule(flowEntry);
assertFlowsOnDevice(deviceId, 1);
FlowEntry flowEntry2 = flowStoreImpl.getFlowEntry(flowRule);
assertEquals("ADDED", flowEntry2.state().toString());
assertThat(flowStoreImpl.getTableStatistics(deviceId), notNullValue());
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class PolatisFlowRuleProgrammable method getFlowEntries.
@Override
public Collection<FlowEntry> getFlowEntries() {
List<TableEvent> events;
DeviceId deviceId = handler().data().deviceId();
ImmutableList.Builder<FlowEntry> connectionsBuilder = ImmutableList.builder();
try {
OID[] columnOIDs = { new OID(PORT_PATCH_OID) };
events = getTable(handler(), columnOIDs);
} catch (IOException e) {
log.error("Error reading ports table for device {} exception {}", deviceId, e);
return connectionsBuilder.build();
}
if (events == null) {
log.error("Error reading ports table for device {}", deviceId);
return connectionsBuilder.build();
}
for (TableEvent event : events) {
if (event == null) {
log.error("Error reading event for device {}", deviceId);
continue;
}
VariableBinding[] columns = event.getColumns();
if (columns == null) {
log.error("Error reading columns for device {}", deviceId);
continue;
}
VariableBinding patchColumn = columns[0];
if (patchColumn == null) {
continue;
}
int port = event.getIndex().last();
int patch = patchColumn.getVariable().toInt();
if (patch == 0) {
continue;
}
FlowRule flowRule = PolatisOpticalUtility.toFlowRule(this, PortNumber.portNumber(port), PortNumber.portNumber(patch));
connectionsBuilder.add(new DefaultFlowEntry(flowRule, FlowEntry.FlowEntryState.ADDED));
}
return connectionsBuilder.build();
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class PolatisUtility method parseConnections.
/**
* Returns flow entries representing current cross-connections on a Polatis optical switch.
*
* @param behaviour HandlerBehaviour object associated with device being queried
* @return Cross-connections as a collection of FlowEntry objects
*/
public static Collection<FlowEntry> parseConnections(HandlerBehaviour behaviour) {
log.debug("Fetch connections...");
String reply = netconfGet(behaviour.handler(), getConnectionsFilter());
final String keyPairMode = String.format("%s.%s", KEY_DATA_CONNS, parseKeyPairCompat(behaviour));
List<HierarchicalConfiguration> subtrees = configsAt(reply, keyPairMode);
ImmutableList.Builder<FlowEntry> connectionsBuilder = ImmutableList.builder();
for (HierarchicalConfiguration connection : subtrees) {
connectionsBuilder.add(new DefaultFlowEntry(parseConnection(connection, behaviour), FlowEntry.FlowEntryState.ADDED));
}
return connectionsBuilder.build();
}
Aggregations