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);
}
Aggregations