use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class SerializationUtils method deserializePathAndNode.
public static <T> void deserializePathAndNode(DataInput in, T instance, Applier<T> applier) {
try {
NormalizedNodeDataInput streamReader = streamReader(in);
NormalizedNode<?, ?> node = streamReader.readNormalizedNode();
YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
applier.apply(instance, path, node);
} catch (IOException e) {
throw new IllegalArgumentException("Error deserializing path and Node", e);
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method processDestination.
@Override
protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
if (destination != null) {
final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(NLRI_ROUTES_LIST);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(routeNid());
for (final UnkeyedListEntryNode e : ((UnkeyedListNode) routes).getValue()) {
final NodeIdentifierWithPredicates routeKey = createRouteKey(e);
function.apply(tx, base, routeKey, e, attributes);
}
} else {
LOG.warn("Routes {} are not a map", routes);
}
}
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AdjRibsInWriterTest method testTransform.
@Test
public void testTransform() {
this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, this.chain);
assertNotNull(this.writer);
final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(Rib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME, AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
this.writer.transform(new PeerId(this.peerIp), this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
verifyPeerSkeletonInsertedCorrectly(peerPath);
// verify supported tables were inserted for ipv4
Mockito.verify(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath.node(SupportedTables.QNAME).node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.any(NormalizedNode.class));
verifyUptodateSetToFalse(peerPath);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AbstractRIBSupportTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
AbstractRIBSupportTest.this.insertedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode<?, ?>) args[2]));
return args[1];
}).when(this.tx).put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
return args[1];
}).when(this.tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
this.deletedRoutes = new ArrayList<>();
this.insertedRoutes = new ArrayList<>();
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
this.moduleInfoBackedContext = ModuleInfoBackedContext.create();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project bgpcep by opendaylight.
the class AbstractRIBSupportTest method createNlriAdvertiseRoute.
protected final ContainerNode createNlriAdvertiseRoute(final DestinationType destReach) {
final MpReachNlri mpReach = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(destReach).build()).build();
final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> result = this.mappingService.toNormalizedNode(MP_REACH_IID, mpReach);
return (ContainerNode) result.getValue();
}
Aggregations