Search in sources :

Example 16 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class LinkstateRIBSupportTest method testRoutePath.

@Test
public void testRoutePath() {
    final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
    Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
Also used : NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Example 17 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class BmpRouterPeerImpl method createPeerEntry.

private MapEntryNode createPeerEntry(final PeerUpNotification peerUp) {
    final PeerHeader peerHeader = peerUp.getPeerHeader();
    final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME, peerHeader.getType().name().toLowerCase(Locale.ENGLISH))).withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME, getStringIpAddress(peerHeader.getAddress()))).withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue())).withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue())).withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec())).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build()).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
    final PeerDistinguisher pd = peerHeader.getPeerDistinguisher();
    if (pd != null) {
        mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, pd.getRouteDistinguisher()));
    }
    return mapEntryBuilder.build();
}
Also used : PeerHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.header.PeerHeader) 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) PeerDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.Peer.PeerDistinguisher)

Example 18 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class TablesUtil method toYangTablesKey.

/**
 * Creates Yang Instance Identifier path argument from supplied QNAMES and AFI and SAFI.
 *
 * @param nodeName QName reprenting node
 * @param afi Class representing AFI
 * @param safi Class representing SAFI
 * @return NodeIdentifierWithPredicates for specified AFI, SAFI combination.
 */
public static NodeIdentifierWithPredicates toYangTablesKey(final QName nodeName, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
    final QName afiQname = QName.create(nodeName, "afi").intern();
    final QName safiQname = QName.create(nodeName, "safi").intern();
    final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(afiQname, BindingReflections.findQName(afi), safiQname, BindingReflections.findQName(safi));
    return new NodeIdentifierWithPredicates(nodeName, keyValues);
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 19 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class BmpRibInWriter method createTableInstance.

/**
 * Create new table instance.
 */
private static ImmutableMap.Builder<TablesKey, TableContext> createTableInstance(final Set<TablesKey> tableTypes, final YangInstanceIdentifier yangTableRootIId, final DOMDataWriteTransaction tx, final RIBExtensionConsumerContext ribExtensions, final BindingCodecTree tree) {
    final ImmutableMap.Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
    for (final TablesKey k : tableTypes) {
        final RIBSupport rs = ribExtensions.getRIBSupport(k);
        if (rs == null) {
            LOG.warn("No support for table type {}, skipping it", k);
            continue;
        }
        final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(yangTableRootIId);
        final NodeIdentifierWithPredicates key = TablesUtil.toYangTablesKey(k);
        idb.nodeWithKey(key.getNodeType(), key.getKeyValues());
        final TableContext ctx = new TableContext(rs, idb.build(), tree);
        ctx.createTable(tx);
        tx.put(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(BMP_ATTRIBUTES_QNAME).node(ATTRIBUTES_UPTODATE_FALSE.getNodeType()), ATTRIBUTES_UPTODATE_FALSE);
        LOG.debug("Created table instance {}", ctx.getTableId());
        tb.put(k, ctx);
    }
    return tb;
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 20 with NodeIdentifierWithPredicates

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates in project bgpcep by opendaylight.

the class IdentifierUtilsTest method testDomPeerId.

@Test
public void testDomPeerId() throws Exception {
    final NodeIdentifierWithPredicates result = IdentifierUtils.domPeerId(PEER_ID);
    assertEquals(NIWP_PEER, result);
}
Also used : NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) Test(org.junit.Test)

Aggregations

NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)97 Test (org.junit.Test)52 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)49 ArrayList (java.util.ArrayList)37 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)34 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)34 NumericOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand)20 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)20 QName (org.opendaylight.yangtools.yang.common.QName)15 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv4.DestinationFlowspecBuilder)12 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)11 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)9 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)7 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)6 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.BitmaskOperand)6 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)5 DestinationFlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.ipv6.DestinationFlowspecBuilder)5