use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkTransactionProvider method _addFlows.
public void _addFlows(CommandInterpreter ci) {
NodeBuilder tn = createTestNode(ci.nextArgument());
String flowtype = ci.nextArgument();
Integer flowcnt = Integer.parseInt(flowtype);
FlowBuilder tf;
FlowBuilder tf1;
FlowBuilder tf2;
FlowBuilder tf3;
switch(flowcnt) {
case 1:
tf = createTestFlow(tn, "f1", "10");
tf1 = createTestFlow(tn, "f2", "11");
tf2 = createTestFlow(tn, "f3", "12");
tf3 = createTestFlow(tn, "f4", "13");
break;
case 2:
tf = createTestFlow(tn, "f3", "3");
tf1 = createTestFlow(tn, "f4", "4");
tf2 = createTestFlow(tn, "f5", "5");
tf3 = createTestFlow(tn, "f6", "6");
break;
case 3:
tf = createTestFlow(tn, "f7", "7");
tf1 = createTestFlow(tn, "f8", "8");
tf2 = createTestFlow(tn, "f9", "9");
tf3 = createTestFlow(tn, "f10", "10");
break;
case 4:
// -ve scenario
tf = createTestFlow(tn, "f23", "3");
tf1 = createTestFlow(tn, "f34", "4");
tf2 = createTestFlow(tn, "f35", "5");
tf3 = createTestFlow(tn, "f36", "6");
break;
case 5:
// +ve scenario
// modify case 6 -ve
tf = createTestFlow(tn, "f230", "3");
tf1 = createTestFlow(tn, "f34", "4");
tf2 = createTestFlow(tn, "f35", "5");
tf3 = createTestFlow(tn, "f36", "6");
break;
default:
tf = createTestFlow(tn, "f42", "42");
tf1 = createTestFlow(tn, "f43", "43");
tf2 = createTestFlow(tn, "f44", "44");
tf3 = createTestFlow(tn, "f45", "45");
}
writeFlow(ci, tf, tf1, tf2, tf3, tn);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.
the class LearningSwitchHandlerSimpleImpl method onSwitchAppeared.
@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
if (isLearning) {
LOG.debug("already learning a node, skipping {}", nodeId.getValue());
return;
}
LOG.debug("expected table acquired, learning ..");
// disable listening - simple learning handles only one node (switch)
if (registrationPublisher != null) {
LOG.debug("closing dataTreeChangeListenerRegistration");
registrationPublisher.getDataTreeChangeListenerRegistration().close();
}
isLearning = true;
tablePath = appearedTablePath;
nodePath = tablePath.firstIdentifierOf(Node.class);
nodeId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId();
mac2portMapping = new HashMap<>();
// start forwarding all packages to controller
FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
FlowKey flowKey = new FlowKey(flowId);
InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
int priority = 0;
// create flow in table with id = 0, priority = 4 (other params are
// defaulted in OFDataStoreUtil)
FlowBuilder allToCtrlFlow = FlowUtils.createFwdAllToControllerFlow(InstanceIdentifierUtils.getTableId(tablePath), priority, flowId);
LOG.debug("writing packetForwardToController flow");
dataStoreAccessor.writeFlowToConfig(flowPath, allToCtrlFlow.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.
the class LearningSwitchHandlerSimpleImpl method addBridgeFlow.
private void addBridgeFlow(MacAddress srcMac, MacAddress dstMac, NodeConnectorRef destNodeConnector) {
synchronized (coveredMacPaths) {
String macPath = srcMac.toString() + dstMac.toString();
if (!coveredMacPaths.contains(macPath)) {
LOG.debug("covering mac path: {} by [{}]", macPath, destNodeConnector.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId());
coveredMacPaths.add(macPath);
FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
FlowKey flowKey = new FlowKey(flowId);
/**
* Path to the flow we want to program.
*/
InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
Short tableId = InstanceIdentifierUtils.getTableId(tablePath);
FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac, dstMac, destNodeConnector);
srcToDstFlow.setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())));
dataStoreAccessor.writeFlowToConfig(flowPath, srcToDstFlow.build());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.
the class Activator method createFlow.
private static Flow createFlow(String flowId, long groupId, int priority, short tableId) {
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setEthernetMatch(new EthernetMatchBuilder().setEthernetType(new EthernetTypeBuilder().setType(new EtherType(2048L)).build()).build());
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setMatch(matchBuilder.build());
flowBuilder.setInstructions(createGroupInstructions(groupId).build());
flowBuilder.setPriority(priority);
flowBuilder.setCookie(new FlowCookie(new BigInteger(flowId + "" + priority)));
FlowKey key = new FlowKey(new FlowId(flowId));
flowBuilder.setHardTimeout(0);
flowBuilder.setIdleTimeout(0);
flowBuilder.setStrict(false);
flowBuilder.setContainerName(null);
flowBuilder.setId(new FlowId(flowId));
flowBuilder.setTableId(tableId);
flowBuilder.setKey(key);
flowBuilder.setFlowName("FlowWithGroupInstruction");
return flowBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.
the class FlowForwarderTest method removeTest.
@Test
public void removeTest() throws Exception {
Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
final Flow removeFlow = new FlowBuilder(flow).build();
final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
Assert.assertEquals(2, flowInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowInput.getMatch());
Assert.assertEquals(null, flowInput.getInstructions());
Assert.assertEquals(true, flowInput.isStrict());
final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Aggregations