Loading proto/logical_resources.proto +3 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,9 @@ message ConfigParameters { bool multihop = 17; string afi = 18; string name = 19; string interface_comment = 20; string link_target_device = 21; string link_target_interface = 22; } message Response { Loading src/common/tools/descriptor/Loader.py +29 −8 Original line number Diff line number Diff line Loading @@ -204,6 +204,7 @@ class DescriptorLoader: self.__svc_cli = ServiceClient() if service_client is None else service_client self.__slc_cli = SliceClient() if slice_client is None else slice_client self.__vnt_cli = VNTManagerClient() if vntm_client is None else vntm_client self.__fabric_name_to_id: Dict[str, str] = {} self.__results : TypeResults = list() Loading Loading @@ -433,7 +434,14 @@ class DescriptorLoader: elif resource_type == 'router_id': request_kwargs['router_id'] = str(allocation['value']) elif resource_type == 'interface_ip_address': request_kwargs['ip_address'] = str(allocation['value']) ip_val = allocation.get('value') if isinstance(ip_val, dict): request_kwargs['ip_address'] = str(ip_val.get('ip', '')) request_kwargs['interface_comment'] = str(ip_val.get('comment', '')) request_kwargs['link_target_device'] = str(ip_val.get('link_to_device', '')) request_kwargs['link_target_interface'] = str(ip_val.get('link_to_interface', '')) else: request_kwargs['ip_address'] = str(ip_val) request_kwargs['interface'] = endpoint_uuid elif resource_type == 'vlan': request_kwargs['vlan_tag'] = int(allocation['value']) Loading @@ -456,6 +464,10 @@ class DescriptorLoader: for fabric in self.__logical_resources: 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 '' try: self.__fabric_name_to_id[fabric_name] = str(fabric_id) if fabric_id else '' except Exception: self.__fabric_name_to_id = {fabric_name: (str(fabric_id) if fabric_id else '')} for resource_type, resource_descriptor in fabric.items(): if resource_type in ('fabric_id', 'fabric_name'): continue Loading @@ -469,6 +481,15 @@ class DescriptorLoader: if resource_type == 'interface_ip_address': interface_allocations = allocation.get('interfaces', allocation.get('endpoints', {})) for endpoint_uuid, ip_address in interface_allocations.items(): if isinstance(ip_address, dict): alloc = dict(allocation) alloc['device_uuid'] = allocation_key alloc['endpoint_uuid'] = endpoint_uuid alloc['value'] = ip_address alloc['fabric_name'] = fabric_name request = self._logical_resource_request('interface_ip_address', alloc) else: request = ConfigParameters( device_uuid=str(allocation_key), endpoint_uuid=str(endpoint_uuid), Loading src/logical_resources/Dockerfile +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ RUN find . -type f -exec sed -i -E 's/^(import\ .*)_pb2/from . \1_pb2/g' {} \; # Add component files into working directory WORKDIR /var/teraflow COPY src/logical_resources/. logical_resources/ COPY --chown=teraflow:teraflow src/service/service/. service/service/ # Start the service ENTRYPOINT ["python", "-m", "logical_resources.service"] src/logical_resources/database.py +6 −2 Original line number Diff line number Diff line Loading @@ -48,7 +48,8 @@ class Database: 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): remote_as=None, local_role=None, routing_table=None, multihop=None, afi=None, name=None, interface_comment=None, link_target_device=None, link_target_interface=None): if device_uuid not in self.database: self.database[device_uuid] = {} Loading @@ -73,7 +74,10 @@ class Database: "routing_table": routing_table, "multihop": multihop, "afi": afi, "name": name "name": name, "interface_comment": interface_comment, "link_target_device": link_target_device, "link_target_interface": link_target_interface } else: endpoint = self.database[device_uuid][endpoint_uuid] Loading src/logical_resources/service/LogicalResourceServicerImpl.py +4 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ class LogicalResourceServicerImpl(LogicalResourcesServicer): request.routing_table, request.multihop, request.afi, request.name request.name, request.interface_comment, request.link_target_device, request.link_target_interface ) return Response(success=True, message='Resources added to Logical Database') Loading Loading
proto/logical_resources.proto +3 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,9 @@ message ConfigParameters { bool multihop = 17; string afi = 18; string name = 19; string interface_comment = 20; string link_target_device = 21; string link_target_interface = 22; } message Response { Loading
src/common/tools/descriptor/Loader.py +29 −8 Original line number Diff line number Diff line Loading @@ -204,6 +204,7 @@ class DescriptorLoader: self.__svc_cli = ServiceClient() if service_client is None else service_client self.__slc_cli = SliceClient() if slice_client is None else slice_client self.__vnt_cli = VNTManagerClient() if vntm_client is None else vntm_client self.__fabric_name_to_id: Dict[str, str] = {} self.__results : TypeResults = list() Loading Loading @@ -433,7 +434,14 @@ class DescriptorLoader: elif resource_type == 'router_id': request_kwargs['router_id'] = str(allocation['value']) elif resource_type == 'interface_ip_address': request_kwargs['ip_address'] = str(allocation['value']) ip_val = allocation.get('value') if isinstance(ip_val, dict): request_kwargs['ip_address'] = str(ip_val.get('ip', '')) request_kwargs['interface_comment'] = str(ip_val.get('comment', '')) request_kwargs['link_target_device'] = str(ip_val.get('link_to_device', '')) request_kwargs['link_target_interface'] = str(ip_val.get('link_to_interface', '')) else: request_kwargs['ip_address'] = str(ip_val) request_kwargs['interface'] = endpoint_uuid elif resource_type == 'vlan': request_kwargs['vlan_tag'] = int(allocation['value']) Loading @@ -456,6 +464,10 @@ class DescriptorLoader: for fabric in self.__logical_resources: 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 '' try: self.__fabric_name_to_id[fabric_name] = str(fabric_id) if fabric_id else '' except Exception: self.__fabric_name_to_id = {fabric_name: (str(fabric_id) if fabric_id else '')} for resource_type, resource_descriptor in fabric.items(): if resource_type in ('fabric_id', 'fabric_name'): continue Loading @@ -469,6 +481,15 @@ class DescriptorLoader: if resource_type == 'interface_ip_address': interface_allocations = allocation.get('interfaces', allocation.get('endpoints', {})) for endpoint_uuid, ip_address in interface_allocations.items(): if isinstance(ip_address, dict): alloc = dict(allocation) alloc['device_uuid'] = allocation_key alloc['endpoint_uuid'] = endpoint_uuid alloc['value'] = ip_address alloc['fabric_name'] = fabric_name request = self._logical_resource_request('interface_ip_address', alloc) else: request = ConfigParameters( device_uuid=str(allocation_key), endpoint_uuid=str(endpoint_uuid), Loading
src/logical_resources/Dockerfile +1 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ RUN find . -type f -exec sed -i -E 's/^(import\ .*)_pb2/from . \1_pb2/g' {} \; # Add component files into working directory WORKDIR /var/teraflow COPY src/logical_resources/. logical_resources/ COPY --chown=teraflow:teraflow src/service/service/. service/service/ # Start the service ENTRYPOINT ["python", "-m", "logical_resources.service"]
src/logical_resources/database.py +6 −2 Original line number Diff line number Diff line Loading @@ -48,7 +48,8 @@ class Database: 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): remote_as=None, local_role=None, routing_table=None, multihop=None, afi=None, name=None, interface_comment=None, link_target_device=None, link_target_interface=None): if device_uuid not in self.database: self.database[device_uuid] = {} Loading @@ -73,7 +74,10 @@ class Database: "routing_table": routing_table, "multihop": multihop, "afi": afi, "name": name "name": name, "interface_comment": interface_comment, "link_target_device": link_target_device, "link_target_interface": link_target_interface } else: endpoint = self.database[device_uuid][endpoint_uuid] Loading
src/logical_resources/service/LogicalResourceServicerImpl.py +4 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ class LogicalResourceServicerImpl(LogicalResourcesServicer): request.routing_table, request.multihop, request.afi, request.name request.name, request.interface_comment, request.link_target_device, request.link_target_interface ) return Response(success=True, message='Resources added to Logical Database') Loading