Commit dcf7dbd2 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service component - L3NM IETF Slice:

- Reverted changes in original version
parent be04d181
Loading
Loading
Loading
Loading
+58 −42
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
        endpoints: List[Tuple[str, str, Optional[str]]],
        connection_uuid: Optional[str] = None,
    ) -> List[Union[bool, Exception]]:
        chk_type('endpoints', endpoints, list)
        chk_type("endpoints", endpoints, list)
        if len(endpoints) == 0:
            return []

@@ -404,30 +404,48 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):

            # 1. Identify source and destination devices
            src_device_uuid, src_endpoint_uuid = get_device_endpoint_uuids(endpoints[0])
            src_device_obj = self.__task_executor.get_device(DeviceId(**json_device_id(src_device_uuid)))
            src_device_obj = self.__task_executor.get_device(
                DeviceId(**json_device_id(src_device_uuid))
            )
            src_device_name = src_device_obj.name
            src_controller = self.__task_executor.get_device_controller(src_device_obj)

            dst_device_uuid, dst_endpoint_uuid = get_device_endpoint_uuids(endpoints[-1])
            dst_device_obj = self.__task_executor.get_device(DeviceId(**json_device_id(dst_device_uuid)))
            dst_device_uuid, dst_endpoint_uuid = get_device_endpoint_uuids(
                endpoints[-1]
            )
            dst_device_obj = self.__task_executor.get_device(
                DeviceId(**json_device_id(dst_device_uuid))
            )
            dst_device_name = dst_device_obj.name
            dst_controller = self.__task_executor.get_device_controller(dst_device_obj)

            if src_controller.device_id.device_uuid.uuid != dst_controller.device_id.device_uuid.uuid:
            if (
                src_controller.device_id.device_uuid.uuid
                != dst_controller.device_id.device_uuid.uuid
            ):
                raise Exception("Different Src-Dst devices not supported by now")

            controller = src_controller  # same device controller

            # 2. Determine how the candidate & running resources differ
            running_candidate_diff = get_running_candidate_ietf_slice_data_diff(service_config)

            candidate_ietf_slice_cr = get_custom_config_rule(service_config, CANDIDATE_RESOURCE_KEY)
            candidate_resource_value_dict = json.loads(candidate_ietf_slice_cr.custom.resource_value)

            running_ietf_slice_cr = get_custom_config_rule(service_config, RUNNING_RESOURCE_KEY)
            running_resource_value_dict = json.loads(running_ietf_slice_cr.custom.resource_value)

            slice_name = running_resource_value_dict["network-slice-services"]["slice-service"][0]["id"]
            running_candidate_diff = get_running_candidate_ietf_slice_data_diff(
                service_config
            )
            candidate_ietf_slice_cr = get_custom_config_rule(
                service_config, CANDIDATE_RESOURCE_KEY
            )
            candidate_resource_value_dict = json.loads(
                candidate_ietf_slice_cr.custom.resource_value
            )
            running_ietf_slice_cr = get_custom_config_rule(
                service_config, RUNNING_RESOURCE_KEY
            )
            running_resource_value_dict = json.loads(
                running_ietf_slice_cr.custom.resource_value
            )
            slice_name = running_resource_value_dict["network-slice-services"][
                "slice-service"
            ][0]["id"]

            # 3. Retrieve the context links for matching endpoints
            context_client = ContextClient()
@@ -459,9 +477,7 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
                    for link in links:
                        info = get_link_ep_device_names(link, context_client)
                        dev1, ep1, _, dev2, ep2, _ = info
                        if dev1 != node_id: continue
                        if dev2 not in edge_device_names: continue

                        if dev1 == node_id and dev2 in edge_device_names:
                            edge_device_names.remove(dev2)
                            match_criteria = sdp["service-match-criteria"][
                                "match-criterion"