Loading src/common/tools/descriptor/Loader.py +7 −5 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from logical_resources.client.Logicalresourceclient import LogicalResourceClient from service.service.tools.object_uuid import get_uuid_from_string from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient Loading Loading @@ -420,11 +421,11 @@ class DescriptorLoader: def _logical_resource_request(self, resource_type: str, allocation: Dict) -> Any: device_uuid = str(allocation.get('device_uuid', '')) endpoint_uuid = str(allocation.get('endpoint_uuid', allocation.get('interface', ''))) device_name = str(allocation.get('device_name', '')) fabric_name = str(allocation.get('fabric_name', allocation.get('fabric_id', ''))) request_kwargs = { 'device_uuid': device_uuid, 'endpoint_uuid': endpoint_uuid, 'name': device_name, 'name': fabric_name, } if resource_type == 'asn': Loading Loading @@ -453,9 +454,10 @@ class DescriptorLoader: num_ok, error_list = 0, [] for fabric in self.__logical_resources: fabric_id = str(fabric.get('fabric_id', '')) fabric_name = str(fabric.get('fabric_name', fabric.get('fabric_id', ''))) fabric_id = get_uuid_from_string(fabric_name) if len(fabric_name) > 0 else '' for resource_type, resource_descriptor in fabric.items(): if resource_type == 'fabric_id': if resource_type in ('fabric_id', 'fabric_name'): continue allocations = resource_descriptor.get('allocations', {}) Loading @@ -472,7 +474,7 @@ class DescriptorLoader: endpoint_uuid=str(endpoint_uuid), ip_address=str(ip_address), interface=str(endpoint_uuid), name=str(allocation.get('device_name', '')), name=fabric_name, ) self.__lrs_cli.AddResources(request) num_ok += 1 Loading src/logical_resources/database.py +72 −0 Original line number Diff line number Diff line # Copyright 2022-2025 ETSI 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. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from typing import Dict, List, Optional, Tuple from service.service.tools.object_uuid import get_uuid_from_string class Database: def __init__(self): "Creating the database to store things" self.database = {} self.resources = {} self.fabrics = {} def _track_resource(self, resource_type, resource_value): if not resource_value: return self.resources.setdefault((resource_type, resource_value), '') def register_fabric(self, fabric_name: str) -> str: fabric_id = get_uuid_from_string(fabric_name) if fabric_id not in self.fabrics: self.fabrics[fabric_id] = { 'fabric_name': fabric_name, } return fabric_id def get_fabric(self, fabric_id: str): return self.fabrics.get(fabric_id) def resolve_fabric_id(self, fabric_name: str) -> Optional[str]: if not fabric_name: return None fabric_id = get_uuid_from_string(fabric_name) if fabric_id in self.fabrics: return fabric_id return None def add_resources(self, device_uuid, endpoint_uuid, ip_address, vlan_tag, mac_address, ASN, RouterID, vni=None, local_address=None, port=None, bridge=None, interface=None, remote_address=None, remote_as=None, local_role=None, routing_table=None, multihop=None, afi=None, name=None): if device_uuid not in self.database: self.database[device_uuid] = {} if name: self.register_fabric(name) if endpoint_uuid not in self.database[device_uuid]: self.database[device_uuid][endpoint_uuid] = { "mac_address": mac_address, Loading @@ -35,6 +75,38 @@ class Database: "afi": afi, "name": name } else: endpoint = self.database[device_uuid][endpoint_uuid] if mac_address: endpoint["mac_address"] = mac_address if ASN: endpoint["asn"] = ASN if RouterID: endpoint["router_id"] = RouterID if vni: endpoint["vni"] = vni if local_address: endpoint["local_address"] = local_address if port: endpoint["port"] = port if bridge: endpoint["bridge"] = bridge if interface: endpoint["interface"] = interface if remote_address: endpoint["remote_address"] = remote_address if remote_as: endpoint["remote_as"] = remote_as if local_role: endpoint["local_role"] = local_role if routing_table: endpoint["routing_table"] = routing_table if multihop: endpoint["multihop"] = multihop if afi: endpoint["afi"] = afi if name: endpoint["name"] = name if ip_address: self.database[device_uuid][endpoint_uuid]["ip_addresses"].append(ip_address) if vlan_tag: Loading Loading
src/common/tools/descriptor/Loader.py +7 −5 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ from common.tools.object_factory.Context import json_context_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from logical_resources.client.Logicalresourceclient import LogicalResourceClient from service.service.tools.object_uuid import get_uuid_from_string from service.client.ServiceClient import ServiceClient from slice.client.SliceClient import SliceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient Loading Loading @@ -420,11 +421,11 @@ class DescriptorLoader: def _logical_resource_request(self, resource_type: str, allocation: Dict) -> Any: device_uuid = str(allocation.get('device_uuid', '')) endpoint_uuid = str(allocation.get('endpoint_uuid', allocation.get('interface', ''))) device_name = str(allocation.get('device_name', '')) fabric_name = str(allocation.get('fabric_name', allocation.get('fabric_id', ''))) request_kwargs = { 'device_uuid': device_uuid, 'endpoint_uuid': endpoint_uuid, 'name': device_name, 'name': fabric_name, } if resource_type == 'asn': Loading Loading @@ -453,9 +454,10 @@ class DescriptorLoader: num_ok, error_list = 0, [] for fabric in self.__logical_resources: fabric_id = str(fabric.get('fabric_id', '')) fabric_name = str(fabric.get('fabric_name', fabric.get('fabric_id', ''))) fabric_id = get_uuid_from_string(fabric_name) if len(fabric_name) > 0 else '' for resource_type, resource_descriptor in fabric.items(): if resource_type == 'fabric_id': if resource_type in ('fabric_id', 'fabric_name'): continue allocations = resource_descriptor.get('allocations', {}) Loading @@ -472,7 +474,7 @@ class DescriptorLoader: endpoint_uuid=str(endpoint_uuid), ip_address=str(ip_address), interface=str(endpoint_uuid), name=str(allocation.get('device_name', '')), name=fabric_name, ) self.__lrs_cli.AddResources(request) num_ok += 1 Loading
src/logical_resources/database.py +72 −0 Original line number Diff line number Diff line # Copyright 2022-2025 ETSI 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. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from typing import Dict, List, Optional, Tuple from service.service.tools.object_uuid import get_uuid_from_string class Database: def __init__(self): "Creating the database to store things" self.database = {} self.resources = {} self.fabrics = {} def _track_resource(self, resource_type, resource_value): if not resource_value: return self.resources.setdefault((resource_type, resource_value), '') def register_fabric(self, fabric_name: str) -> str: fabric_id = get_uuid_from_string(fabric_name) if fabric_id not in self.fabrics: self.fabrics[fabric_id] = { 'fabric_name': fabric_name, } return fabric_id def get_fabric(self, fabric_id: str): return self.fabrics.get(fabric_id) def resolve_fabric_id(self, fabric_name: str) -> Optional[str]: if not fabric_name: return None fabric_id = get_uuid_from_string(fabric_name) if fabric_id in self.fabrics: return fabric_id return None def add_resources(self, device_uuid, endpoint_uuid, ip_address, vlan_tag, mac_address, ASN, RouterID, vni=None, local_address=None, port=None, bridge=None, interface=None, remote_address=None, remote_as=None, local_role=None, routing_table=None, multihop=None, afi=None, name=None): if device_uuid not in self.database: self.database[device_uuid] = {} if name: self.register_fabric(name) if endpoint_uuid not in self.database[device_uuid]: self.database[device_uuid][endpoint_uuid] = { "mac_address": mac_address, Loading @@ -35,6 +75,38 @@ class Database: "afi": afi, "name": name } else: endpoint = self.database[device_uuid][endpoint_uuid] if mac_address: endpoint["mac_address"] = mac_address if ASN: endpoint["asn"] = ASN if RouterID: endpoint["router_id"] = RouterID if vni: endpoint["vni"] = vni if local_address: endpoint["local_address"] = local_address if port: endpoint["port"] = port if bridge: endpoint["bridge"] = bridge if interface: endpoint["interface"] = interface if remote_address: endpoint["remote_address"] = remote_address if remote_as: endpoint["remote_as"] = remote_as if local_role: endpoint["local_role"] = local_role if routing_table: endpoint["routing_table"] = routing_table if multihop: endpoint["multihop"] = multihop if afi: endpoint["afi"] = afi if name: endpoint["name"] = name if ip_address: self.database[device_uuid][endpoint_uuid]["ip_addresses"].append(ip_address) if vlan_tag: Loading