Search in sources :

Example 1 with EdgeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeBuilder 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)

Aggregations

IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 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)1 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)1 EdgeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeBuilder)1 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)1 PrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)1 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)1