Search in sources :

Example 11 with EndpointsObj

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.

the class PathComputationImpl method getConstraints.

private static PathConstraints getConstraints(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
    ConstraintsBuilder ctsBuilder = new ConstraintsBuilder();
    Float convert;
    /* Set Metrics if any */
    if (metrics != null) {
        for (Metrics metric : metrics) {
            convert = ByteBuffer.wrap(metric.getMetric().getValue().getValue()).getFloat();
            final long value = convert.longValue();
            /* Skip Metric with value equal to 0 */
            if (value == 0) {
                continue;
            }
            switch(metric.getMetric().getMetricType().intValue()) {
                case MessagesUtil.IGP_METRIC:
                    ctsBuilder.setMetric(Uint32.valueOf(value));
                    break;
                case MessagesUtil.TE_METRIC:
                    ctsBuilder.setTeMetric(Uint32.valueOf(value));
                    break;
                case MessagesUtil.PATH_DELAY:
                    ctsBuilder.setDelay(new Delay(Uint32.valueOf(value)));
                    break;
                default:
                    LOG.warn("Metric {} is not handle by Path Computation Constraints", metric);
                    break;
            }
        }
    }
    /* Set Bandwidth and Class Type */
    if (bandwidth != null) {
        convert = ByteBuffer.wrap(bandwidth.getBandwidth().getValue()).getFloat();
        final long value = convert.longValue();
        /* Skip Bandwidth with value equal to 0 */
        if (value != 0) {
            ctsBuilder.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(value)));
            if (classType != null) {
                ctsBuilder.setClassType(classType.getClassType().getValue());
            }
        }
    }
    /* Set Address Family */
    if (endpoints.getAddressFamily() instanceof Ipv4Case) {
        ctsBuilder.setAddressFamily(segmentRouting ? AddressFamily.SrIpv4 : AddressFamily.Ipv4);
    } else {
        ctsBuilder.setAddressFamily(segmentRouting ? AddressFamily.SrIpv6 : AddressFamily.Ipv6);
    }
    return ctsBuilder.build();
}
Also used : DecimalBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.DecimalBandwidth) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) ConstraintsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.get.constrained.path.input.ConstraintsBuilder) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)

Aggregations

Ipv4Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case)4 EndpointsObj (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj)4 ByteBuf (io.netty.buffer.ByteBuf)3 EndpointsObj (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj)3 Ipv6Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6Case)3 ArrayList (java.util.ArrayList)2 ConnectedVertex (org.opendaylight.graph.ConnectedVertex)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.AddressFamily)2 Ipv6Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv6Case)2 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)2 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)2 Test (org.junit.Test)1 PathComputationAlgorithm (org.opendaylight.algo.PathComputationAlgorithm)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 DecimalBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.DecimalBandwidth)1 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)1 VertexKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey)1 AlgorithmType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType)1