use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs in project bgpcep by opendaylight.
the class SyncOptimizationTest method testIsDbVersionPresentNegative.
@Test
public void testIsDbVersionPresentNegative() {
final Tlvs tlvs = createTlvs(null, true, false);
Mockito.doReturn(tlvs).when(this.pcepSession).getLocalTlvs();
Mockito.doReturn(tlvs).when(this.pcepSession).getRemoteTlvs();
final SyncOptimization syncOpt = new SyncOptimization(this.pcepSession);
assertFalse(syncOpt.isDbVersionPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspaObject.
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final LspaBuilder builder = new LspaBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName(new byte[] { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d, (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65 })).build();
builder.setIgnore(false);
builder.setProcessingRule(false);
builder.setExcludeAny(new AttributeFilter(0x20A1FEE3L));
builder.setIncludeAny(new AttributeFilter(0x1A025CC7L));
builder.setIncludeAll(new AttributeFilter(0x2BB66532L));
builder.setHoldPriority((short) 0x02);
builder.setSetupPriority((short) 0x03);
builder.setLocalProtectionDesired(true);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().addAugmentation(Tlvs2.class, new Tlvs2Builder().setSymbolicPathName(tlv).build()).build());
// Tlvs container does not contain toString
final Object o = parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4));
assertEquals(tlv, ((Lspa) o).getTlvs().getAugmentation(Tlvs2.class).getSymbolicPathName());
// assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
// 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validateLsp.
private static boolean validateLsp(final Object object, final boolean lspViaSR, final List<Message> errors, final ReportsBuilder builder) {
if (object instanceof Lsp) {
final Lsp lsp = (Lsp) object;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
if (!lspViaSR && lsp.getPlspId().getValue() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.absent());
errors.add(errorMsg);
return false;
}
builder.setLsp(lsp);
return true;
}
errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.absent()));
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs in project bgpcep by opendaylight.
the class BmpMonitorImplTest method testMonitoringStation.
private Channel testMonitoringStation(final String remoteRouterIpAddr) throws InterruptedException, ReadFailedException {
final Channel channel = connectTestClient(remoteRouterIpAddr, this.msgRegistry);
final RouterId routerId = getRouterId(remoteRouterIpAddr);
readDataOperational(getDataBroker(), MONITOR_IID, monitor -> {
assertFalse(monitor.getRouter().isEmpty());
// now find the current router instance
Router router = null;
for (final Router r : monitor.getRouter()) {
if (routerId.equals(r.getRouterId())) {
router = r;
break;
}
}
assertNotNull(router);
assertEquals(Status.Down, router.getStatus());
assertTrue(router.getPeer().isEmpty());
return router;
});
waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createInitMsg("description", "name", "some info")));
readDataOperational(getDataBroker(), MONITOR_IID, monitor -> {
assertFalse(monitor.getRouter().isEmpty());
Router retRouter = null;
for (final Router r : monitor.getRouter()) {
if (routerId.equals(r.getRouterId())) {
retRouter = r;
break;
}
}
assertEquals("some info;", retRouter.getInfo());
assertEquals("name", retRouter.getName());
assertEquals("description", retRouter.getDescription());
assertEquals(routerId, retRouter.getRouterId());
assertTrue(retRouter.getPeer().isEmpty());
assertEquals(Status.Up, retRouter.getStatus());
return retRouter;
});
waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createPeerUpNotification(PEER1, true)));
final KeyedInstanceIdentifier<Router, RouterKey> routerIId = MONITOR_IID.child(Router.class, new RouterKey(routerId));
readDataOperational(getDataBroker(), routerIId, router -> {
final List<Peer> peers = router.getPeer();
assertEquals(1, peers.size());
final Peer peer = peers.get(0);
assertEquals(PeerType.Global, peer.getType());
assertEquals(PEER_ID, peer.getPeerId());
assertEquals(PEER1, peer.getBgpId());
assertEquals(TestUtil.IPV4_ADDRESS_10, peer.getAddress().getIpv4Address());
assertEquals(TestUtil.PEER_AS, peer.getAs());
assertNull(peer.getPeerDistinguisher());
assertNull(peer.getStats());
assertNotNull(peer.getPrePolicyRib());
assertEquals(1, peer.getPrePolicyRib().getTables().size());
final Tables prePolicyTable = peer.getPrePolicyRib().getTables().get(0);
assertEquals(Ipv4AddressFamily.class, prePolicyTable.getAfi());
assertEquals(UnicastSubsequentAddressFamily.class, prePolicyTable.getSafi());
assertFalse(prePolicyTable.getAttributes().isUptodate());
assertNotNull(prePolicyTable.getRoutes());
assertNotNull(peer.getPostPolicyRib());
assertEquals(1, peer.getPostPolicyRib().getTables().size());
final Tables postPolicyTable = peer.getPrePolicyRib().getTables().get(0);
assertEquals(Ipv4AddressFamily.class, postPolicyTable.getAfi());
assertEquals(UnicastSubsequentAddressFamily.class, postPolicyTable.getSafi());
assertFalse(postPolicyTable.getAttributes().isUptodate());
assertNotNull(postPolicyTable.getRoutes());
assertNotNull(peer.getPeerSession());
final PeerSession peerSession = peer.getPeerSession();
assertEquals(TestUtil.IPV4_ADDRESS_10, peerSession.getLocalAddress().getIpv4Address());
assertEquals(TestUtil.PEER_LOCAL_PORT, peerSession.getLocalPort());
assertEquals(TestUtil.PEER_REMOTE_PORT, peerSession.getRemotePort());
assertEquals(Status.Up, peerSession.getStatus());
assertNotNull(peerSession.getReceivedOpen());
assertNotNull(peerSession.getSentOpen());
return router;
});
final StatsReportsMessage statsMsg = TestUtil.createStatsReportMsg(PEER1);
waitWriteAndFlushSuccess(channel.writeAndFlush(statsMsg));
final KeyedInstanceIdentifier<Peer, PeerKey> peerIId = routerIId.child(Peer.class, new PeerKey(PEER_ID));
readDataOperational(getDataBroker(), peerIId.child(Stats.class), peerStats -> {
assertNotNull(peerStats.getTimestampSec());
final Tlvs tlvs = statsMsg.getTlvs();
assertEquals(tlvs.getAdjRibsInRoutesTlv().getCount(), peerStats.getAdjRibsInRoutes());
assertEquals(tlvs.getDuplicatePrefixAdvertisementsTlv().getCount(), peerStats.getDuplicatePrefixAdvertisements());
assertEquals(tlvs.getDuplicateWithdrawsTlv().getCount(), peerStats.getDuplicateWithdraws());
assertEquals(tlvs.getInvalidatedAsConfedLoopTlv().getCount(), peerStats.getInvalidatedAsConfedLoop());
assertEquals(tlvs.getInvalidatedAsPathLoopTlv().getCount(), peerStats.getInvalidatedAsPathLoop());
assertEquals(tlvs.getInvalidatedClusterListLoopTlv().getCount(), peerStats.getInvalidatedClusterListLoop());
assertEquals(tlvs.getInvalidatedOriginatorIdTlv().getCount(), peerStats.getInvalidatedOriginatorId());
assertEquals(tlvs.getLocRibRoutesTlv().getCount(), peerStats.getLocRibRoutes());
assertEquals(tlvs.getRejectedPrefixesTlv().getCount(), peerStats.getRejectedPrefixes());
assertEquals(tlvs.getPerAfiSafiAdjRibInTlv().getCount().toString(), peerStats.getPerAfiSafiAdjRibInRoutes().getAfiSafi().get(0).getCount().toString());
assertEquals(tlvs.getPerAfiSafiLocRibTlv().getCount().toString(), peerStats.getPerAfiSafiLocRibRoutes().getAfiSafi().get(0).getCount().toString());
return peerStats;
});
// route mirror message test
final RouteMirroringMessage routeMirrorMsg = TestUtil.createRouteMirrorMsg(PEER1);
waitWriteAndFlushSuccess(channel.writeAndFlush(routeMirrorMsg));
readDataOperational(getDataBroker(), peerIId.child(Mirrors.class), routeMirrors -> {
assertNotNull(routeMirrors.getTimestampSec());
return routeMirrors;
});
waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonitMsg(false, PEER1, AdjRibInType.PrePolicy)));
waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonMsgWithEndOfRibMarker(PEER1, AdjRibInType.PrePolicy)));
readDataOperational(getDataBroker(), peerIId.child(PrePolicyRib.class), prePolicyRib -> {
assertTrue(!prePolicyRib.getTables().isEmpty());
final Tables tables = prePolicyRib.getTables().get(0);
assertTrue(tables.getAttributes().isUptodate());
assertEquals(3, ((Ipv4RoutesCase) tables.getRoutes()).getIpv4Routes().getIpv4Route().size());
return tables;
});
waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonitMsg(false, PEER1, AdjRibInType.PostPolicy)));
waitWriteAndFlushSuccess(channel.writeAndFlush(createRouteMonMsgWithEndOfRibMarker(PEER1, AdjRibInType.PostPolicy)));
readDataOperational(getDataBroker(), peerIId.child(PostPolicyRib.class), postPolicyRib -> {
assertTrue(!postPolicyRib.getTables().isEmpty());
final Tables tables = postPolicyRib.getTables().get(0);
assertTrue(tables.getAttributes().isUptodate());
assertEquals(3, ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.bmp.monitor.monitor.router.peer.post.policy.rib.tables.routes.Ipv4RoutesCase) tables.getRoutes()).getIpv4Routes().getIpv4Route().size());
return tables;
});
waitWriteAndFlushSuccess(channel.writeAndFlush(TestUtil.createPeerDownNotification(PEER1)));
readDataOperational(getDataBroker(), routerIId, router -> {
final List<Peer> peersAfterDown = router.getPeer();
assertTrue(peersAfterDown.isEmpty());
return router;
});
return channel;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method createStats.
private static ContainerNode createStats(final Stat stat, final Timestamp timestamp) {
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME));
builder.withChild(ImmutableNodes.leafNode(PEER_STATS_TIMESTAMP_QNAME, timestamp.getValue()));
final Tlvs tlvs = stat.getTlvs();
if (tlvs != null) {
statsForTlvs(tlvs, builder);
}
return builder.build();
}
Aggregations