diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Services.py b/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Services.py index 987dbb2cd2dbd64d08bf8b8b89cf2651e55a3c03..df19f9e4a1f7f192ee067f64680f5c4a314243fe 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Services.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Services.py @@ -75,10 +75,11 @@ class NSS_Services(Resource): if cc.slo_sle_policy.custom: with cc.slo_sle_policy.custom as slo: for metric_bound in slo.service_slo_sle_policy().metric_bounds().metric_bound: - if "service-slo-two-way-bandwidth" in str(metric_bound.metric_type()).casefold(): # TODO fix to two way! + metric_type = str(metric_bound.metric_type()).casefold() + if metric_type == "service-slo-two-way-bandwidth": # TODO fix to two way! constraint = Constraint() metric_unit = metric_bound.metric_unit().casefold() - capacity = float(metric_bound.value_description()) # Assuming capacity already in Gbps + capacity = float(metric_bound.bound()) # Assuming capacity already in Gbps if metric_unit == "mbps": capacity /= 1E3 elif metric_unit != "gbps": @@ -88,9 +89,9 @@ class NSS_Services(Resource): constraint.sla_capacity.capacity_gbps = capacity list_constraints.append(constraint) - elif "service-slo-one-way-delay" in str(metric_bound.metric_type()).casefold(): + elif metric_type == "service-slo-one-way-delay": if metric_bound.metric_unit().casefold() == "ms": - latency = float(metric_bound.value_description()) + latency = int(metric_bound.bound()) else: LOGGER.warning(f"Invalided metric unit ({metric_bound.metric_unit()}), must be \"ms\" ") response.status_code = HTTP_SERVERERROR @@ -99,13 +100,17 @@ class NSS_Services(Resource): constraint.sla_latency.e2e_latency_ms = latency list_constraints.append(constraint) - elif "service-slo-availability": - # TODO map to an availability number (or use a custom identity definition) + elif metric_type == "service-slo-availability": + availability = float(metric_bound.bound()) + if availability > 100.0 or availability < 0.0: + raise Exception(f'Slice SLO availability ({availability}) must be constrained [0,100]') constraint = Constraint() - constraint.sla_availability.num_disjoint_paths = 2 - constraint.sla_availability.all_active = True + constraint.sla_availability.availability = availability + list_constraints.append(constraint) + slice_request.slice_constraints.extend(list_constraints) + LOGGER.debug(grpc_message_to_json(slice_request)) # TODO remove slice_client = SliceClient() slice_client.CreateSlice(slice_request) - LOGGER.debug(grpc_message_to_json(slice_request)) # TODO remove + return response diff --git a/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/__init__.py b/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/__init__.py index aa45206cd2e20546ad1a4af100c9ec1855b28b64..5b7ac27d5fe223126fea7ed08d5d9a8f1b21244b 100644 --- a/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/__init__.py +++ b/src/compute/service/rest_server/nbi_plugins/ietf_network_slice/__init__.py @@ -20,7 +20,7 @@ from compute.service.rest_server.RestServer import RestServer from .NSS_Services import NSS_Services from .NSS_Service import NSS_Service -URL_PREFIX = '/ietf-network-slice-service:ietf-nss' +URL_PREFIX = '/data/ietf-network-slice-service:ietf-nss' def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs): urls = [(URL_PREFIX + url) for url in urls] @@ -29,4 +29,3 @@ def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs def register_ietf_nss(rest_server : RestServer): _add_resource(rest_server, NSS_Services, '/network-slice-services') _add_resource(rest_server, NSS_Service, '/network-slice-services/slice-service=<string:slice_id>') - \ No newline at end of file