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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations