Search in sources :

Example 21 with QName

use of org.opendaylight.yangtools.yang.common.QName in project bgpcep by opendaylight.

the class RemoteNodeDescriptorTlvParser method parseTlvBody.

@Override
public RemoteNodeDescriptors parseTlvBody(final ByteBuf value) {
    final Map<QName, Object> parsedSubTlvs = new HashMap<>();
    final RemoteNodeDescriptorsBuilder builder = new RemoteNodeDescriptorsBuilder(parseNodeDescriptor(value, parsedSubTlvs));
    builder.setBgpRouterId((Ipv4Address) parsedSubTlvs.get(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME));
    builder.setMemberAsn((AsNumber) parsedSubTlvs.get(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME));
    return builder.build();
}
Also used : HashMap(java.util.HashMap) QName(org.opendaylight.yangtools.yang.common.QName) RemoteNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.RemoteNodeDescriptorsBuilder)

Example 22 with QName

use of org.opendaylight.yangtools.yang.common.QName in project bgpcep by opendaylight.

the class AbstractLocalNodeDescriptorTlvCodec method parseTlvBody.

@Override
public final LocalNodeDescriptors parseTlvBody(final ByteBuf value) {
    final Map<QName, Object> parsedSubTlvs = new HashMap<>();
    final LocalNodeDescriptorsBuilder builder = new LocalNodeDescriptorsBuilder(parseNodeDescriptor(value, parsedSubTlvs));
    builder.setBgpRouterId((Ipv4Address) parsedSubTlvs.get(BgpRouterIdTlvParser.BGP_ROUTER_ID_QNAME));
    builder.setMemberAsn((AsNumber) parsedSubTlvs.get(MemAsNumTlvParser.MEMBER_AS_NUMBER_QNAME));
    return builder.build();
}
Also used : LocalNodeDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LocalNodeDescriptorsBuilder) HashMap(java.util.HashMap) QName(org.opendaylight.yangtools.yang.common.QName)

Example 23 with QName

use of org.opendaylight.yangtools.yang.common.QName in project bgpcep by opendaylight.

the class RIBImpl method startLocRib.

private synchronized void startLocRib(final TablesKey key) {
    LOG.debug("Creating LocRib table for {}", key);
    // create locRibWriter for each table
    final DOMDataWriteTransaction tx = this.domChain.newWriteOnlyTransaction();
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> table = ImmutableNodes.mapEntryBuilder();
    table.withNodeIdentifier(RibSupportUtils.toYangTablesKey(key));
    table.withChild(EMPTY_TABLE_ATTRIBUTES);
    final NodeIdentifierWithPredicates tableKey = RibSupportUtils.toYangTablesKey(key);
    final InstanceIdentifierBuilder tableId = YangInstanceIdentifier.builder(this.yangRibId.node(LocRib.QNAME).node(Tables.QNAME));
    tableId.nodeWithKey(tableKey.getNodeType(), tableKey.getKeyValues());
    for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
        table.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
    }
    final RIBSupportContext supportContext = this.ribContextRegistry.getRIBSupportContext(key);
    if (supportContext != null) {
        final ChoiceNode routes = supportContext.getRibSupport().emptyRoutes();
        table.withChild(routes);
        tx.put(LogicalDatastoreType.OPERATIONAL, tableId.build(), table.build());
        try {
            tx.submit().checkedGet();
        } catch (final TransactionCommitFailedException e1) {
            LOG.error("Failed to initiate LocRIB for key {}", key, e1);
        }
    } else {
        LOG.warn("There's no registered RIB Context for {}", key.getAfi());
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder) QName(org.opendaylight.yangtools.yang.common.QName) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 24 with QName

use of org.opendaylight.yangtools.yang.common.QName 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 25 with QName

use of org.opendaylight.yangtools.yang.common.QName in project bgpcep by opendaylight.

the class RibSupportUtilsTest method testYangKey.

@Test
public void testYangKey() {
    final NodeIdentifierWithPredicates p = RibSupportUtils.toYangKey(SupportedTables.QNAME, TABLE_KEY);
    final Map<QName, Object> m = p.getKeyValues();
    assertFalse(m.isEmpty());
    assertEquals(SupportedTables.QNAME, p.getNodeType());
    assertTrue(m.containsValue(BindingReflections.findQName(AFI)));
    assertTrue(m.containsValue(BindingReflections.findQName(SAFI)));
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) Test(org.junit.Test)

Aggregations

QName (org.opendaylight.yangtools.yang.common.QName)50 HashMap (java.util.HashMap)13 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)12 Test (org.junit.Test)10 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)9 HashSet (java.util.HashSet)7 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)6 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)5 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)5 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)5 Module (org.opendaylight.yangtools.yang.model.api.Module)5 ArrayList (java.util.ArrayList)4 AttributeIfc (org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc)4 UnknownSchemaNode (org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)4 Map (java.util.Map)3 JavaAttribute (org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute)3 NameConflictException (org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException)3 TypeProviderImpl (org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl)3 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)3