use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createTestFlow.
private FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg, final String tableId) {
final long TEST_ID = 123;
final FlowBuilder flow = new FlowBuilder();
long id = TEST_ID;
String flowType = flowTypeArg;
if (flowType == null) {
flowType = "f1";
}
flow.setPriority(2);
switch(flowType) {
case "f1":
id += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f2":
id += 2;
flow.setMatch(createMatch2().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f3":
id += 3;
flow.setMatch(createMatch3().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f4":
id += 4;
flow.setMatch(createEthernetMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f5":
id += 5;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction().build());
break;
case "f6":
id += 6;
flow.setMatch(createMatch1().build());
flow.setInstructions(createGotoTableInstructions().build());
break;
case "f7":
id += 7;
flow.setMatch(createMatch1().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f8":
id += 8;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction1().build());
break;
case "f9":
id += 9;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction2().build());
break;
case "f10":
id += 10;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction3().build());
break;
case "f11":
id += 11;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction4().build());
break;
case "f12":
id += 12;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction5().build());
break;
case "f13":
id += 13;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction6().build());
break;
case "f14":
id += 14;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction7().build());
break;
case "f15":
id += 15;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction8().build());
break;
case "f16":
id += 16;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction9().build());
break;
case "f17":
id += 17;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction10().build());
break;
case "f18":
id += 18;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction11().build());
break;
case "f19":
id += 19;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction12().build());
break;
case "f20":
id += 20;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction13().build());
break;
case "f21":
id += 21;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction14().build());
break;
case "f22":
id += 22;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction15().build());
break;
case "f23":
id += 23;
// f23 can be used as test-case for generating error notification
// if the particular group is not configured - tested
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction16().build());
break;
case "f24":
id += 24;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction17().build());
break;
case "f25":
id += 25;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction18().build());
break;
case "f26":
id += 26;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction19().build());
break;
case "f27":
id += 27;
flow.setMatch(createMatch1().build());
flow.setInstructions(createMetadataInstructions().build());
break;
case "f28":
id += 28;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction20().build());
break;
case "f29":
id += 29;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction21().build());
break;
case "f30":
id += 30;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction22().build());
break;
case "f31":
id += 31;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
break;
case "f32":
id += 32;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction24().build());
break;
case "f33":
id += 33;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction25().build());
break;
case "f34":
id += 34;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction26().build());
break;
case "f35":
id += 35;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction27().build());
break;
case "f36":
id += 36;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction28().build());
break;
case "f37":
id += 37;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction29().build());
break;
case "f38":
id += 38;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction30().build());
break;
case "f39":
id += 39;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction31().build());
break;
case "f40":
id += 40;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction32().build());
break;
case "f41":
id += 41;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction33().build());
break;
case "f42":
id += 42;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction34().build());
break;
case "f43":
id += 43;
flow.setMatch(createICMPv6Match().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f44":
id += 44;
flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
flow.setInstructions(createDropInstructions().build());
break;
case "f45":
id += 45;
flow.setMatch(createMetadataMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f46":
id += 46;
flow.setMatch(createL3IPv6Match().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f47":
id += 47;
flow.setMatch(createL4SCTPMatch().build());
flow.setInstructions(createAppyActionInstruction().build());
break;
case "f48":
id += 48;
flow.setMatch(createTunnelIDMatch().build());
flow.setInstructions(createGotoTableInstructions().build());
break;
case "f49":
id += 49;
flow.setMatch(createVlanMatch().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f50":
id += 50;
flow.setMatch(createPbbMatch().build());
flow.setInstructions(createMeterInstructions().build());
break;
case "f51":
id += 51;
flow.setMatch(createVlanMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f52":
id += 52;
flow.setMatch(createL4TCPMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f53":
id += 53;
flow.setMatch(createL4UDPMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f54":
id += 54;
flow.setMatch(new MatchBuilder().build());
flow.setInstructions(createSentToControllerInstructions().build());
flow.setPriority(0);
break;
case "f55":
id += 55;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f56":
id += 56;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("INPORT", 10).build());
break;
case "f57":
id += 57;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
break;
case "f58":
id += 58;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("ALL", 30).build());
break;
case "f59":
id += 59;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
break;
case "f60":
id += 60;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
break;
case "f61":
id += 61;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("TABLE", 60).build());
break;
case "f62":
id += 62;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions("NONE", 70).build());
break;
case "f63":
id += 63;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createStripVlanInstructions().build());
flow.setBarrier(Boolean.TRUE);
break;
case "f64":
id += 64;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction35().build());
break;
case "f65":
id += 65;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction36().build());
break;
case "f66":
id += 66;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction37().build());
break;
case "f67":
id += 67;
flow.setMatch(createMatch1().build());
flow.setInstructions(createAppyActionInstruction38().build());
break;
case "f68":
id += 68;
flow.setMatch(createL4TCPMatch().build());
flow.setInstructions(createAppyActionInstruction39().build());
break;
case "f69":
id += 69;
flow.setMatch(createL4UDPMatch().build());
flow.setInstructions(createAppyActionInstruction40().build());
break;
case "f70":
id += 70;
flow.setMatch(createL4SCTPMatch().build());
flow.setInstructions(createAppyActionInstruction41().build());
break;
case "f71":
id += 71;
flow.setMatch(createICMPv4Match().build());
flow.setInstructions(createAppyActionInstruction42().build());
break;
case "f72":
id += 72;
flow.setMatch(createArpMatch().build());
flow.setInstructions(createAppyActionInstruction43().build());
break;
case "f73":
id += 73;
flow.setMatch(createL3IPv6Match().build());
flow.setInstructions(createAppyActionInstruction44().build());
break;
case "f74":
id += 74;
flow.setMatch(createICMPv6Match().build());
flow.setInstructions(createAppyActionInstruction45().build());
break;
case "f75":
id += 75;
flow.setMatch(createMplsMatch().build());
flow.setInstructions(createAppyActionInstruction46().build());
break;
case "f76":
id += 76;
flow.setMatch(createPbbMatch().build());
flow.setInstructions(createAppyActionInstruction47().build());
break;
case "f77":
id += 77;
flow.setMatch(createTunnelIDMatch().build());
flow.setInstructions(createAppyActionInstruction48().build());
break;
case "f78":
id += 78;
flow.setMatch(createMatch33().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f79":
id += 79;
flow.setMatch(createICMPv6Match1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
case "f80":
id += 80;
flow.setMatch(createVlanMatch().build());
flow.setInstructions(createAppyActionInstruction88().build());
break;
case "f81":
id += 81;
flow.setMatch(createLLDPMatch().build());
flow.setInstructions(createSentToControllerInstructions().build());
break;
case "f82":
id += 82;
flow.setMatch(createToSMatch().build());
flow.setInstructions(createOutputInstructions().build());
break;
case "f83":
// Test TCP_Flag Match
id += 83;
flow.setMatch(createTcpFlagMatch().build());
flow.setInstructions(createDropInstructions().build());
break;
case "f84":
id += 84;
// match vlan=10,dl_vlan_pcp=3
flow.setMatch(createVlanMatch().build());
// vlan_pcp=4
flow.setInstructions(createAppyActionInstruction88().build());
break;
case "f85":
// Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
id += 85;
flow.setMatch(createMatch3().build());
flow.setInstructions(createTunnelIpv4SrcInstructions().build());
break;
case "f86":
// Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
id += 86;
flow.setMatch(createMatch1().build());
flow.setInstructions(createTunnelIpv4DstInstructions().build());
break;
default:
LOG.warn("flow type not understood: {}", flowType);
}
final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
final BigInteger value = BigInteger.valueOf(10);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(new FlowId("12"));
flow.setTableId(getTableId(tableId));
flow.setKey(key);
flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method addMissingFlows.
ListenableFuture<RpcResult<Void>> addMissingFlows(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final Map<TableKey, ItemSyncBox<Flow>> flowsInTablesSyncBox, final SyncCrudCounters counters) {
if (flowsInTablesSyncBox.isEmpty()) {
LOG.trace("no tables in config for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
final List<ListenableFuture<RpcResult<AddFlowOutput>>> allResults = new ArrayList<>();
final List<ListenableFuture<RpcResult<UpdateFlowOutput>>> allUpdateResults = new ArrayList<>();
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
for (Map.Entry<TableKey, ItemSyncBox<Flow>> flowsInTableBoxEntry : flowsInTablesSyncBox.entrySet()) {
final TableKey tableKey = flowsInTableBoxEntry.getKey();
final ItemSyncBox<Flow> flowSyncBox = flowsInTableBoxEntry.getValue();
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdent.child(Table.class, tableKey);
for (final Flow flow : flowSyncBox.getItemsToPush()) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, flow.getKey());
LOG.trace("adding flow {} in table {} - absent on device {} match{}", flow.getId(), tableKey, nodeId, flow.getMatch());
allResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.add(flowIdent, flow, nodeIdent)));
flowCrudCounts.incAdded();
}
for (final ItemSyncBox.ItemUpdateTuple<Flow> flowUpdate : flowSyncBox.getItemsToUpdate()) {
final Flow existingFlow = flowUpdate.getOriginal();
final Flow updatedFlow = flowUpdate.getUpdated();
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, updatedFlow.getKey());
LOG.trace("flow {} in table {} - needs update on device {} match{}", updatedFlow.getId(), tableKey, nodeId, updatedFlow.getMatch());
allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(flowForwarder.update(flowIdent, existingFlow, updatedFlow, nodeIdent)));
flowCrudCounts.incUpdated();
}
}
final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<AddFlowOutput>createRpcResultCondenser("flow adding"), MoreExecutors.directExecutor());
final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(Futures.allAsList(allUpdateResults), ReconcileUtil.<UpdateFlowOutput>createRpcResultCondenser("flow updating"), MoreExecutors.directExecutor());
return Futures.transform(Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult), ReconcileUtil.<Void>createRpcResultCondenser("flow add/update"), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey in project openflowplugin by opendaylight.
the class FlowListenerTest method updateFlowTest.
@Test
public void updateFlowTest() throws Exception {
addFlowCapableNode(NODE_KEY);
FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(1, addFlowCalls.size());
assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
flowKey = new FlowKey(new FlowId("test_Flow"));
flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).setOutGroup((long) 5).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<UpdateFlowInput> updateFlowCalls = salFlowService.getUpdateFlowCalls();
assertEquals(1, updateFlowCalls.size());
assertEquals("DOM-1", updateFlowCalls.get(0).getTransactionUri().getValue());
assertEquals(flowII, updateFlowCalls.get(0).getFlowRef().getValue());
assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getOriginalFlow().isStrict());
assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getUpdatedFlow().isStrict());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey in project openflowplugin by opendaylight.
the class FlowListenerTest method addTwoFlowsTest.
@Test
public void addTwoFlowsTest() throws Exception {
addFlowCapableNode(NODE_KEY);
FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(1, addFlowCalls.size());
assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
flowKey = new FlowKey(new FlowId("test_Flow2"));
flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(2, addFlowCalls.size());
assertEquals("DOM-1", addFlowCalls.get(1).getTransactionUri().getValue());
assertEquals(2, addFlowCalls.get(1).getTableId().intValue());
assertEquals(flowII, addFlowCalls.get(1).getFlowRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey in project openflowplugin by opendaylight.
the class BulkOMaticUtils method buildFlow.
public static Flow buildFlow(Short tableId, String flowId, Match match) {
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setKey(new FlowKey(new FlowId(flowId)));
flowBuilder.setTableId(tableId);
flowBuilder.setMatch(match);
return flowBuilder.build();
}
Aggregations