Search in sources :

Example 51 with TableKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey 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 52 with TableKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey 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 53 with TableKey

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

the class FlowBasedServicesUtils method removeEgressDispatcherFlow.

private static void removeEgressDispatcherFlow(BigInteger dpId, String iface, WriteTransaction writeTransaction, short currentServiceIndex) {
    // build the flow and install it
    String flowRef = getFlowRef(dpId, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, iface, currentServiceIndex);
    FlowKey flowKey = new FlowKey(new FlowId(flowRef));
    Node nodeDpn = buildInventoryDpnNode(dpId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE)).child(Flow.class, flowKey).build();
    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
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) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 54 with TableKey

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

the class FlowBasedServicesUtils method removeEgressSplitHorizonDispatcherFlow.

public static void removeEgressSplitHorizonDispatcherFlow(BigInteger dpId, String iface, WriteTransaction writeTransaction) {
    // BigInteger.ONE is used for checking the Split-Horizon flag
    BigInteger shFlagSet = BigInteger.ONE;
    String shFlowRef = getSplitHorizonFlowRef(dpId, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, iface, shFlagSet);
    FlowKey shFlowKey = new FlowKey(new FlowId(shFlowRef));
    Node nodeDpn = buildInventoryDpnNode(dpId);
    InstanceIdentifier<Flow> shFlowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE)).child(Flow.class, shFlowKey).build();
    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, shFlowInstanceId);
}
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) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) BigInteger(java.math.BigInteger) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 55 with TableKey

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

the class FlowBasedServicesUtils method removeLPortDispatcherFlow.

public static void removeLPortDispatcherFlow(BigInteger dpId, String iface, BoundServices boundServicesOld, WriteTransaction writeTransaction, short currentServiceIndex) {
    LOG.debug("Removing LPort Dispatcher Flows {}, {}", dpId, iface);
    boundServicesOld.getAugmentation(StypeOpenflow.class);
    // build the flow and install it
    String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, iface, currentServiceIndex);
    FlowKey flowKey = new FlowKey(new FlowId(flowRef));
    Node nodeDpn = buildInventoryDpnNode(dpId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.LPORT_DISPATCHER_TABLE)).child(Flow.class, flowKey).build();
    writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
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) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)50 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)41 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)37 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)28 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)28 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)27 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)23 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)22 Test (org.junit.Test)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 ArrayList (java.util.ArrayList)10 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)10 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)8 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)8 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)8 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)8 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)7 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)6 StaleFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow)6