Search in sources :

Example 71 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class DropTestCommiter method processPacket.

@Override
protected void processPacket(final InstanceIdentifier<Node> node, final Match match, final Instructions instructions) {
    // Finally build our flow
    final FlowBuilder fb = BUILDER.get();
    fb.setMatch(match);
    fb.setInstructions(instructions);
    fb.setId(new FlowId(String.valueOf(fb.hashCode()) + "." + ID_COUNTER.getAndIncrement()));
    // Construct the flow instance id
    final InstanceIdentifier<Flow> flowInstanceId = node.builder().augmentation(FlowCapableNode.class).child(Table.class, ZERO_TABLE).child(Flow.class, new FlowKey(fb.getId())).build();
    final Flow flow = fb.build();
    final ReadWriteTransaction transaction = dataService.newReadWriteTransaction();
    if (LOG.isDebugEnabled()) {
        LOG.debug("onPacketReceived - About to write flow {}", flow);
    }
    transaction.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true);
    transaction.submit();
    LOG.debug("onPacketReceived - About to write flow commited");
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 72 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkTransactionProvider method writeFlow.

private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, FlowBuilder flow1, FlowBuilder flow2, FlowBuilder flow3, NodeBuilder nodeBuilder) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
    InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true);
    InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true);
    InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), true);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void notUsed) {
            ci.println("Status of Group Data Loaded Transaction: success.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error(throwable.getMessage(), throwable);
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 73 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkTransactionProvider method _removeFlows.

public void _removeFlows(final CommandInterpreter ci) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    NodeBuilder tn = createTestNode(ci.nextArgument());
    String flowtype = ci.nextArgument();
    Integer flowcnt = Integer.parseInt(flowtype);
    FlowBuilder tf = null;
    FlowBuilder tf1 = null;
    FlowBuilder tf2 = null;
    FlowBuilder tf3 = null;
    switch(flowcnt) {
        case 1:
            // add 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:
            // modify case 1
            tf = createTestFlow(tn, "f82", "10");
            tf1 = createTestFlow(tn, "f83", "11");
            tf2 = createTestFlow(tn, "f84", "12");
            tf3 = createTestFlow(tn, "f85", "13");
            break;
        case 3:
            // add case 2
            tf = createTestFlow(tn, "f3", "3");
            tf1 = createTestFlow(tn, "f4", "4");
            tf2 = createTestFlow(tn, "f5", "5");
            tf3 = createTestFlow(tn, "f6", "6");
            break;
        case 4:
            // modify case 2
            tf = createTestFlow(tn, "f700", "3");
            tf1 = createTestFlow(tn, "f4", "4");
            tf2 = createTestFlow(tn, "f900", "5");
            tf3 = createTestFlow(tn, "f86", "6");
            break;
        case 5:
            // add case 3
            tf = createTestFlow(tn, "f7", "7");
            tf1 = createTestFlow(tn, "f8", "8");
            tf2 = createTestFlow(tn, "f9", "9");
            tf3 = createTestFlow(tn, "f10", "10");
            break;
        case 6:
            // modify case 3
            tf = createTestFlow(tn, "f91", "7");
            tf1 = createTestFlow(tn, "f92", "8");
            tf2 = createTestFlow(tn, "f93", "9");
            tf3 = createTestFlow(tn, "f94", "10");
            break;
        case 7:
            // -ve scenario
            tf = createTestFlow(tn, "f23", "3");
            tf1 = createTestFlow(tn, "f34", "4");
            tf2 = createTestFlow(tn, "f35", "5");
            tf3 = createTestFlow(tn, "f36", "6");
            break;
        case 8:
            // +ve scenario
            // modify case 6 -ve
            tf = createTestFlow(tn, "f23", "3");
            tf1 = createTestFlow(tn, "f99", "4");
            tf2 = createTestFlow(tn, "f100", "5");
            tf3 = createTestFlow(tn, "f101", "6");
            break;
        case 9:
            // modify case 6
            tf = createTestFlow(tn, "f700", "7");
            tf1 = createTestFlow(tn, "f230", "23");
            tf2 = createTestFlow(tn, "f900", "9");
            tf3 = createTestFlow(tn, "f1000", "10");
            break;
        default:
            throw new IllegalArgumentException("Invalid flowtype: " + flowtype);
    }
    InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId())).child(Flow.class, tf.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
    InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId())).child(Flow.class, tf1.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
    InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId())).child(Flow.class, tf2.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path3);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
    InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId())).child(Flow.class, tf3.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path4);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void notUsed) {
            ci.println("Status of Group Data Loaded Transaction: success.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error(throwable.getMessage(), throwable);
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) BigInteger(java.math.BigInteger) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)

Example 74 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project genius by opendaylight.

the class FlowEntity method getFlowBuilder.

public FlowBuilder getFlowBuilder() {
    FlowBuilder flowBuilder = new FlowBuilder();
    flowBuilder.setKey(new FlowKey(new FlowId(getFlowId())));
    flowBuilder.setTableId(getTableId());
    flowBuilder.setPriority(getPriority());
    flowBuilder.setFlowName(getFlowName());
    flowBuilder.setIdleTimeout(getIdleTimeOut());
    flowBuilder.setHardTimeout(getHardTimeOut());
    flowBuilder.setCookie(new FlowCookie(getCookie()));
    flowBuilder.setMatch(MDSALUtil.buildMatches(getMatchInfoList()));
    flowBuilder.setInstructions(MDSALUtil.buildInstructions(getInstructionInfoList()));
    flowBuilder.setStrict(getStrictFlag());
    // TODO flowBuilder.setResyncFlag(getResyncFlag());
    if (getSendFlowRemFlag()) {
        flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
    }
    flowBuilder.setBarrier(false);
    flowBuilder.setInstallHw(true);
    return flowBuilder;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)

Example 75 with FlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder in project genius by opendaylight.

the class MDSALManager method writeFlowEntityInternal.

public void writeFlowEntityInternal(FlowEntity flowEntity, WriteTransaction tx) {
    FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
    FlowBuilder flowbld = flowEntity.getFlowBuilder();
    InstanceIdentifier<Flow> flowInstanceId = buildFlowInstanceIdentifier(flowEntity.getDpnId(), flowEntity.getTableId(), flowKey);
    tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flowbld.build(), true);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)62 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)39 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)37 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)26 BigInteger (java.math.BigInteger)22 Test (org.junit.Test)19 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)15 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)15 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)12 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)10 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)10 ArrayList (java.util.ArrayList)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)8 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)8 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)7 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)6