Search in sources :

Example 16 with Tlvs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs in project bgpcep by opendaylight.

the class PCCTunnelManagerImpl method sendEndOfSynchronization.

private void sendEndOfSynchronization(final PCCSession session, final Optional<SrpIdNumber> operationId) {
    Srp srp = null;
    if (operationId.isPresent()) {
        srp = new SrpBuilder().setOperationId(operationId.get()).build();
    }
    Optional<Tlvs> tlv = Optional.absent();
    if (this.syncOptimization.isSyncAvoidanceEnabled()) {
        tlv = createLspTlvsEndofSync(this.syncOptimization.incrementLspDBVersion().get());
    }
    final Pcrpt pcrtp = createPcRtpMessage(createLsp(0, false, tlv, true, false), Optional.fromNullable(srp), createPath(Collections.emptyList()));
    session.sendReport(pcrtp);
}
Also used : MsgBuilderUtil.createSrp(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createSrp) Srp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.Srp) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) SrpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)

Example 17 with Tlvs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs in project bgpcep by opendaylight.

the class PCCTunnelManagerImpl method takeDelegation.

protected void takeDelegation(final Requests request, final PCCSession session) {
    final PlspId plspId = request.getLsp().getPlspId();
    final PCCTunnel tunnel = this.tunnels.get(plspId);
    final long srpId = request.getSrp().getOperationId().getValue();
    if (tunnel != null) {
        // check if tunnel has no delegation
        if ((tunnel.getType() == LspType.PCE_LSP) && ((tunnel.getDelegationHolder() == -1) || (tunnel.getDelegationHolder() == session.getId()))) {
            // set delegation
            tunnel.cancelTimeouts();
            setDelegation(plspId, session);
            // send report
            final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
            session.sendReport(createPcRtpMessage(new LspBuilder(request.getLsp()).setSync(true).setOperational(OperationalStatus.Up).setDelegate(true).setTlvs(tlvs).build(), Optional.of(createSrp(srpId)), tunnel.getLspState()));
        } else {
            session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.LSP_NOT_PCE_INITIATED, srpId));
        }
    } else {
        session.sendError(MsgBuilderUtil.createErrorMsg(PCEPErrors.UNKNOWN_PLSP_ID, srpId));
    }
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Example 18 with Tlvs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs in project bgpcep by opendaylight.

the class PcepOpenObjectWithSpcTlvParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
    if (tbuilder.getAugmentation(Tlvs1.class) != null) {
        final Tlvs1 tlvs = tbuilder.getAugmentation(Tlvs1.class);
        if (tlvs.getSrPceCapability() != null) {
            tlvBuilder.setSrPceCapability(tlvs.getSrPceCapability());
        }
    }
    if (tlv instanceof SrPceCapability) {
        tlvBuilder.setSrPceCapability((SrPceCapability) tlv);
    }
    tbuilder.addAugmentation(Tlvs1.class, tlvBuilder.build());
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.sr.pce.capability.tlv.SrPceCapability) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.Tlvs1)

Example 19 with Tlvs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.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;
}
Also used : MockitoAnnotations(org.mockito.MockitoAnnotations) BindingReflections(org.opendaylight.yangtools.yang.binding.util.BindingReflections) RouteMirroringMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.RouteMirroringMessage) RouterId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId) RouterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.RouterKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) StatsReportsMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.StatsReportsMessage) Mirrors(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Mirrors) PostPolicyRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PostPolicyRib) PrePolicyRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PrePolicyRib) SocketChannel(io.netty.channel.socket.SocketChannel) EpollSocketChannel(io.netty.channel.epoll.EpollSocketChannel) Channel(io.netty.channel.Channel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Peer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router) PeerKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.PeerKey) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs) PeerSession(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.PeerSession) Stats(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.peer.Stats)

Example 20 with Tlvs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.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();
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.stat.Tlvs) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)

Aggregations

Test (org.junit.Test)21 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)13 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)13 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)11 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)11 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)9 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs)9 BgpParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder)8 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities)8 OptionalCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder)8 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)8 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)8 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder)7 As4BytesCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder)7 MultiprotocolCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder)7 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)7 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)7 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)7 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.ProtocolVersion)6 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)5