Search in sources :

Example 1 with DecimalBandwidth

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

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 ConstraintsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.get.constrained.path.input.ConstraintsBuilder)1 Ipv4Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case)1 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)1