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();
}
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();
}
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());
}
}
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);
}
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)));
}
Aggregations