Search in sources :

Example 51 with NodeIdentifier

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();
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Map(java.util.Map) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 52 with NodeIdentifier

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()));
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) RouterIdParserTest(org.opendaylight.protocol.bgp.evpn.impl.esi.types.RouterIdParserTest) Test(org.junit.Test)

Example 53 with NodeIdentifier

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);
}
Also used : LacpAutoGeneratedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.lacp.auto.generated._case.LacpAutoGeneratedBuilder) LacpAutoGeneratedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.LacpAutoGeneratedCaseBuilder) LacpAutoGeneratedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.esi.LacpAutoGeneratedCase) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Esi(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.Esi) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 54 with NodeIdentifier

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;
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) HashSet(java.util.HashSet)

Example 55 with NodeIdentifier

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);
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Aggregations

NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)58 Test (org.junit.Test)34 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)29 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)12 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)11 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)11 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)10 DOMDataTreeWriteCursor (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor)8 ByteBuf (io.netty.buffer.ByteBuf)7 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)7 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)7 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)7 DOMDataTreeCursorAwareTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction)6 DOMDataTreeProducer (org.opendaylight.mdsal.dom.api.DOMDataTreeProducer)6 AbstractTest (org.opendaylight.controller.cluster.datastore.AbstractTest)5 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)5 BigInteger (java.math.BigInteger)4 ClientTransaction (org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction)4 DistributedShardRegistration (org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration)4 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)4