Commit 90bf2f34 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component- IETF Slice:

- Corrected metric bound handling
- Disabled code to replace ONT endpoint by Emu-DC, not clear why it is done
parent a02136f1
Loading
Loading
Loading
Loading
+59 −11
Original line number Diff line number Diff line
@@ -103,19 +103,65 @@ def build_constraints_from_connection_group(connection_group: dict) -> List[Cons
    ]["slo-policy"]["metric-bound"]

    for metric in metric_bounds:
        metric_type = metric["metric-type"]
        if metric_type == "ietf-nss:one-way-delay-maximum":
            bound_value = float(metric["bound"])
        metric_type = str(metric['metric-type'])
        metric_type = metric_type.replace('ietf-network-slice-service:', 'ietf-nss:')

        if metric_type == 'ietf-nss:one-way-delay-maximum':
            value = float(metric['bound'])
            unit  = str(metric['metric-unit'])

            if unit == 'nanoseconds':
                factor = 1.0e6
            elif unit == 'microseconds':
                factor = 1.0e3
            elif unit == 'milliseconds':
                factor = 1.0
            else:
                MSG = 'Unsupported unit({:s}) for metric({:s})'
                raise Exception(MSG.format(unit, metric_type))

            constraint = Constraint()
            constraint.sla_latency.e2e_latency_ms = value / factor
            constraints.append(constraint)

        elif metric_type == 'ietf-nss:one-way-bandwidth':
            value = float(metric['bound'])
            unit  = str(metric['metric-unit'])

            if unit == 'bps':
                factor = 1.0e9
            elif unit == 'Kbps':
                factor = 1.0e6
            elif unit == 'Mbps':
                factor = 1.0e3
            elif unit == 'Gbps':
                factor = 1.0
            else:
                MSG = 'Unsupported unit({:s}) for metric({:s})'
                raise Exception(MSG.format(unit, metric_type))

            constraint = Constraint()
            constraint.sla_latency.e2e_latency_ms = bound_value
            constraint.sla_capacity.capacity_gbps = value / factor
            constraints.append(constraint)
        elif metric_type == "ietf-nss:one-way-bandwidth":
            bound_value = float(metric["bound"])

        elif metric_type == "ietf-nss:two-way-packet-loss":
            value = float(metric["percentile-value"])
            unit  = str(metric['metric-unit'])

            if unit != 'percentage':
                MSG = 'Unsupported unit({:s}) for metric({:s})'
                raise Exception(MSG.format(unit, metric_type))

            constraint = Constraint()
            # Convert from Mbps to Gbps if needed
            constraint.sla_capacity.capacity_gbps = bound_value / 1.0e3
            constraint.sla_availability.num_disjoint_paths = 1
            constraint.sla_availability.all_active = True
            constraint.sla_availability.availability = 100.0 - value
            constraints.append(constraint)

        else:
            MSG = 'Unsupported metric({:s})'
            raise Exception(MSG.format(str(metric)))

    return constraints


@@ -335,9 +381,11 @@ class IETFSliceHandler:

        # Sort endpoints and optionally replace the ONT endpoint
        list_endpoints = sort_endpoints(list_endpoints, sdps, found_cg, context_client)
        list_endpoints = replace_ont_endpoint_with_emu_dc(
            list_endpoints, context_client
        )
        
        # NOTE: not sure why this is needed
        #list_endpoints = replace_ont_endpoint_with_emu_dc(
        #    list_endpoints, context_client
        #)

        slice_request.slice_endpoint_ids.extend(list_endpoints)
        slice_request.slice_constraints.extend(list_constraints)