Commit 5ddadb6a authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

minor polish

parent a65301c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+1 −1
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+1 −1
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+13 −7
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -200,15 +200,16 @@ class IetfSliceDriver(_Driver):
                    continue
                results.extend(dump_subtree(resource_node))
            return results
        return results

    @metered_subclass_method(METRICS_POOL)
    def SetConfig(
        self, resources: List[Tuple[str, Any]]
    ) -> List[Union[bool, Exception]]:
        results = []

        if len(resources) == 0:
            return results

        with self.__lock:
            for resource in resources:
                resource_key, resource_value = resource
@@ -225,26 +226,33 @@ class IetfSliceDriver(_Driver):
                    continue
                try:
                    resource_value = json.loads(resource_value)

                    slice_name = resource_value["network-slice-services"][
                        "slice-service"
                    ][0]["id"]

                    if operation_type == "create":
                        self.tac.create_slice(resource_value)

                    elif operation_type == "update":
                        connection_groups = resource_value["network-slice-services"][
                            "slice-service"
                        ][0]["connection-groups"]["connection-group"]

                        if len(connection_groups) != 1:
                            raise Exception("only one connection group is supported")

                        connection_group = connection_groups[0]

                        self.tac.update_slice(
                            slice_name, connection_group["id"], connection_group
                        )

                    elif operation_type == "delete":
                        self.tac.delete_slice(slice_name)

                    results.append((resource_key, True))
                except Exception as e:  # pylint: disable=broad-except
                    raise e
                    LOGGER.exception(
                        "Unhandled error processing resource_key({:s})".format(
                            str(resource_key)
@@ -258,17 +266,15 @@ class IetfSliceDriver(_Driver):
        self, resources: List[Tuple[str, Any]]
    ) -> List[Union[bool, Exception]]:
        results = []

        if len(resources) == 0:
            return results

        with self.__lock:
            for resource in resources:
                LOGGER.info("resource = {:s}".format(str(resource)))
                resource_key, resource_value = resource
                try:
                    # resource_value = json.loads(resource_value)
                    # service_uuid = resource_value["uuid"]
                    # if service_exists(self.__tfs_nbi_root, self.__auth, service_uuid):
                    #     self.tac.delete_slice(service_uuid)
                    results.append((resource_key, True))
                except Exception as e:  # pylint: disable=broad-except
                    LOGGER.exception(
+2 −2
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2025 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ TIMEOUT = 30

LOGGER = logging.getLogger(__name__)

HEADERS = {'Content-Type': 'application/json'}
HEADERS = {"Content-Type": "application/json"}


class TfsApiClient: