use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class AbstractRIBSupportTest method createRoutes.
@SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
protected final Collection<MapEntryNode> createRoutes(final DataObject routes) {
Preconditions.checkArgument(routes.getImplementedInterface().equals(this.abstractRIBSupport.routesContainerClass()));
final InstanceIdentifier<DataObject> routesIId = routesIId();
final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNode = this.mappingService.toNormalizedNode(routesIId, routes);
final ContainerNode container = (ContainerNode) normalizedNode.getValue();
final NodeIdentifier routeNid = new NodeIdentifier(getRouteListQname());
return ((MapNode) container.getChild(routeNid).get()).getValue();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class SimpleEsiTypeRegistryTest method registryNullModelTest.
@Test(expected = IllegalArgumentException.class)
public void registryNullModelTest() {
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> noRegister = Builders.choiceBuilder();
noRegister.withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register").intern()));
assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(noRegister.build()));
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class LacpParserTest method parserTest.
@Test
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder().setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
this.parser.serializeEsi(lanAuto, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(lanAuto, acResult);
final ContainerNode cont = createContBuilder(new NodeIdentifier(LacpAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build()).addChild(createValueBuilder(PORT, PK_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(lanAuto, acmResult);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier 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.YangInstanceIdentifier.NodeIdentifier 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);
}
Aggregations