use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParserTest method testExtractFlowspecDestPrefix.
@Test
public void testExtractFlowspecDestPrefix() {
final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry = Builders.mapEntryBuilder();
entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.choiceBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID).withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.DEST_PREFIX_NID).withValue("102:304:500::/40").build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(new Ipv6Prefix("102:304:500::/40")).build());
final List<Flowspec> expectedValue = new ArrayList<>();
expectedValue.add(expectedFS.build());
assertEquals(expectedValue, this.FS_PARSER.extractFlowspec(entry.build()));
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.
the class AdjRibInWriter method createEmptyPeerStructure.
private YangInstanceIdentifier createEmptyPeerStructure(final PeerId newPeerId, final DOMDataWriteTransaction tx) {
final NodeIdentifierWithPredicates peerKey = IdentifierUtils.domPeerId(newPeerId);
final YangInstanceIdentifier newPeerPath = this.ribPath.node(Peer.QNAME).node(peerKey);
tx.put(LogicalDatastoreType.OPERATIONAL, newPeerPath, peerSkeleton(peerKey, newPeerId.getValue()));
LOG.debug("New peer {} structure installed.", newPeerPath);
return newPeerPath;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class DomListBuilder method buildInnerList.
private static MapNode buildInnerList(final int index, final int elements) {
CollectionNodeBuilder<MapEntryNode, MapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME);
final String itemStr = "Item-" + String.valueOf(index) + "-";
for (int i = 0; i < elements; i++) {
innerList.addChild(ImmutableNodes.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(InnerList.QNAME, IL_NAME, i)).withChild(ImmutableNodes.leafNode(IL_NAME, i)).withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i))).build());
}
return innerList.build();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class SimpletxDomDelete method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
long writeCnt = 0;
for (int l = 0; l < outerListElem; l++) {
YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
tx.delete(dsType, yid);
writeCnt++;
if (writeCnt == writesPerTx) {
try {
tx.submit().checkedGet();
txOk++;
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed: {}", e);
txError++;
}
tx = domDataBroker.newWriteOnlyTransaction();
writeCnt = 0;
}
}
if (writeCnt != 0) {
try {
tx.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed: {}", e);
}
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project controller by opendaylight.
the class SimpletxDomWrite method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
long writeCnt = 0;
for (MapEntryNode element : this.list) {
YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
if (oper == StartTestInput.Operation.PUT) {
tx.put(dsType, yid, element);
} else {
tx.merge(dsType, yid, element);
}
writeCnt++;
if (writeCnt == writesPerTx) {
try {
tx.submit().checkedGet();
txOk++;
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed", e);
txError++;
}
tx = domDataBroker.newWriteOnlyTransaction();
writeCnt = 0;
}
}
if (writeCnt != 0) {
try {
tx.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed", e);
}
}
}
Aggregations