use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class PathComputationServer method getConstrainedPath.
@Override
public ListenableFuture<RpcResult<GetConstrainedPathOutput>> getConstrainedPath(final GetConstrainedPathInput input) {
final GetConstrainedPathOutputBuilder output = new GetConstrainedPathOutputBuilder();
LOG.info("Got Path Computation Service request");
/* First, get graph */
final ConnectedGraph cgraph = graphProvider.getConnectedGraph(input.getGraphName());
if (cgraph == null) {
output.setStatus(ComputationStatus.Failed);
return RpcResultBuilder.<GetConstrainedPathOutput>failed().withError(RpcError.ErrorType.RPC, "Unknown Graph Name").buildFuture();
}
/* get a new Path Computation Algorithm according to Input choice */
PathComputationAlgorithm algo = getPathComputationAlgorithm(cgraph, input.getAlgorithm());
if (algo == null) {
output.setStatus(ComputationStatus.Failed);
return RpcResultBuilder.<GetConstrainedPathOutput>failed().withError(RpcError.ErrorType.RPC, "Unknown Path Computation Algorithm").buildFuture();
}
/*
* Request Path Computation for given source, destination and
* constraints
*/
final VertexKey source = new VertexKey(input.getSource());
final VertexKey destination = new VertexKey(input.getDestination());
LOG.info("Call Path Computation {} algorithm for path from {} to {} with contraints {}", input.getAlgorithm().getName(), source, destination, input.getConstraints());
final ConstrainedPath cpath = algo.computeP2pPath(source, destination, input.getConstraints());
/* Send back the Computed Path */
output.setPathDescription(cpath.getPathDescription()).setStatus(cpath.getStatus()).setComputedMetric(cpath.getMetric()).setComputedTeMetric(cpath.getTeMetric()).setComputedDelay(cpath.getDelay());
return RpcResultBuilder.success(output.build()).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method createVertex.
/**
* Create new Connected Vertex in the Connected Graph.
*
* @param value The complete Linkstate route information
* @param nodeCase The node part of the Linkstate route
* @param attributes The node attributes
*/
private void createVertex(final LinkstateRoute value, final NodeCase nodeCase, final Attributes attributes) {
checkArgument(nodeCase != null, "Missing Node Case. Skip this Node");
checkArgument(nodeCase.getNodeDescriptors() != null, "Missing Node Descriptors. Skip this Node");
Uint64 vertexId = getVertexId(nodeCase.getNodeDescriptors().getCRouterIdentifier());
if (vertexId == Uint64.ZERO) {
LOG.warn("Unable to get Vertex Identifier from descriptor {}, skipping it", nodeCase.getNodeDescriptors());
return;
}
NodeAttributes na = getNodeAttributes(attributes);
if (na == null) {
LOG.warn("Missing attributes in node {} route {}, skipping it", nodeCase, value);
return;
}
Uint32 asNumber = Uint32.ZERO;
if (nodeCase.getNodeDescriptors() != null) {
asNumber = nodeCase.getNodeDescriptors().getAsNumber().getValue();
}
Vertex vertex = getVertex(na, vertexId, asNumber);
/* Add the Connected Vertex and associated Vertex in the Graph */
LOG.info("Add Vertex {} in TED[{}]", vertex.getName(), cgraph);
cgraph.addVertex(vertex);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getVertexId.
/**
* Get Vertex in the Graph by the OSPF Router ID or IS-IS-System ID.
*
* @param routerID The Router Identifier entry
*
* @return Vertex in the Connected Graph that corresponds to this Router ID. Vertex is created if not found.
*/
private static Uint64 getVertexId(final CRouterIdentifier routerID) {
Uint64 rid = Uint64.ZERO;
if (routerID instanceof IsisNodeCase) {
final byte[] isoId = ((IsisNodeCase) routerID).getIsisNode().getIsoSystemId().getValue();
final byte[] convert = { 0, 0, isoId[0], isoId[1], isoId[2], isoId[3], isoId[4], isoId[5] };
rid = Uint64.fromLongBits(ByteBuffer.wrap(convert).getLong());
}
if (routerID instanceof OspfNodeCase) {
rid = ((OspfNodeCase) routerID).getOspfNode().getOspfRouterId().toUint64();
}
LOG.debug("Get Vertex Identifier {}", rid);
return rid;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class ConnectedGraphServer method createConnectedGraph.
@Override
public ConnectedGraph createConnectedGraph(final String name, final DomainScope scope) {
Graph graph = new GraphBuilder().setName(name).setDomainScope(scope).build();
addToDataStore(getGraphInstanceIdentifier(name), graph, "Graph(" + name + ")");
ConnectedGraphImpl cgraph = new ConnectedGraphImpl(graph, this);
graphs.put(graph.key(), cgraph);
return cgraph;
}
Aggregations