Skip to content
Snippets Groups Projects
Commit 09b442f2 authored by PEDRENOMANR's avatar PEDRENOMANR
Browse files

Bug fixes in IETF entry point and parsing.

Added SLA availability as percentage.
parent 63d65aad
No related branches found
No related tags found
2 merge requests!142Release TeraFlowSDN 2.1,!70Add IETF Slice NBI
...@@ -75,10 +75,11 @@ class NSS_Services(Resource): ...@@ -75,10 +75,11 @@ class NSS_Services(Resource):
if cc.slo_sle_policy.custom: if cc.slo_sle_policy.custom:
with cc.slo_sle_policy.custom as slo: with cc.slo_sle_policy.custom as slo:
for metric_bound in slo.service_slo_sle_policy().metric_bounds().metric_bound: 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() constraint = Constraint()
metric_unit = metric_bound.metric_unit().casefold() 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": if metric_unit == "mbps":
capacity /= 1E3 capacity /= 1E3
elif metric_unit != "gbps": elif metric_unit != "gbps":
...@@ -88,9 +89,9 @@ class NSS_Services(Resource): ...@@ -88,9 +89,9 @@ class NSS_Services(Resource):
constraint.sla_capacity.capacity_gbps = capacity constraint.sla_capacity.capacity_gbps = capacity
list_constraints.append(constraint) 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": if metric_bound.metric_unit().casefold() == "ms":
latency = float(metric_bound.value_description()) latency = int(metric_bound.bound())
else: else:
LOGGER.warning(f"Invalided metric unit ({metric_bound.metric_unit()}), must be \"ms\" ") LOGGER.warning(f"Invalided metric unit ({metric_bound.metric_unit()}), must be \"ms\" ")
response.status_code = HTTP_SERVERERROR response.status_code = HTTP_SERVERERROR
...@@ -99,13 +100,17 @@ class NSS_Services(Resource): ...@@ -99,13 +100,17 @@ class NSS_Services(Resource):
constraint.sla_latency.e2e_latency_ms = latency constraint.sla_latency.e2e_latency_ms = latency
list_constraints.append(constraint) list_constraints.append(constraint)
elif "service-slo-availability": elif metric_type == "service-slo-availability":
# TODO map to an availability number (or use a custom identity definition) 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 = Constraint()
constraint.sla_availability.num_disjoint_paths = 2 constraint.sla_availability.availability = availability
constraint.sla_availability.all_active = True list_constraints.append(constraint)
slice_request.slice_constraints.extend(list_constraints) slice_request.slice_constraints.extend(list_constraints)
LOGGER.debug(grpc_message_to_json(slice_request)) # TODO remove
slice_client = SliceClient() slice_client = SliceClient()
slice_client.CreateSlice(slice_request) slice_client.CreateSlice(slice_request)
LOGGER.debug(grpc_message_to_json(slice_request)) # TODO remove
return response return response
...@@ -20,7 +20,7 @@ from compute.service.rest_server.RestServer import RestServer ...@@ -20,7 +20,7 @@ from compute.service.rest_server.RestServer import RestServer
from .NSS_Services import NSS_Services from .NSS_Services import NSS_Services
from .NSS_Service import NSS_Service 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): def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs):
urls = [(URL_PREFIX + url) for url in urls] urls = [(URL_PREFIX + url) for url in urls]
...@@ -29,4 +29,3 @@ def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs ...@@ -29,4 +29,3 @@ def _add_resource(rest_server : RestServer, resource : Resource, *urls, **kwargs
def register_ietf_nss(rest_server : RestServer): def register_ietf_nss(rest_server : RestServer):
_add_resource(rest_server, NSS_Services, '/network-slice-services') _add_resource(rest_server, NSS_Services, '/network-slice-services')
_add_resource(rest_server, NSS_Service, '/network-slice-services/slice-service=<string:slice_id>') _add_resource(rest_server, NSS_Service, '/network-slice-services/slice-service=<string:slice_id>')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment