Skip to content
Snippets Groups Projects
Commit 0e8bc24b authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service component - OpticalTfs Service Handler:

- Corrected composition of requests for setting up and tearing down optical connectivity services
parent 970d7456
No related branches found
No related tags found
4 merge requests!346Draft: support for restconf protocol,!345Draft: support ipinfusion devices via netconf,!328Resolve "(CTTC) Update recommendations to use SocketIO on NBI and E2E Orch components",!286Resolve "(CTTC) Implement integration test between E2E-IP-Optical SDN Controllers"
......@@ -16,7 +16,7 @@ import json, logging
from typing import Any, Dict, List, Optional, Tuple, Union
from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method
from common.proto.context_pb2 import ConfigRule, DeviceId, Service
from common.tools.object_factory.ConfigRule import json_config_rule_set
from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
from common.tools.object_factory.Device import json_device_id
from common.type_checkers.Checkers import chk_type
from service.service.service_handler_api.Tools import get_device_endpoint_uuids
......@@ -36,6 +36,20 @@ class OpticalTfsServiceHandler(_ServiceHandler):
self.__task_executor = task_executor
self.__settings_handler = SettingsHandler(service.service_config, **settings)
def _get_constraints(self) -> Tuple[Optional[int], Optional[int], Optional[int]]:
bitrate = None
bidir = None
ob_width = None
for constraint in self.__service.service_constraints:
if constraint.WhichOneof('constraint') != 'custom': continue
if constraint.custom.constraint_type == 'bandwidth[gbps]':
bitrate = int(float(constraint.custom.constraint_value))
elif constraint.custom.constraint_type == 'bidirectionality':
bidir = int(constraint.custom.constraint_value) == 1
elif constraint.custom.constraint_type == 'optical-band-width[GHz]':
ob_width = int(constraint.custom.constraint_value)
return bitrate, bidir, ob_width
@metered_subclass_method(METRICS_POOL)
def SetEndpoint(
self, endpoints : List[Tuple[str, str, Optional[str]]], connection_uuid : Optional[str] = None
......@@ -45,9 +59,8 @@ class OpticalTfsServiceHandler(_ServiceHandler):
if len(endpoints) < 2: return []
service_uuid = self.__service.service_id.service_uuid.uuid
settings = self.__settings_handler.get('/settings')
json_settings : Dict = {} if settings is None else settings.value
bitrate = json_settings['bitrate']
service_name = self.__service.name
bitrate, bidir, ob_width = self._get_constraints()
results = []
try:
......@@ -64,10 +77,15 @@ class OpticalTfsServiceHandler(_ServiceHandler):
controller = src_controller
json_config_rule = json_config_rule_set('/services/service[{:s}]'.format(service_uuid), {
'uuid' : service_uuid,
'src_node' : src_endpoint_uuid,
'dst_node' : dst_endpoint_uuid,
'bitrate' : bitrate
'service_uuid' : service_uuid,
'service_name' : service_name,
'src_device_uuid' : src_device_uuid,
'src_endpoint_uuid': src_endpoint_uuid,
'dst_device_uuid' : dst_device_uuid,
'dst_endpoint_uuid': dst_endpoint_uuid,
'bitrate' : bitrate,
'bidir' : bidir,
'ob_width' : ob_width,
})
del controller.device_config.config_rules[:]
controller.device_config.config_rules.append(ConfigRule(**json_config_rule))
......@@ -91,7 +109,7 @@ class OpticalTfsServiceHandler(_ServiceHandler):
settings = self.__settings_handler.get('/settings')
json_settings : Dict = {} if settings is None else settings.value
flow_id = json_settings['flow_id']
bitrate = json_settings['bitrate']
bitrate, bidir, ob_width = self._get_constraints()
results = []
try:
......@@ -107,12 +125,16 @@ class OpticalTfsServiceHandler(_ServiceHandler):
controller = src_controller
json_config_rule = json_config_rule_set('/services/service[{:s}]'.format(service_uuid), {
'uuid' : service_uuid,
'flow_id' : flow_id,
'src_node' : src_endpoint_uuid,
'dst_node' : dst_endpoint_uuid,
'bitrate' : bitrate
json_config_rule = json_config_rule_delete('/services/service[{:s}]'.format(service_uuid), {
'flow_id' : flow_id,
'service_uuid' : service_uuid,
'src_device_uuid' : src_device_uuid,
'src_endpoint_uuid': src_endpoint_uuid,
'dst_device_uuid' : dst_device_uuid,
'dst_endpoint_uuid': dst_endpoint_uuid,
'bitrate' : bitrate,
'bidir' : bidir,
'ob_width' : ob_width,
})
del controller.device_config.config_rules[:]
......
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