Commit b6eedabe authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

-Added changes to client and servicer + database

parent b0c70ad6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION,

class LogicalResourceClient:
    def __init__(self, host=None, port=None):
        if not host: host = get_service_host(ServiceNameEnum.LogicalResource)
        if not port: port = get_service_port_grpc(ServiceNameEnum.LogicalResource)
        if not host: host = get_service_host(ServiceNameEnum.LOGICALRESOURCES)
        if not port: port = get_service_port_grpc(ServiceNameEnum.LOGICALRESOURCES)
        self.endpoint = '{:s}:{:s}'.format(str(host), str(port))
        LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint)))
        self.channel = None
+3 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ class Database:
        self._track_resource('vlan', str(vlan_tag) if vlan_tag else '')
        self._track_resource('asn', str(ASN) if ASN else '')
        self._track_resource('loopback', RouterID)
        self._track_resource('vni', str(vni) if vni else '')

    def get_full_db(self):
        "Return ALLL"
@@ -91,3 +92,4 @@ class Database:
            for (rtype, value), fabric_id in self.resources.items()
            if rtype == resource_type
        ]
    
 No newline at end of file
+17 −2
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 common.tools.service.GenericGrpcService import GenericGrpcService
from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc
@@ -6,8 +20,9 @@ from common.proto.logical_resources_pb2_grpc import add_LogicalResourcesServicer

class LogicalResourceService(GenericGrpcService):
    def __init__(self, cls_name: str = __name__) -> None:
        port = get_service_port_grpc(ServiceNameEnum.LogicalResource)
        port = get_service_port_grpc(ServiceNameEnum.LOGICALRESOURCES)
        super().__init__(port, cls_name=cls_name)
        self.servicer_impl = LogicalResourceServicerImpl()
    def install_servicers(self):
            add_LogicalResourcesServicer_to_server(self.servicer_impl, self.server)
            
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ from logical_resources.client.Logicalresourceclient import LogicalResourceClient

LOCAL_HOST = '127.0.0.1'
# Use the official port + 10000 for safety during local testing
GRPC_PORT = 10000 + int(get_service_port_grpc(ServiceNameEnum.LogicalResource))
GRPC_PORT = 10000 + int(get_service_port_grpc(ServiceNameEnum.LOGICALRESOURCES))

# This "tricks" the Client into looking at localhost:40230
os.environ[get_env_var_name(ServiceNameEnum.LogicalResource, ENVVAR_SUFIX_SERVICE_HOST)] = str(LOCAL_HOST)
os.environ[get_env_var_name(ServiceNameEnum.LogicalResource, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(GRPC_PORT)
os.environ[get_env_var_name(ServiceNameEnum.LOGICALRESOURCES, ENVVAR_SUFIX_SERVICE_HOST)] = str(LOCAL_HOST)
os.environ[get_env_var_name(ServiceNameEnum.LOGICALRESOURCES, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(GRPC_PORT)

@pytest.fixture(scope='session')
def logical_resource_service():