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):
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
......@@ -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
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