diff --git a/src/device/service/drivers/ietf_slice/Constants.py b/src/device/service/drivers/ietf_slice/Constants.py index df66eb16b3d78c1b388a086011ed6f6b75b8099f..172c328aeaa5a2beafe4ced1b273cb3e7577e241 100644 --- a/src/device/service/drivers/ietf_slice/Constants.py +++ b/src/device/service/drivers/ietf_slice/Constants.py @@ -1,4 +1,4 @@ -# 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. diff --git a/src/device/service/drivers/ietf_slice/Tools.py b/src/device/service/drivers/ietf_slice/Tools.py index fddfd894035cec9af89171a59cb779e6e5dec853..bd976927e4b17c74264b3372ed1caeeb1bc96c61 100644 --- a/src/device/service/drivers/ietf_slice/Tools.py +++ b/src/device/service/drivers/ietf_slice/Tools.py @@ -1,4 +1,4 @@ -# 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. diff --git a/src/device/service/drivers/ietf_slice/__init__.py b/src/device/service/drivers/ietf_slice/__init__.py index bbfc943b68af13a11e562abbc8680ade71db8f02..6242c89c7fa17bc5b6cc44328d8ce58438721d45 100644 --- a/src/device/service/drivers/ietf_slice/__init__.py +++ b/src/device/service/drivers/ietf_slice/__init__.py @@ -1,4 +1,4 @@ -# 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. diff --git a/src/device/service/drivers/ietf_slice/driver.py b/src/device/service/drivers/ietf_slice/driver.py index a7e91925c4e00571c126c44496d27df83441c5a8..e8b6e7d0effac1f7a3eb05c7aabd2d0a39125b65 100644 --- a/src/device/service/drivers/ietf_slice/driver.py +++ b/src/device/service/drivers/ietf_slice/driver.py @@ -1,4 +1,4 @@ -# 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( diff --git a/src/device/service/drivers/ietf_slice/tfs_slice_nbi_client.py b/src/device/service/drivers/ietf_slice/tfs_slice_nbi_client.py index 5716982af509d2922bf1613e18740d4203ba9057..596e3d903d6e17dda96be42d776aae2f9068f7bd 100644 --- a/src/device/service/drivers/ietf_slice/tfs_slice_nbi_client.py +++ b/src/device/service/drivers/ietf_slice/tfs_slice_nbi_client.py @@ -1,4 +1,4 @@ -# 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: