Search in sources :

Example 6 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class LinkAttributesParser method parseLinkAttributes.

/**
 * Parse Link Attributes.
 *
 * @param attributes key is the tlv type and value is the value of the tlv
 * @param protocolId to differentiate parsing methods
 * @return {@link LinkStateAttribute}
 */
static LinkStateAttribute parseLinkAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
    final LinkAttributesBuilder builder = new LinkAttributesBuilder();
    final List<SrAdjIds> srAdjIds = new ArrayList<>();
    final List<SrLanAdjIds> srLanAdjIds = new ArrayList<>();
    final List<PeerSetSids> peerSetSids = new ArrayList<>();
    for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
        LOG.trace("Link attribute TLV {}", entry.getKey());
        final int key = entry.getKey();
        final ByteBuf value = entry.getValue();
        switch(key) {
            case TlvUtil.LOCAL_IPV4_ROUTER_ID:
                builder.setLocalIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
                LOG.debug("Parsed IPv4 Router-ID of local node: {}", builder.getLocalIpv4RouterId());
                break;
            case TlvUtil.LOCAL_IPV6_ROUTER_ID:
                builder.setLocalIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
                LOG.debug("Parsed IPv6 Router-ID of local node: {}", builder.getLocalIpv6RouterId());
                break;
            case REMOTE_IPV4_ROUTER_ID:
                builder.setRemoteIpv4RouterId(new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value)));
                LOG.debug("Parsed IPv4 Router-ID of remote node: {}", builder.getRemoteIpv4RouterId());
                break;
            case REMOTE_IPV6_ROUTER_ID:
                builder.setRemoteIpv6RouterId(new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value)));
                LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
                break;
            case ADMIN_GROUP:
                builder.setAdminGroup(new AdministrativeGroup(readUint32(value)));
                LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
                break;
            case EXTENDED_ADMIN_GROUP:
                // FIXME: BGPCEP-895: add proper implementation
                LOG.info("Support for Extended Administrative Group not implemented, ignoring it");
                break;
            case MAX_BANDWIDTH:
                builder.setMaxLinkBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
                LOG.debug("Parsed Max Bandwidth {}", builder.getMaxLinkBandwidth());
                break;
            case MAX_RESERVABLE_BANDWIDTH:
                builder.setMaxReservableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
                LOG.debug("Parsed Max Reservable Bandwidth {}", builder.getMaxReservableBandwidth());
                break;
            case UNRESERVED_BANDWIDTH:
                parseUnreservedBandwidth(value, builder);
                break;
            case TE_METRIC:
                builder.setTeMetric(new TeMetric(readUint32(value)));
                LOG.debug("Parsed Metric {}", builder.getTeMetric());
                break;
            case LINK_PROTECTION_TYPE:
                builder.setLinkProtection(LinkProtectionType.forValue(value.readShort()));
                LOG.debug("Parsed Link Protection Type {}", builder.getLinkProtection());
                break;
            case MPLS_PROTOCOL:
                final BitArray bits = BitArray.valueOf(value, FLAGS_SIZE);
                builder.setMplsProtocol(new MplsProtocolMask(bits.get(LDP_BIT), bits.get(RSVP_BIT)));
                LOG.debug("Parsed MPLS Protocols: {}", builder.getMplsProtocol());
                break;
            case METRIC:
                // length can 3, 2 or 1
                builder.setMetric(new Metric(Uint32.valueOf(ByteArray.bytesToLong(ByteArray.readAllBytes(value)))));
                LOG.debug("Parsed Metric {}", builder.getMetric());
                break;
            case SHARED_RISK_LINK_GROUP:
                parseSrlg(value, builder);
                break;
            case LINK_OPAQUE:
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Parsed Opaque value : {}", ByteBufUtil.hexDump(value));
                }
                break;
            case LINK_NAME:
                builder.setLinkName(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
                LOG.debug("Parsed Link Name : {}", builder.getLinkName());
                break;
            case SR_ADJ_ID:
                srAdjIds.add(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(value, protocolId));
                LOG.debug("Parsed Adjacency Segment Identifier :{}", srAdjIds.get(srAdjIds.size() - 1));
                break;
            case SR_LAN_ADJ_ID:
                srLanAdjIds.add(SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(value, protocolId));
                LOG.debug("Parsed Adjacency Segment Identifier :{}", srLanAdjIds.get(srLanAdjIds.size() - 1));
                break;
            case PEER_NODE_SID_CODE:
                builder.setPeerNodeSid(new PeerNodeSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
                LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerNodeSid());
                break;
            case PEER_ADJ_SID_CODE:
                builder.setPeerAdjSid(new PeerAdjSidBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
                LOG.debug("Parsed Peer Segment Identifier :{}", builder.getPeerAdjSid());
                break;
            case PEER_SET_SID_CODE:
                peerSetSids.add(new PeerSetSidsBuilder(SrLinkAttributesParser.parseEpeAdjacencySegmentIdentifier(value)).build());
                LOG.debug("Parsed Peer Set Sid :{}", peerSetSids.get(peerSetSids.size() - 1));
                break;
            // Performance Metrics
            case LINK_DELAY:
                builder.setLinkDelay(new Delay(readUint32(value)));
                LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
                break;
            case LINK_MIN_MAX_DELAY:
                builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder().setMinDelay(new Delay(readUint32(value))).setMaxDelay(new Delay(readUint32(value))).build());
                LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
                break;
            case DELAY_VARIATION:
                builder.setDelayVariation(new Delay(readUint32(value)));
                LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
                break;
            case LINK_LOSS:
                builder.setLinkLoss(new Loss(readUint32(value)));
                LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
                break;
            case RESIDUAL_BANDWIDTH:
                builder.setResidualBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
                LOG.debug("Parsed Residual Bandwidth {}", builder.getResidualBandwidth());
                break;
            case AVAILABLE_BANDWIDTH:
                builder.setAvailableBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
                LOG.debug("Parsed Available Bandwidth {}", builder.getAvailableBandwidth());
                break;
            case UTILIZED_BANDWIDTH:
                builder.setUtilizedBandwidth(new Bandwidth(ByteArray.readAllBytes(value)));
                LOG.debug("Parsed Utilized Bandwidth {}", builder.getUtilizedBandwidth());
                break;
            default:
                LOG.warn("TLV {} is not a recognized link attribute, ignoring it", key);
        }
    }
    if (!srAdjIds.isEmpty()) {
        builder.setSrAdjIds(srAdjIds);
    }
    if (!srLanAdjIds.isEmpty()) {
        builder.setSrLanAdjIds(srLanAdjIds);
    }
    if (!peerSetSids.isEmpty()) {
        builder.setPeerSetSids(peerSetSids);
    }
    LOG.trace("Finished parsing Link Attributes.");
    return new LinkAttributesCaseBuilder().setLinkAttributes(builder.build()).build();
}
Also used : SrLanAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrLanAdjIds) TeMetric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.TeMetric) PeerNodeSidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.PeerNodeSidBuilder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) PeerSetSidsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.PeerSetSidsBuilder) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Delay) LinkMinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.LinkMinMaxDelay) SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidth) LinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributesBuilder) BitArray(org.opendaylight.protocol.util.BitArray) Ipv6RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv6RouterIdentifier) MplsProtocolMask(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.MplsProtocolMask) Ipv4RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv4RouterIdentifier) Loss(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Loss) AdministrativeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.AdministrativeGroup) LinkAttributesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.LinkAttributesCaseBuilder) PeerAdjSidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.PeerAdjSidBuilder) LinkMinMaxDelayBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.LinkMinMaxDelayBuilder) PeerSetSids(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.PeerSetSids) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Metric) TeMetric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.TeMetric)

Example 7 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method serializeFailure.

private void serializeFailure(final FailureCase failure, final ByteBuf buffer) {
    if (failure == null) {
        return;
    }
    serializeObject(failure.getNoPath(), buffer);
    serializeObject(failure.getLspa(), buffer);
    serializeObject(failure.getBandwidth(), buffer);
    for (final Metrics m : failure.nonnullMetrics()) {
        serializeObject(m.getMetric(), buffer);
    }
    serializeObject(failure.getIro(), buffer);
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)

Example 8 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method parseAttributes.

protected void parseAttributes(final FailureCaseBuilder builder, final Queue<Object> objects) {
    final List<Metrics> pathMetrics = new ArrayList<>();
    State state = State.INIT;
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        state = insertObject(state, obj, builder, pathMetrics);
        if (state == State.END) {
            break;
        }
        objects.remove();
    }
    if (!pathMetrics.isEmpty()) {
        builder.setMetrics(pathMetrics);
    }
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) ArrayList(java.util.ArrayList) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)

Example 9 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class StatefulPCUpdateRequestMessageParser method serializeUpdate.

protected void serializeUpdate(final Updates update, final ByteBuf buffer) {
    serializeObject(update.getSrp(), buffer);
    serializeObject(update.getLsp(), buffer);
    final Path p = update.getPath();
    if (p != null) {
        serializeObject(p.getEro(), buffer);
        serializeObject(p.getLspa(), buffer);
        serializeObject(p.getBandwidth(), buffer);
        serializeObject(p.getReoptimizationBandwidth(), buffer);
        for (final Metrics m : p.nonnullMetrics()) {
            serializeObject(m.getMetric(), buffer);
        }
        serializeObject(p.getIro(), buffer);
    }
}
Also used : Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)

Example 10 with Metrics

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.

the class StatefulPCRequestMessageParser method serializeP2P.

@Override
protected void serializeP2P(final ByteBuf buffer, final P2p p2p) {
    serializeObject(p2p.getEndpointsObj(), buffer);
    serializeVendorInformationObjects(p2p.getVendorInformationObject(), buffer);
    if (p2p.getReportedRoute() != null) {
        final ReportedRoute rr = p2p.getReportedRoute();
        if (rr != null) {
            serializeObject(rr.getRro(), buffer);
            serializeObject(rr.getReoptimizationBandwidth(), buffer);
        }
    }
    serializeObject(p2p.getLoadBalancing(), buffer);
    if (p2p.augmentation(P2p1.class) != null) {
        final P2p1 aug = p2p.augmentation(P2p1.class);
        serializeObject(aug.getLsp(), buffer);
    }
    serializeObject(p2p.getLspa(), buffer);
    serializeObject(p2p.getBandwidth(), buffer);
    for (final Metrics m : p2p.nonnullMetrics()) {
        serializeObject(m.getMetric(), buffer);
    }
    serializeObject(p2p.getIro(), buffer);
    serializeObject(p2p.getRro(), buffer);
    serializeObject(p2p.getXro(), buffer);
    serializeObject(p2p.getOf(), buffer);
    serializeObject(p2p.getClassType(), buffer);
}
Also used : Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) P2p1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.P2p1) ReportedRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRoute)

Aggregations

Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)15 ArrayList (java.util.ArrayList)13 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics)9 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)9 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)7 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)6 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)4 Preconditions (com.google.common.base.Preconditions)3 List (java.util.List)3 Metric (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric)3 ByteBuf (io.netty.buffer.ByteBuf)2 Counter (org.opendaylight.infrautils.metrics.Counter)2 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth)2 Iro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro)2 LoadBalancing (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing)2 MetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder)2 Lspa (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa)2