use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder in project bgpcep by opendaylight.
the class RouteMirroringMessageHandler method serializeTlvs.
protected void serializeTlvs(final Tlvs tlvs, final ByteBuf output) {
final ByteBuf tlvsBuffer = Unpooled.buffer();
if (tlvs.getMirrorInformationTlv() != null) {
serializeTlv(tlvs.getMirrorInformationTlv(), tlvsBuffer);
}
if (tlvs.getPduUpdateTlv() != null) {
getBgpMessageRegistry().serializeMessage(new UpdateBuilder(tlvs.getPduUpdateTlv()).build(), tlvsBuffer);
}
if (tlvs.getPduOpenTlv() != null) {
getBgpMessageRegistry().serializeMessage(new OpenBuilder(tlvs.getPduOpenTlv()).build(), tlvsBuffer);
}
output.writeBytes(tlvsBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder in project bgpcep by opendaylight.
the class PCEPStatefulPeerProposalTest method testSetPeerProposalWithEntityIdSuccess.
@Test
public void testSetPeerProposalWithEntityIdSuccess() throws Exception {
updateBuilder(() -> {
final var listeners = captor.getAllValues();
assertEquals(2, listeners.size());
// not entirely accurate, but works well enough
final var modPath = TOPOLOGY_IID.child(Node.class, new NodeKey(ServerSessionManager.createNodeId(ADDRESS.getAddress())));
final var dbverRoot = mock(DataObjectModification.class);
doReturn(LSP_DB_VERSION).when(dbverRoot).getDataAfter();
final var dbverMod = mock(DataTreeModification.class);
doReturn(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, modPath)).when(dbverMod).getRootPath();
doReturn(dbverRoot).when(dbverMod).getRootNode();
final var speakerRoot = mock(DataObjectModification.class);
doReturn(new PcepNodeSyncConfigBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build()).when(speakerRoot).getDataAfter();
final var speakerMod = mock(DataTreeModification.class);
doReturn(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, modPath)).when(speakerMod).getRootPath();
doReturn(speakerRoot).when(speakerMod).getRootNode();
for (DataTreeChangeListener<?> listener : listeners) {
if (listener instanceof SpeakerIdListener) {
listener.onDataTreeChanged(List.of(speakerMod));
} else if (listener instanceof LspDbVersionListener) {
listener.onDataTreeChanged(List.of(dbverMod));
}
}
});
final Tlvs3 aug = tlvsBuilder.augmentation(Tlvs3.class);
assertNotNull(aug);
assertEquals(LSP_DB_VERSION, aug.getLspDbVersion());
assertEquals(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build(), aug.getSpeakerEntityId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder in project bgpcep by opendaylight.
the class MultiPathAbstractRIBSupportTest method buildUpdate.
@Test
public void buildUpdate() {
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
final Attributes attr = new AttributesBuilder().setCNextHop(nextHop).build();
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, routes, attr));
routes.add(this.mapEntryNode);
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().build()).build();
final Attributes attMpR = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpR).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, Collections.emptySet(), attr));
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().build()).build();
final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpU).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(Collections.emptySet(), routes, attr));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder in project bgpcep by opendaylight.
the class RouteMonitoringMessageHandler method serializeMessageBody.
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
super.serializeMessageBody(message, buffer);
Preconditions.checkArgument(message instanceof RouteMonitoringMessage, "An instance of RouteMonitoringMessage is required");
final RouteMonitoringMessage routeMonitor = (RouteMonitoringMessage) message;
this.msgRegistry.serializeMessage(new UpdateBuilder(routeMonitor.getUpdate()).build(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder in project bgpcep by opendaylight.
the class PCEPStatefulPeerProposalTest method testSetPeerProposalSuccess.
@Test
public void testSetPeerProposalSuccess() throws Exception {
updateBuilder(() -> {
final var listeners = captor.getAllValues();
assertEquals(2, listeners.size());
// not entirely accurate, but works well enough
final var modPath = TOPOLOGY_IID.child(Node.class, new NodeKey(ServerSessionManager.createNodeId(ADDRESS.getAddress())));
final var dbverRoot = mock(DataObjectModification.class);
doReturn(LSP_DB_VERSION).when(dbverRoot).getDataAfter();
final var dbverMod = mock(DataTreeModification.class);
doReturn(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, modPath)).when(dbverMod).getRootPath();
doReturn(dbverRoot).when(dbverMod).getRootNode();
for (DataTreeChangeListener<?> listener : listeners) {
if (listener instanceof LspDbVersionListener) {
listener.onDataTreeChanged(List.of(dbverMod));
}
}
// Mock lspdb
});
assertEquals(new Tlvs3Builder().setLspDbVersion(LSP_DB_VERSION).build(), tlvsBuilder.augmentation(Tlvs3.class));
}
Aggregations