Search in sources :

Example 1 with LinkAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes in project bgpcep by opendaylight.

the class LinkstateAttributeParserTest method testPositiveLinks.

@Test
public void testPositiveLinks() throws BGPParsingException, BGPDocumentedException {
    final AttributesBuilder builder = createBuilder(new LinkCaseBuilder().build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder, null);
    final Attributes1 attrs = builder.augmentation(Attributes1.class);
    final LinkAttributes ls = ((LinkAttributesCase) attrs.getLinkStateAttribute()).getLinkAttributes();
    assertNotNull(ls);
    assertEquals("42.42.42.42", ls.getLocalIpv4RouterId().getValue());
    assertEquals("43.43.43.43", ls.getRemoteIpv4RouterId().getValue());
    assertEquals(Uint32.ZERO, ls.getAdminGroup().getValue());
    assertArrayEquals(new byte[] { (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80 }, ls.getMaxLinkBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getMaxReservableBandwidth().getValue());
    assertNotNull(ls.getUnreservedBandwidth());
    assertEquals(8, ls.getUnreservedBandwidth().size());
    assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
    assertTrue(ls.getMplsProtocol().getLdp());
    assertTrue(ls.getMplsProtocol().getRsvpte());
    assertEquals(Uint32.TEN, ls.getMetric().getValue());
    assertEquals(2, ls.getSharedRiskLinkGroups().size());
    assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
    assertEquals("12K-2", ls.getLinkName());
    final IsisAdjFlagsCase flags = new IsisAdjFlagsCaseBuilder().setIsisAdjFlags(new IsisAdjFlagsBuilder().setAddressFamily(Boolean.TRUE).setBackup(Boolean.FALSE).setSet(Boolean.FALSE).build()).build();
    assertEquals(flags, ls.getSrAdjIds().get(0).getFlags());
    assertEquals(flags, ls.getSrAdjIds().get(1).getFlags());
    assertEquals(Uint32.valueOf(1048575L), ((LocalLabelCase) ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel().getValue());
    assertEquals(Uint32.valueOf(1048559L), ((LocalLabelCase) ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel().getValue());
    assertEquals(Uint32.valueOf(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerNodeSid().getWeight().getValue());
    assertEquals(Uint32.valueOf(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerSetSids().get(0).getWeight().getValue());
    assertEquals(Uint32.valueOf(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerAdjSid().getWeight().getValue());
    // Performance Metrics
    assertEquals(Uint32.valueOf(10000L), ls.getLinkDelay().getValue());
    assertEquals(Uint32.valueOf(5000L), ls.getLinkMinMaxDelay().getMinDelay().getValue());
    assertEquals(Uint32.valueOf(20000L), ls.getLinkMinMaxDelay().getMaxDelay().getValue());
    assertEquals(Uint32.valueOf(10000L), ls.getDelayVariation().getValue());
    assertEquals(Uint32.ZERO, ls.getLinkLoss().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getResidualBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getAvailableBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }, ls.getUtilizedBandwidth().getValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    // The LINK_ATTR buffer is now greater than 255 bytes. Need to skip one more byte
    buff.skipBytes(4);
    // there is unresolved TLV at the end, that needs to be cut off
    assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length - 5), ByteArray.getAllBytes(buff));
}
Also used : LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) LinkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCaseBuilder) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) IsisAdjFlagsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.IsisAdjFlagsCaseBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1) IsisAdjFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.IsisAdjFlagsCase) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) LinkAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.LinkAttributesCase) IsisAdjFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlagsBuilder) Test(org.junit.Test)

Example 2 with LinkAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes in project bgpcep by opendaylight.

the class LinkstateTopologyBuilder method createLink.

private void createLink(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
    // defensive lookup
    final LinkAttributes la;
    final Attributes1 attr = attributes.augmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType != null) {
            la = ((LinkAttributesCase) attrType).getLinkAttributes();
        } else {
            LOG.debug("Missing attribute type in link {} route {}, skipping it", linkCase, value);
            la = null;
        }
    } else {
        LOG.debug("Missing attributes in link {} route {}, skipping it", linkCase, value);
        la = null;
    }
    final IgpLinkAttributesBuilder ilab = new IgpLinkAttributesBuilder();
    Long adjSid = null;
    if (la != null) {
        if (la.getMetric() != null) {
            ilab.setMetric(la.getMetric().getValue());
        }
        ilab.setName(la.getLinkName());
        if (la.getSrAdjIds() != null && !la.getSrAdjIds().isEmpty()) {
            final SrAdjIds srAdjIds = la.getSrAdjIds().get(0);
            if (srAdjIds != null) {
                final SidLabelIndex sidLabelIndex = srAdjIds.getSidLabelIndex();
                if (sidLabelIndex instanceof LocalLabelCase) {
                    adjSid = ((LocalLabelCase) sidLabelIndex).getLocalLabel().getValue().longValue();
                }
            }
        }
    }
    ProtocolUtil.augmentProtocolId(value, ilab, la, linkCase.getLinkDescriptors());
    final LinkBuilder lb = new LinkBuilder().setLinkId(buildLinkId(base, linkCase)).addAugmentation(new Link1Builder().setIgpLinkAttributes(ilab.build()).build());
    final NodeId srcNode = buildNodeId(base, linkCase.getLocalNodeDescriptors());
    LOG.trace("Link {} implies source node {}", linkCase, srcNode);
    final NodeId dstNode = buildNodeId(base, linkCase.getRemoteNodeDescriptors());
    LOG.trace("Link {} implies destination node {}", linkCase, dstNode);
    final TerminationPoint srcTp = buildLocalTp(base, linkCase.getLinkDescriptors());
    LOG.trace("Link {} implies source TP {}", linkCase, srcTp);
    final TerminationPoint dstTp = buildRemoteTp(base, linkCase.getLinkDescriptors());
    LOG.trace("Link {} implies destination TP {}", linkCase, dstTp);
    lb.setSource(new SourceBuilder().setSourceNode(srcNode).setSourceTp(srcTp.getTpId()).build());
    lb.setDestination(new DestinationBuilder().setDestNode(dstNode).setDestTp(dstTp.getTpId()).build());
    LOG.trace("Created TP {} as link source", srcTp);
    NodeHolder snh = this.nodes.get(srcNode);
    if (snh == null) {
        snh = getNode(srcNode);
        snh.addTp(srcTp, lb.getLinkId(), false);
        if (adjSid != null) {
            snh.createSrHolderIfRequired().addAdjacencySid(trans, false, lb.getLinkId(), adjSid);
        }
        putNode(trans, snh);
    } else {
        snh.addTp(srcTp, lb.getLinkId(), false);
        if (adjSid != null) {
            snh.createSrHolderIfRequired().addAdjacencySid(trans, true, lb.getLinkId(), adjSid);
        }
        final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(snh.getNodeId()));
        trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, srcTp.key()), srcTp);
    }
    if (adjSid != null) {
        lb.addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Link1Builder().setSegment(new SegmentId(Uint32.valueOf(adjSid))).build());
    }
    LOG.debug("Created TP {} as link destination", dstTp);
    NodeHolder dnh = this.nodes.get(dstNode);
    if (dnh == null) {
        dnh = getNode(dstNode);
        dnh.addTp(dstTp, lb.getLinkId(), true);
        putNode(trans, dnh);
    } else {
        dnh.addTp(dstTp, lb.getLinkId(), true);
        final InstanceIdentifier<Node> nid = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class, new NodeKey(dnh.getNodeId()));
        trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, dstTp.key()), dstTp);
    }
    final InstanceIdentifier<Link> lid = buildLinkIdentifier(lb.getLinkId());
    final Link link = lb.build();
    trans.put(LogicalDatastoreType.OPERATIONAL, lid, link);
    LOG.debug("Created link {} at {} for {}", link, lid, linkCase);
}
Also used : Preconditions(com.google.common.base.Preconditions) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute) Link1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Link1Builder) LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) IgpLinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.link.attributes.IgpLinkAttributesBuilder) SegmentId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.SegmentId) SourceBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder) LinkBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.routes.linkstate.routes.linkstate.route.Attributes1) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder) SidLabelIndex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Example 3 with LinkAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createEdge.

/**
 * Create new Connected Edge in the Connected Graph.
 *
 * @param value       The complete Linkstate route information
 * @param linkCase    The Link part of the Linkstate route
 * @param attributes  The Link attributes
 */
private void createEdge(final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
    checkArgument(checkLinkState(linkCase), "Missing mandatory information in link {}", linkCase);
    final LinkAttributes la = getLinkAttributes(attributes);
    if (la == null) {
        LOG.warn("Missing attributes in link {} route {}, skipping it", linkCase, value);
        return;
    }
    /* Get Source and Destination Vertex from the graph */
    Uint64 srcId = getVertexId(linkCase.getLocalNodeDescriptors().getCRouterIdentifier());
    Uint64 dstId = getVertexId(linkCase.getRemoteNodeDescriptors().getCRouterIdentifier());
    if (srcId == Uint64.ZERO || dstId == Uint64.ZERO) {
        LOG.warn("Unable to get the Source or Destination Vertex Identifier from link {}, skipping it", linkCase);
        return;
    }
    /* Get Source and Destination Key for the corresponding Edge */
    Uint64 edgeId = getEdgeId(linkCase);
    if (edgeId == Uint64.ZERO) {
        LOG.warn("Unable to get the Edge Identifier from link {}, skipping it", linkCase);
        return;
    }
    /* Add associated Edge */
    Edge edge = new EdgeBuilder().setEdgeId(edgeId).setLocalVertexId(srcId).setRemoteVertexId(dstId).setName(srcId + " - " + dstId).setEdgeAttributes(createEdgeAttributes(la, linkCase.getLinkDescriptors())).build();
    /*
         * Add corresponding Prefix for the Local Address. Remote address will be added with the remote Edge */
    final var localAddress = edge.getEdgeAttributes().getLocalAddress();
    PrefixBuilder prefBuilder = new PrefixBuilder().setVertexId(srcId);
    if (localAddress.getIpv4Address() != null) {
        prefBuilder.setPrefix(new IpPrefix(IetfInetUtil.INSTANCE.ipv4PrefixFor(localAddress.getIpv4Address())));
    }
    if (localAddress.getIpv6Address() != null) {
        prefBuilder.setPrefix(new IpPrefix(IetfInetUtil.INSTANCE.ipv6PrefixFor(localAddress.getIpv6Address())));
    }
    Prefix prefix = prefBuilder.build();
    /* Add the Edge in the Connected Graph */
    LOG.info("Add Edge {} and associated Prefix {} in TED[{}]", edge.getName(), prefix.getPrefix(), cgraph);
    cgraph.addEdge(edge);
    cgraph.addPrefix(prefix);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) Prefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Edge(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge) EdgeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64) PrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)

Example 4 with LinkAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createEdgeAttributes.

/**
 * Create Edge Attributes from Link attributes.
 *
 * @param la         Linkstate Attributes
 * @param linkDesc   Linkstate Descriptors
 *
 * @return EdgeAttributes
 */
private static EdgeAttributes createEdgeAttributes(final LinkAttributes la, final LinkDescriptors linkDesc) {
    EdgeAttributesBuilder builder = new EdgeAttributesBuilder();
    if (linkDesc.getIpv4InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv4InterfaceAddress()));
    }
    if (linkDesc.getIpv6InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv6InterfaceAddress()));
    }
    if (linkDesc.getIpv4NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv4NeighborAddress()));
    }
    if (linkDesc.getIpv6NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv6NeighborAddress()));
    }
    if (linkDesc.getLinkLocalIdentifier() != null) {
        builder.setLocalIdentifier(linkDesc.getLinkLocalIdentifier());
    }
    if (linkDesc.getLinkRemoteIdentifier() != null) {
        builder.setRemoteIdentifier(linkDesc.getLinkRemoteIdentifier());
    }
    if (la.getMetric() != null) {
        builder.setMetric(la.getMetric().getValue());
    }
    if (la.getTeMetric() != null) {
        builder.setTeMetric(la.getTeMetric().getValue());
    }
    if (la.getMaxLinkBandwidth() != null) {
        builder.setMaxLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxLinkBandwidth()));
    }
    if (la.getMaxReservableBandwidth() != null) {
        builder.setMaxResvLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxReservableBandwidth()));
    }
    if (la.getUnreservedBandwidth() != null) {
        int upperBound = Math.min(la.getUnreservedBandwidth().size(), MAX_PRIORITY);
        final List<UnreservedBandwidth> unRsvBw = new ArrayList<>(upperBound);
        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.UnreservedBandwidth bandwidth : la.nonnullUnreservedBandwidth().values()) {
            unRsvBw.add(new UnreservedBandwidthBuilder().setBandwidth(bandwithToDecimalBandwidth(bandwidth.getBandwidth())).withKey(new UnreservedBandwidthKey(bandwidth.getPriority())).build());
        }
        builder.setUnreservedBandwidth(unRsvBw);
    }
    if (la.getAdminGroup() != null) {
        builder.setAdminGroup(la.getAdminGroup().getValue());
    }
    if (la.getLinkDelay() != null) {
        builder.setDelay(new Delay(la.getLinkDelay().getValue()));
    }
    if (la.getLinkMinMaxDelay() != null && la.getLinkMinMaxDelay() != null) {
        MinMaxDelay mmDelay = new MinMaxDelayBuilder().setMaxDelay(new Delay(la.getLinkMinMaxDelay().getMaxDelay().getValue())).setMinDelay(new Delay(la.getLinkMinMaxDelay().getMinDelay().getValue())).build();
        builder.setMinMaxDelay(mmDelay);
    }
    if (la.getDelayVariation() != null) {
        builder.setJitter(new Delay(la.getDelayVariation().getValue()));
    }
    if (la.getLinkLoss() != null) {
        builder.setLoss(new Loss(la.getLinkLoss().getValue()));
    }
    if (la.getAvailableBandwidth() != null) {
        builder.setAvailableBandwidth(bandwithToDecimalBandwidth(la.getAvailableBandwidth()));
    }
    if (la.getResidualBandwidth() != null) {
        builder.setResidualBandwidth(bandwithToDecimalBandwidth(la.getResidualBandwidth()));
    }
    if (la.getUtilizedBandwidth() != null) {
        builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
    }
    if (la.getSharedRiskLinkGroups() != null) {
        List<Uint32> srlgs = new ArrayList<>();
        for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
            srlgs.add(srlg.getValue());
        }
        builder.setSrlgs(srlgs);
    }
    for (SrAdjIds adj : la.nonnullSrAdjIds()) {
        if (adj.getSidLabelIndex() instanceof LocalLabelCase) {
            boolean backup = false;
            if (adj.getFlags() instanceof OspfAdjFlags) {
                backup = ((OspfAdjFlags) adj.getFlags()).getBackup();
            }
            if (adj.getFlags() instanceof IsisAdjFlags) {
                backup = ((IsisAdjFlags) adj.getFlags()).getBackup();
            }
            if (!backup) {
                builder.setAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            } else {
                builder.setBackupAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            }
        }
    }
    return builder.build();
}
Also used : EdgeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributesBuilder) OspfAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags) ArrayList(java.util.ArrayList) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) Uint32(org.opendaylight.yangtools.yang.common.Uint32) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth) UnreservedBandwidthKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthKey) MinMaxDelayBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelayBuilder) Loss(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId) UnreservedBandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) IsisAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)

Example 5 with LinkAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes in project bgpcep by opendaylight.

the class ProtocolUtil method isisLinkAttributes.

private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1 isisLinkAttributes(final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
    final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder();
    if (la != null) {
        if (la.getAdminGroup() != null) {
            tb.setColor(la.getAdminGroup().getValue());
        }
        if (la.getTeMetric() != null) {
            tb.setTeDefaultMetric(la.getTeMetric().getValue());
        }
        if (la.getUnreservedBandwidth() != null) {
            tb.setUnreservedBandwidth(unreservedBandwidthList(la.nonnullUnreservedBandwidth().values()));
        }
        if (la.getMaxLinkBandwidth() != null) {
            tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
        }
        if (la.getMaxReservableBandwidth() != null) {
            tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
        }
        if (la.getSharedRiskLinkGroups() != null) {
            tb.setSrlg(new SrlgBuilder().setSrlgValues(la.getSharedRiskLinkGroups().stream().map(id -> new SrlgValuesBuilder().setSrlgValue(id.getValue()).build()).collect(BindingMap.toOrderedMap())).build());
        }
    }
    final IsisLinkAttributesBuilder ilab = new IsisLinkAttributesBuilder();
    ilab.setTed(tb.build());
    if (topologyIdentifier != null) {
        ilab.setMultiTopologyId(Uint8.valueOf(topologyIdentifier.getValue()));
    }
    return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1Builder().setIsisLinkAttributes(ilab.build()).build();
}
Also used : IsisLinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.IsisLinkAttributesBuilder) SrlgValuesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValuesBuilder) SrlgBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.ted.link.attributes.SrlgBuilder)

Aggregations

LinkAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes)4 LocalLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase)3 ArrayList (java.util.ArrayList)2 SrAdjIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds)2 SrlgValuesBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValuesBuilder)2 SrlgBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.ted.link.attributes.SrlgBuilder)2 Preconditions (com.google.common.base.Preconditions)1 ByteBuf (io.netty.buffer.ByteBuf)1 List (java.util.List)1 Test (org.junit.Test)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 AdministrativeGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.AdministrativeGroup)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1)1 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Delay)1 Loss (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Loss)1 LinkMinMaxDelay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.LinkMinMaxDelay)1 LinkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCaseBuilder)1 LinkStateAttribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute)1 LinkAttributesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.LinkAttributesCase)1