Search in sources :

Example 11 with Graph

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 ConnectedGraphImpl method createConnectedGraph.

/**
 * Transform the associated Graph in a Connected Graph. This method will automatically create associated Connected
 * Vertices, from the Graph Vertices, Connected Edges, from the Graph Edges and Prefix from the Graph Prefix.
 */
private void createConnectedGraph() {
    if (this.graph == null) {
        return;
    }
    /* Add all vertices */
    for (Vertex vertex : this.graph.nonnullVertex().values()) {
        ConnectedVertexImpl cvertex = new ConnectedVertexImpl(vertex);
        vertices.put(cvertex.getKey(), cvertex);
    }
    /* Add all edges */
    for (Edge edge : this.graph.nonnullEdge().values()) {
        ConnectedEdgeImpl cedge = new ConnectedEdgeImpl(edge);
        edges.put(cedge.getKey(), cedge);
    }
    /* Add all prefixes */
    for (Prefix prefix : this.graph.nonnullPrefix().values()) {
        ConnectedVertexImpl cvertex = vertices.get(prefix.getVertexId().longValue());
        if (cvertex != null) {
            cvertex.addPrefix(prefix);
        }
        prefixes.putIfAbsent(prefix.getPrefix(), prefix);
    }
}
Also used : Vertex(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex) ConnectedVertex(org.opendaylight.graph.ConnectedVertex) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Prefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix) Edge(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge) ConnectedEdge(org.opendaylight.graph.ConnectedEdge)

Example 12 with Graph

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 PathComputationImpl method computePath.

@Override
public Message computePath(final Requests req) {
    LOG.info("Received Compute Path request");
    /* Check that Request Parameter Object is present */
    if (req == null || req.getRp() == null) {
        LOG.error("Missing Request Parameter Objects. Abort!");
        return MessagesUtil.createErrorMsg(PCEPErrors.RP_MISSING, Uint32.ZERO);
    }
    LOG.debug("Request for path computation {}", req);
    /*
         * Check that mandatory End Point Objects are present and Source /
         * Destination are know in the TED Graph
         */
    P2p input = req.getSegmentComputation().getP2p();
    if (input == null || input.getEndpointsObj() == null) {
        LOG.error("Missing End Point Objects. Abort!");
        Uint32 reqID = req.getRp().getRequestId().getValue();
        return MessagesUtil.createErrorMsg(PCEPErrors.END_POINTS_MISSING, reqID);
    }
    VertexKey source = getSourceVertexKey(input.getEndpointsObj());
    VertexKey destination = getDestinationVertexKey(input.getEndpointsObj());
    if (source == null) {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.UNKNOWN_SOURCE);
    }
    if (destination == null) {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.UNKNOWN_DESTINATION);
    }
    /* Create new Constraints Object from the request */
    PathConstraints cts = getConstraints(input, !PSTUtil.isDefaultPST(req.getRp().getTlvs().getPathSetupType()));
    /* Determine Path Computation Algorithm according to Input choice */
    AlgorithmType algoType;
    if (cts.getTeMetric() == null && cts.getDelay() == null) {
        algoType = AlgorithmType.Spf;
    } else if (cts.getDelay() == null) {
        algoType = AlgorithmType.Cspf;
    } else {
        algoType = AlgorithmType.Samcra;
    }
    PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
    if (algo == null) {
        return MessagesUtil.createErrorMsg(PCEPErrors.RESOURCE_LIMIT_EXCEEDED, Uint32.ZERO);
    }
    /* Request Path Computation for given source, destination and constraints */
    LOG.debug("Call Path Computation {} algorithm for path from {} to {} with contraints {}", algoType, source, destination, cts);
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
    LOG.info("Computed path: {}", cpath.getPathDescription());
    /* Check if we got a valid Path and return appropriate message */
    if (cpath.getStatus() == ComputationStatus.Completed) {
        return MessagesUtil.createPcRepMessage(req.getRp(), req.getSegmentComputation().getP2p(), cpath);
    } else {
        return MessagesUtil.createNoPathMessage(req.getRp(), MessagesUtil.NO_PATH);
    }
}
Also used : AlgorithmType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm) PathConstraints(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints) Uint32(org.opendaylight.yangtools.yang.common.Uint32) P2p(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2p)

Example 13 with Graph

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 createPrefix.

/**
 * Create new Prefix in the Connected Graph.
 *
 * @param value       The complete Linkstate route information
 * @param prefixCase  The Prefix part of the Linkstate route
 * @param attributes  The Prefix attributes
 */
private void createPrefix(final LinkstateRoute value, final PrefixCase prefixCase, final Attributes attributes) {
    final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
    if (ippfx == null) {
        LOG.warn("IP reachability not present in prefix {} route {}, skipping it", prefixCase, value);
        return;
    }
    /* Verify that all mandatory information are present */
    final PrefixAttributes pa;
    final Attributes1 attr = attributes.augmentation(Attributes1.class);
    if (attr != null) {
        final LinkStateAttribute attrType = attr.getLinkStateAttribute();
        if (attrType instanceof PrefixAttributesCase) {
            pa = ((PrefixAttributesCase) attrType).getPrefixAttributes();
        } else {
            LOG.warn("Missing attribute type in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
            return;
        }
    } else {
        LOG.warn("Missing attributes in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
        return;
    }
    /*
         * Get Connected Vertex from Connected Graph corresponding to the
         * Advertising Node Descriptor
         */
    Uint64 vertexId = getVertexId(prefixCase.getAdvertisingNodeDescriptors().getCRouterIdentifier());
    if (vertexId == Uint64.ZERO) {
        LOG.warn("Unable to get the Vertex Identifier from descriptor {}, skipping it", prefixCase.getAdvertisingNodeDescriptors());
        return;
    }
    /* Create Prefix */
    PrefixBuilder builder = new PrefixBuilder().setVertexId(vertexId).setPrefix(ippfx);
    if (pa.getSrPrefix() != null && pa.getSrPrefix().getSidLabelIndex() instanceof SidCase) {
        builder.setPrefixSid(((SidCase) pa.getSrPrefix().getSidLabelIndex()).getSid());
        if (pa.getSrPrefix().getFlags() instanceof IsisPrefixFlagsCase) {
            builder.setNodeSid(((IsisPrefixFlagsCase) pa.getSrPrefix().getFlags()).getIsisPrefixFlags().getNodeSid());
        } else {
            /*
                 * Seems that OSPF Flags are not accessible. Assuming that the
                 * Prefix is a Node SID
                 */
            builder.setNodeSid(true);
        }
    }
    Prefix prefix = builder.build();
    /* Add the Prefix to the Connected Vertex within the Connected Graph */
    LOG.info("Add prefix {} in TED[{}]", builder.getPrefix(), cgraph);
    cgraph.addPrefix(prefix);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IsisPrefixFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.prefix.sid.tlv.flags.IsisPrefixFlagsCase) PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) PrefixAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.routes.linkstate.routes.linkstate.route.Attributes1) 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) LinkStateAttribute(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.LinkStateAttribute) SidCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase) 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

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 ConnectedGraph (org.opendaylight.graph.ConnectedGraph)3 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)3 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)3 PathComputationAlgorithm (org.opendaylight.algo.PathComputationAlgorithm)2 ConnectedVertex (org.opendaylight.graph.ConnectedVertex)2 Graph (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph)2 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)2 PrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)2 Vertex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex)2 VertexKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey)2 ConstrainedPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath)2 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)2 ArrayList (java.util.ArrayList)1 ConnectedEdge (org.opendaylight.graph.ConnectedEdge)1 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)1 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)1