use of org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode in project bgpcep by opendaylight.
the class TableContext method createTable.
void createTable(final DOMDataWriteTransaction tx) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
tb.withNodeIdentifier((NodeIdentifierWithPredicates) this.tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
for (final Map.Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
final ChoiceNode routes = this.tableSupport.emptyRoutes();
Verify.verifyNotNull(routes, "Null empty routes in %s", this.tableSupport);
tx.put(LogicalDatastoreType.OPERATIONAL, this.tableId, tb.withChild(ImmutableChoiceNodeBuilder.create(routes).withNodeIdentifier(new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
use of org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecRIBSupport method buildWithdrawnDestination.
@Nonnull
@Override
protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
return this.nlriParser.createWithdrawnDestinationType(new Object[] { this.nlriParser.extractFlowspec(Iterables.getOnlyElement(routes)) }, pathId);
}
use of org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode in project bgpcep by opendaylight.
the class AbstractRIBTestSetup method ipv4Input.
public Collection<DataTreeCandidate> ipv4Input(final YangInstanceIdentifier target, final ModificationType type, final Ipv4Prefix... prefix) {
final Collection<DataTreeCandidate> col = new HashSet<>();
final DataTreeCandidate candidate = mock(DataTreeCandidate.class);
final DataTreeCandidateNode rootNode = mock(DataTreeCandidateNode.class);
doReturn(rootNode).when(candidate).getRootNode();
doReturn(type).when(rootNode).getModificationType();
doCallRealMethod().when(rootNode).toString();
doReturn(target).when(candidate).getRootPath();
doCallRealMethod().when(candidate).toString();
final Collection<DataTreeCandidateNode> children = new HashSet<>();
for (final Ipv4Prefix p : prefix) {
final NodeIdentifierWithPredicates routekey = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, PREFIX_QNAME, p);
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = ImmutableNodes.mapEntryBuilder();
b.withNodeIdentifier(routekey);
b.addChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(PREFIX_QNAME)).withValue(p).build());
final DataTreeCandidateNode child = mock(DataTreeCandidateNode.class);
doReturn(createIdentifier(p)).when(child).getIdentifier();
doReturn(java.util.Optional.of(b.build())).when(child).getDataAfter();
doReturn(type).when(child).getModificationType();
children.add(child);
}
doReturn(children).when(rootNode).getChildNodes();
col.add(candidate);
return col;
}
use of org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode in project bgpcep by opendaylight.
the class RIBImpl method instantiateServiceInstance.
public synchronized void instantiateServiceInstance() {
this.isServiceInstantiated = true;
setActive(true);
this.domChain = this.domDataBroker.createTransactionChain(this);
LOG.debug("Instantiating RIB table {} at {}", this.ribId, this.yangRibId);
final ContainerNode bgpRib = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BgpRib.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Rib.QNAME).build()).build();
final MapEntryNode ribInstance = Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Rib.QNAME, RIB_ID_QNAME, this.ribId.getValue())).addChild(ImmutableNodes.leafNode(RIB_ID_QNAME, this.ribId.getValue())).addChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).addChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(LocRib.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Tables.QNAME).build()).build()).build();
final DOMDataWriteTransaction trans = this.domChain.newWriteOnlyTransaction();
// merge empty BgpRib + Rib, to make sure the top-level parent structure is present
trans.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().node(BgpRib.QNAME).build(), bgpRib);
trans.put(LogicalDatastoreType.OPERATIONAL, this.yangRibId, ribInstance);
try {
trans.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Failed to initiate RIB {}", this.yangRibId, e);
}
LOG.debug("Effective RIB created.");
this.localTablesKeys.forEach(this::startLocRib);
this.localTablesKeys.forEach(this::createLocRibWriter);
}
use of org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode in project bgpcep by opendaylight.
the class RIBSupportContextImpl method createEmptyTableStructure.
@Override
public void createEmptyTableStructure(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
tb.withNodeIdentifier((NodeIdentifierWithPredicates) tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) tableId.getLastPathArgument();
for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
final ChoiceNode routes = this.ribSupport.emptyRoutes();
Verify.verifyNotNull(routes, "Null empty routes in %s", this.ribSupport);
Verify.verify(Routes.QNAME.equals(routes.getNodeType()), "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
}
Aggregations