private static NodeRef createNodeRef(String string) {
NodeKey key = new NodeKey(new NodeId(string));
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
- .toInstance();
-
+ InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
return new NodeRef(path);
}
}
private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
private void createTestNode() {
private void writeGroup(final CommandInterpreter ci, Group group, Group group1) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(group.getGroupId())).build();
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12);
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, group);
+ .child(Group.class, new GroupKey(group.getGroupId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true);
- InstanceIdentifier<Group> path2 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(group1.getGroupId())).build();
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12);
- modification.put(LogicalDatastoreType.CONFIGURATION, path2, group1);
+ .child(Group.class, new GroupKey(group1.getGroupId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path2, group1, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
private void deleteGroup(final CommandInterpreter ci, Group group, Group group1) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(group.getGroupId())).build();
+ .child(Group.class, new GroupKey(group.getGroupId()));
modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
- InstanceIdentifier<Group> path2 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(group1.getGroupId())).build();
+ .child(Group.class, new GroupKey(group1.getGroupId()));
modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static NodeRef createNodeRef(String string) {
NodeKey key = new NodeKey(new NodeId(string));
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
- .toInstance();
+ InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
return new NodeRef(path);
}
}
private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
public void _modifyFlows(CommandInterpreter ci) {
break;
}
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+ 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()).build();
+ .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.builder(Nodes.class).child(Node.class, tn.getKey())
+ 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()).build();
+ .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.builder(Nodes.class).child(Node.class, tn.getKey())
+ 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()).build();
+ .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.builder(Nodes.class).child(Node.class, tn.getKey())
+ 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()).build();
+ .child(Flow.class, tf3.getKey());
modification.delete(LogicalDatastoreType.OPERATIONAL, path4);
modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, FlowBuilder flow1, FlowBuilder flow2,
FlowBuilder flow3, NodeBuilder nodeBuilder) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
+ 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()).build();
- modification.put(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.OPERATIONAL, path1, flow.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
- InstanceIdentifier<Flow> path2 = InstanceIdentifier.builder(Nodes.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()).build();
- modification.put(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.OPERATIONAL, path2, flow1.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path2, flow1.build());
+ .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.builder(Nodes.class)
+ 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()).build();
- modification.put(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.OPERATIONAL, path3, flow2.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path3, flow2.build());
+ .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.builder(Nodes.class)
+ 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()).build();
- modification.put(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.OPERATIONAL, path4, flow3.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path4, flow3.build());
+ .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
}
private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
private GroupBuilder createTestGroup(String actiontype, String type, String mod) {
}
GroupBuilder gbuilder = createTestGroup(ci.nextArgument(), ci.nextArgument(), "add");
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
- .augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(gbuilder.getGroupId())).build();
+ InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey())
+ .augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(gbuilder.getGroupId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
private void writeGroup(final CommandInterpreter ci, Group group) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Group> path1 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Group.class, new GroupKey(group.getGroupId()))
- .build();
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, group);
+ .child(Group.class, new GroupKey(group.getGroupId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
private static NodeRef createNodeRef(String string) {
NodeKey key = new NodeKey(new NodeId(string));
InstanceIdentifier<Node> path =
- InstanceIdentifier.builder(Nodes.class).child(Node.class, key).toInstance();
+ InstanceIdentifier.create(Nodes.class).child(Node.class, key);
return new NodeRef(path);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
}
private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
final class MeterEventListener implements SalMeterListener {
}
MeterBuilder mBuilder = createTestMeter();
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId())).build();
+ InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey())
+ .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
switch (count) {
case 1:
MeterBuilder mBuilder = createTestMeters("1", "remove");
- InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
MeterBuilder mBuilder1 = createTestMeters("2", "remove");
- InstanceIdentifier<Meter> path2 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
break;
case 2:
MeterBuilder mBuilder2 = createTestMeters("3", "remove");
- InstanceIdentifier<Meter> path3 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path3 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
MeterBuilder mBuilder22 = createTestMeters("4", "remove");
- InstanceIdentifier<Meter> path4 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path4 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
break;
case 3:
MeterBuilder mBuilder3 = createTestMeters("5", "remove");
- InstanceIdentifier<Meter> path5 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path5 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path5);
MeterBuilder mBuilder4 = createTestMeters("6", "remove");
- InstanceIdentifier<Meter> path6 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path6 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path6);
break;
case 4:
MeterBuilder mBuilder5 = createTestMeters("7", "remove");
- InstanceIdentifier<Meter> path7 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path7 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter1.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path7);
MeterBuilder mBuilder6 = createTestMeters("8", "remove");
- InstanceIdentifier<Meter> path8 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Meter> path8 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class)
- .child(Meter.class, new MeterKey(testMeter2.getMeterId())).build();
+ .child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path8);
break;
private void writeMeter(final CommandInterpreter ci, Meter meter) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())).build();
- DataObject cls = (DataObject) modification.read(LogicalDatastoreType.CONFIGURATION, path1);
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, meter);
+ InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey())
+ .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
private void writeMeter(final CommandInterpreter ci, Meter meter, Meter meter1) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Meter> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())).build();
- DataObject cls = (DataObject) modification.read(LogicalDatastoreType.CONFIGURATION, path1);
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, meter);
- InstanceIdentifier<Meter> path2 = InstanceIdentifier.builder(Nodes.class).child(Node.class, testNode.getKey())
- .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId())).build();
- DataObject cls1 = (DataObject) modification.read(LogicalDatastoreType.CONFIGURATION, path2);
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.CONFIGURATION, path2, meter1);
+ InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey())
+ .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
+ InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey())
+ .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId()));
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<Node> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).toInstance();
+ InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- Node node = (Node) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<NodeConnector> ports = node.getNodeConnector();
- for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
- nodeConnectorCount++;
- NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
- InstanceIdentifier<NodeConnector> connectorRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).toInstance();
- NodeConnector nodeConnector = (NodeConnector) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, connectorRef);
- FlowCapableNodeConnectorStatisticsData data = nodeConnector.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
- if (null != data) {
- nodeConnectorStatsCount++;
+ Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<NodeConnector> ports = node.getNodeConnector();
+ for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
+ nodeConnectorCount++;
+ NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
+ InstanceIdentifier<NodeConnector> connectorRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey);
+ NodeConnector nodeConnector = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, connectorRef);
+ if (nodeConnector != null) {
+ FlowCapableNodeConnectorStatisticsData data = nodeConnector.getAugmentation(FlowCapableNodeConnectorStatisticsData.class);
+ if (null != data) {
+ nodeConnectorStatsCount++;
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<Node> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).toInstance();
+ InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- Node node = (Node) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<NodeConnector> ports = node.getNodeConnector();
- for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
- nodeConnectorCount++;
- NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
- InstanceIdentifier<FlowCapableNodeConnector> connectorRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).augmentation(FlowCapableNodeConnector.class).toInstance();
- FlowCapableNodeConnector nodeConnector = (FlowCapableNodeConnector) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, connectorRef);
- if (null != nodeConnector.getName() &&
- null != nodeConnector.getCurrentFeature() &&
- null != nodeConnector.getState() &&
- null != nodeConnector.getHardwareAddress() &&
- null != nodeConnector.getPortNumber()) {
- nodeConnectorDescStatsCount++;
+ Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<NodeConnector> ports = node.getNodeConnector();
+ for (Iterator<NodeConnector> iterator2 = ports.iterator(); iterator2.hasNext(); ) {
+ nodeConnectorCount++;
+ NodeConnectorKey nodeConnectorKey = iterator2.next().getKey();
+ InstanceIdentifier<FlowCapableNodeConnector> connectorRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).child(NodeConnector.class, nodeConnectorKey).augmentation(FlowCapableNodeConnector.class);
+ FlowCapableNodeConnector nodeConnector = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, connectorRef);
+ if (nodeConnector != null) {
+ if (null != nodeConnector.getName() &&
+ null != nodeConnector.getCurrentFeature() &&
+ null != nodeConnector.getState() &&
+ null != nodeConnector.getHardwareAddress() &&
+ null != nodeConnector.getPortNumber()) {
+ nodeConnectorDescStatsCount++;
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Table> tables = node.getTable();
- for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
- TableKey tableKey = iterator2.next().getKey();
- InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
- Table table = (Table) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, tableRef);
- List<Flow> flows = table.getFlow();
- for (Iterator<Flow> iterator3 = flows.iterator(); iterator3.hasNext(); ) {
- flowCount++;
- FlowKey flowKey = iterator3.next().getKey();
- InstanceIdentifier<Flow> flowRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey).toInstance();
- Flow flow = (Flow) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, flowRef);
- FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
- if (null != data) {
- flowStatsCount++;
- LOG.debug("--------------------------------------------");
- ci.print(data);
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+
+ if (node != null) {
+ List<Table> tables = node.getTable();
+ for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
+ TableKey tableKey = iterator2.next().getKey();
+ InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+ if (table != null) {
+ List<Flow> flows = table.getFlow();
+ for (Iterator<Flow> iterator3 = flows.iterator(); iterator3.hasNext(); ) {
+ flowCount++;
+ FlowKey flowKey = iterator3.next().getKey();
+ InstanceIdentifier<Flow> flowRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
+ Flow flow = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, flowRef);
+ if (flow != null) {
+ FlowStatisticsData data = flow.getAugmentation(FlowStatisticsData.class);
+ if (null != data) {
+ flowStatsCount++;
+ LOG.debug("--------------------------------------------");
+ ci.print(data);
+ }
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Table> tables = node.getTable();
- for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
- tableCount++;
- TableKey tableKey = iterator2.next().getKey();
- InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
- Table table = (Table) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, tableRef);
- FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
- if (null != data) {
- tableStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<Table> tables = node.getTable();
+ for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
+ tableCount++;
+ TableKey tableKey = iterator2.next().getKey();
+ InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+ if (table != null) {
+ FlowTableStatisticsData data = table.getAugmentation(FlowTableStatisticsData.class);
+ if (null != data) {
+ tableStatsCount++;
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Group> groups = node.getGroup();
- for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext(); ) {
- groupCount++;
- GroupKey groupKey = iterator2.next().getKey();
- InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
- Group group = (Group) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, groupRef);
- data = group.getAugmentation(NodeGroupStatistics.class);
- if (null != data) {
- groupStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<Group> groups = node.getGroup();
+ for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext(); ) {
+ groupCount++;
+ GroupKey groupKey = iterator2.next().getKey();
+ InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
+ if (group != null) {
+ data = group.getAugmentation(NodeGroupStatistics.class);
+ if (null != data) {
+ groupStatsCount++;
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Group> groups = node.getGroup();
- for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext(); ) {
- groupCount++;
- GroupKey groupKey = iterator2.next().getKey();
- InstanceIdentifier<Group> groupRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey).toInstance();
- Group group = (Group) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, groupRef);
- data = group.getAugmentation(NodeGroupDescStats.class);
- if (null != data) {
- groupDescStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+
+ if (node != null) {
+ List<Group> groups = node.getGroup();
+ for (Iterator<Group> iterator2 = groups.iterator(); iterator2.hasNext(); ) {
+ groupCount++;
+ GroupKey groupKey = iterator2.next().getKey();
+ InstanceIdentifier<Group> groupRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
+ Group group = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, groupRef);
+ if (group != null) {
+ data = group.getAugmentation(NodeGroupDescStats.class);
+ if (null != data) {
+ groupDescStatsCount++;
+ }
+ }
}
}
- }
- if (groupCount == groupDescStatsCount) {
- LOG.debug("---------------------groupDescStats - Success-------------------------------");
- } else {
- LOG.debug("------------------------------groupDescStats - Failed--------------------------");
- LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ if (groupCount == groupDescStatsCount) {
+ LOG.debug("---------------------groupDescStats - Success-------------------------------");
+ } else {
+ LOG.debug("------------------------------groupDescStats - Failed--------------------------");
+ LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ }
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Meter> meters = node.getMeter();
- for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext(); ) {
- meterCount++;
- MeterKey meterKey = iterator2.next().getKey();
- InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
- Meter meter = (Meter) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, meterRef);
- data = meter.getAugmentation(NodeMeterStatistics.class);
- if (null != data) {
- meterStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<Meter> meters = node.getMeter();
+ for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext(); ) {
+ meterCount++;
+ MeterKey meterKey = iterator2.next().getKey();
+ InstanceIdentifier<Meter> meterRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ Meter meter = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, meterRef);
+ if (meter != null) {
+ data = meter.getAugmentation(NodeMeterStatistics.class);
+ if (null != data) {
+ meterStatsCount++;
+ }
+ }
}
}
}
}
}
+
public void _meterConfigStats(CommandInterpreter ci) {
int meterCount = 0;
int meterConfigStatsCount = 0;
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Meter> meters = node.getMeter();
- for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext(); ) {
- meterCount++;
- MeterKey meterKey = iterator2.next().getKey();
- InstanceIdentifier<Meter> meterRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey).toInstance();
- Meter meter = (Meter) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, meterRef);
- data = meter.getAugmentation(NodeMeterConfigStats.class);
- if (null != data) {
- meterConfigStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<Meter> meters = node.getMeter();
+ for (Iterator<Meter> iterator2 = meters.iterator(); iterator2.hasNext(); ) {
+ meterCount++;
+ MeterKey meterKey = iterator2.next().getKey();
+ InstanceIdentifier<Meter> meterRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
+ Meter meter = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, meterRef);
+ if (meter != null) {
+ data = meter.getAugmentation(NodeMeterConfigStats.class);
+ if (null != data) {
+ meterConfigStatsCount++;
+ }
+ }
}
}
}
List<Node> nodes = getNodes();
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
-
- List<Table> tables = node.getTable();
- for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
- aggregateFlowCount++;
- TableKey tableKey = iterator2.next().getKey();
- InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey).toInstance();
- Table table = (Table) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, tableRef);
- AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
- if (null != data) {
- aggerateFlowStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ List<Table> tables = node.getTable();
+ for (Iterator<Table> iterator2 = tables.iterator(); iterator2.hasNext(); ) {
+ aggregateFlowCount++;
+ TableKey tableKey = iterator2.next().getKey();
+ InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
+ Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
+ if (table != null) {
+ AggregateFlowStatisticsData data = table.getAugmentation(AggregateFlowStatisticsData.class);
+ if (null != data) {
+ aggerateFlowStatsCount++;
+ }
+ }
}
}
}
for (Iterator<Node> iterator = nodes.iterator(); iterator.hasNext(); ) {
descCount++;
NodeKey nodeKey = iterator.next().getKey();
- InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).toInstance();
+ InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class);
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- FlowCapableNode node = (FlowCapableNode) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodeRef);
- if (null != node.getHardware() &&
- null != node.getManufacturer() &&
- null != node.getSoftware()) {
- descStatsCount++;
+ FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
+ if (node != null) {
+ if (null != node.getHardware() &&
+ null != node.getManufacturer() &&
+ null != node.getSoftware()) {
+ descStatsCount++;
+ }
}
}
LOG.debug("descStats - Success");
} else {
LOG.debug("descStats - Failed");
- LOG.debug("System fetchs stats data in 50 seconds interval, so pls wait and try again.");
+ LOG.debug("System fetches stats data in 50 seconds interval, so please wait and try again.");
}
}
private List<Node> getNodes() {
ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
- Nodes nodes = (Nodes) readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(Nodes.class).toInstance());
- if (null == nodes) {
+ InstanceIdentifier<Nodes> nodesID = InstanceIdentifier.create(Nodes.class);
+ Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID);
+ if (nodes == null) {
throw new RuntimeException("nodes are not found, pls add the node.");
}
return nodes.getNode();
-
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.osgi.framework.BundleContext;
}
private InstanceIdentifier<Node> nodeToInstanceId(Node node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
private TableBuilder createTestTable(String tableFeatureTypeArg) {
private void writeTable(final CommandInterpreter ci, Table table) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Table> path1 = InstanceIdentifier.builder(Nodes.class)
+ InstanceIdentifier<Table> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).
- child(Table.class, new TableKey(table.getId())).build();
+ child(Table.class, new TableKey(table.getId()));
- modification.put(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.OPERATIONAL, path1, table);
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode);
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, table);
+ modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.OPERATIONAL, path1, table, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, table, true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
- return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
} else {
tf = createTestFlow(tn, flowtype, ci.nextArgument());
}
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
+ 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()).build();
+ .child(Flow.class, tf.getKey());
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
* @param ci arguments: switchId flowType tableNum
* <p/>
* <pre>
- * e.g.: addMDFlow openflow:1 f1 42
- * </pre>
+ * e.g.: addMDFlow openflow:1 f1 42
+ * </pre>
*/
public void _addMDFlow(CommandInterpreter ci) {
NodeBuilder tn = createTestNode(ci.nextArgument());
private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
+ 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()).build();
- modification.put(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
- modification.put(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
+ .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
+ modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
private static NodeRef createNodeRef(String string) {
NodeKey key = new NodeKey(new NodeId(string));
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
- .toInstance();
+ InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
return new NodeRef(path);
}
--- /dev/null
+package org.opendaylight.openflowplugin.test;
+
+import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Created by Martin Bobak mbobak@cisco.com on 8/20/14.
+ */
+public final class TestProviderTransactionUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestProviderTransactionUtil.class);
+
+ private TestProviderTransactionUtil() {
+ throw new AssertionError("TestProviderTransactionUtil was not meant to be instantiated.");
+ }
+
+ public static <T extends DataObject> T getDataObject(ReadTransaction readOnlyTransaction, InstanceIdentifier<T> identifier) {
+ Optional<T> optionalData = null;
+ try {
+ optionalData = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, identifier).get();
+ if (optionalData.isPresent()) {
+ return optionalData.get();
+ }
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("Read transaction for identifier {} failed.", identifier, e);
+ }
+ return null;
+ }
+
+}