Commit eaee6c8c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Defined/Corrected skeleton for Interdomain component

parent 37f647b9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -45,9 +45,10 @@ RUN python3 -m pip install -r interdomain/requirements.txt
COPY common/. common
COPY context/. context
COPY device/. device
COPY interdomain/. interdomain
COPY monitoring/. monitoring
COPY service/. service
COPY interdomain/. interdomain
COPY slice/. slice

# Start interdomain service
ENTRYPOINT ["python", "-m", "interdomain.service"]
+5 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ from interdomain.proto.interdomain_pb2_grpc import InterdomainServiceStub
LOGGER = logging.getLogger(__name__)
MAX_RETRIES = 15
DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0)
RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')

class InterdomainClient:
    def __init__(self, address, port):
@@ -26,28 +27,28 @@ class InterdomainClient:
        self.channel = None
        self.stub = None

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def Authenticate(self, request : TeraFlowController) -> AuthenticationResult:
        LOGGER.debug('Authenticate request: {:s}'.format(str(request)))
        response = self.stub.Authenticate(request)
        LOGGER.debug('Authenticate result: {:s}'.format(str(response)))
        return response

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def LookUpSlice(self, request : TransportSlice) -> SliceId:
        LOGGER.debug('LookUpSlice request: {:s}'.format(str(request)))
        response = self.stub.LookUpSlice(request)
        LOGGER.debug('LookUpSlice result: {:s}'.format(str(response)))
        return response

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def OrderSliceFromCatalog(self, request : TransportSlice) -> SliceStatus:
        LOGGER.debug('OrderSliceFromCatalog request: {:s}'.format(str(request)))
        response = self.stub.OrderSliceFromCatalog(request)
        LOGGER.debug('OrderSliceFromCatalog result: {:s}'.format(str(response)))
        return response

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def CreateSliceAndAddToCatalog(self, request : TransportSlice) -> SliceStatus:
        LOGGER.debug('CreateSliceAndAddToCatalog request: {:s}'.format(str(request)))
        response = self.stub.CreateSliceAndAddToCatalog(request)
+0 −14
Original line number Diff line number Diff line
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
+58 −57
Original line number Diff line number Diff line
@@ -3,9 +3,10 @@
import grpc

from . import context_pb2 as context__pb2
from . import slice_pb2 as slice__pb2


class ServiceServiceStub(object):
class InterdomainServiceStub(object):
    """Missing associated documentation comment in .proto file."""

    def __init__(self, channel):
@@ -14,90 +15,90 @@ class ServiceServiceStub(object):
        Args:
            channel: A grpc.Channel.
        """
        self.CreateService = channel.unary_unary(
                '/service.ServiceService/CreateService',
                request_serializer=context__pb2.Service.SerializeToString,
                response_deserializer=context__pb2.ServiceId.FromString,
        self.Authenticate = channel.unary_unary(
                '/interdomain.InterdomainService/Authenticate',
                request_serializer=context__pb2.TeraFlowController.SerializeToString,
                response_deserializer=context__pb2.AuthenticationResult.FromString,
                )
        self.UpdateService = channel.unary_unary(
                '/service.ServiceService/UpdateService',
                request_serializer=context__pb2.Service.SerializeToString,
                response_deserializer=context__pb2.ServiceId.FromString,
        self.LookUpSlice = channel.unary_unary(
                '/interdomain.InterdomainService/LookUpSlice',
                request_serializer=slice__pb2.TransportSlice.SerializeToString,
                response_deserializer=slice__pb2.SliceId.FromString,
                )
        self.DeleteService = channel.unary_unary(
                '/service.ServiceService/DeleteService',
                request_serializer=context__pb2.ServiceId.SerializeToString,
                response_deserializer=context__pb2.Empty.FromString,
        self.OrderSliceFromCatalog = channel.unary_unary(
                '/interdomain.InterdomainService/OrderSliceFromCatalog',
                request_serializer=slice__pb2.TransportSlice.SerializeToString,
                response_deserializer=slice__pb2.SliceStatus.FromString,
                )
        self.GetConnectionList = channel.unary_unary(
                '/service.ServiceService/GetConnectionList',
                request_serializer=context__pb2.ServiceId.SerializeToString,
                response_deserializer=context__pb2.ConnectionList.FromString,
        self.CreateSliceAndAddToCatalog = channel.unary_unary(
                '/interdomain.InterdomainService/CreateSliceAndAddToCatalog',
                request_serializer=slice__pb2.TransportSlice.SerializeToString,
                response_deserializer=slice__pb2.SliceStatus.FromString,
                )


class ServiceServiceServicer(object):
class InterdomainServiceServicer(object):
    """Missing associated documentation comment in .proto file."""

    def CreateService(self, request, context):
    def Authenticate(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def UpdateService(self, request, context):
    def LookUpSlice(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def DeleteService(self, request, context):
    def OrderSliceFromCatalog(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetConnectionList(self, request, context):
    def CreateSliceAndAddToCatalog(self, request, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_ServiceServiceServicer_to_server(servicer, server):
def add_InterdomainServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'CreateService': grpc.unary_unary_rpc_method_handler(
                    servicer.CreateService,
                    request_deserializer=context__pb2.Service.FromString,
                    response_serializer=context__pb2.ServiceId.SerializeToString,
            'Authenticate': grpc.unary_unary_rpc_method_handler(
                    servicer.Authenticate,
                    request_deserializer=context__pb2.TeraFlowController.FromString,
                    response_serializer=context__pb2.AuthenticationResult.SerializeToString,
            ),
            'UpdateService': grpc.unary_unary_rpc_method_handler(
                    servicer.UpdateService,
                    request_deserializer=context__pb2.Service.FromString,
                    response_serializer=context__pb2.ServiceId.SerializeToString,
            'LookUpSlice': grpc.unary_unary_rpc_method_handler(
                    servicer.LookUpSlice,
                    request_deserializer=slice__pb2.TransportSlice.FromString,
                    response_serializer=slice__pb2.SliceId.SerializeToString,
            ),
            'DeleteService': grpc.unary_unary_rpc_method_handler(
                    servicer.DeleteService,
                    request_deserializer=context__pb2.ServiceId.FromString,
                    response_serializer=context__pb2.Empty.SerializeToString,
            'OrderSliceFromCatalog': grpc.unary_unary_rpc_method_handler(
                    servicer.OrderSliceFromCatalog,
                    request_deserializer=slice__pb2.TransportSlice.FromString,
                    response_serializer=slice__pb2.SliceStatus.SerializeToString,
            ),
            'GetConnectionList': grpc.unary_unary_rpc_method_handler(
                    servicer.GetConnectionList,
                    request_deserializer=context__pb2.ServiceId.FromString,
                    response_serializer=context__pb2.ConnectionList.SerializeToString,
            'CreateSliceAndAddToCatalog': grpc.unary_unary_rpc_method_handler(
                    servicer.CreateSliceAndAddToCatalog,
                    request_deserializer=slice__pb2.TransportSlice.FromString,
                    response_serializer=slice__pb2.SliceStatus.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'service.ServiceService', rpc_method_handlers)
            'interdomain.InterdomainService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class ServiceService(object):
class InterdomainService(object):
    """Missing associated documentation comment in .proto file."""

    @staticmethod
    def CreateService(request,
    def Authenticate(request,
            target,
            options=(),
            channel_credentials=None,
@@ -107,14 +108,14 @@ class ServiceService(object):
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/service.ServiceService/CreateService',
            context__pb2.Service.SerializeToString,
            context__pb2.ServiceId.FromString,
        return grpc.experimental.unary_unary(request, target, '/interdomain.InterdomainService/Authenticate',
            context__pb2.TeraFlowController.SerializeToString,
            context__pb2.AuthenticationResult.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def UpdateService(request,
    def LookUpSlice(request,
            target,
            options=(),
            channel_credentials=None,
@@ -124,14 +125,14 @@ class ServiceService(object):
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/service.ServiceService/UpdateService',
            context__pb2.Service.SerializeToString,
            context__pb2.ServiceId.FromString,
        return grpc.experimental.unary_unary(request, target, '/interdomain.InterdomainService/LookUpSlice',
            slice__pb2.TransportSlice.SerializeToString,
            slice__pb2.SliceId.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def DeleteService(request,
    def OrderSliceFromCatalog(request,
            target,
            options=(),
            channel_credentials=None,
@@ -141,14 +142,14 @@ class ServiceService(object):
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/service.ServiceService/DeleteService',
            context__pb2.ServiceId.SerializeToString,
            context__pb2.Empty.FromString,
        return grpc.experimental.unary_unary(request, target, '/interdomain.InterdomainService/OrderSliceFromCatalog',
            slice__pb2.TransportSlice.SerializeToString,
            slice__pb2.SliceStatus.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def GetConnectionList(request,
    def CreateSliceAndAddToCatalog(request,
            target,
            options=(),
            channel_credentials=None,
@@ -158,8 +159,8 @@ class ServiceService(object):
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/service.ServiceService/GetConnectionList',
            context__pb2.ServiceId.SerializeToString,
            context__pb2.ConnectionList.FromString,
        return grpc.experimental.unary_unary(request, target, '/interdomain.InterdomainService/CreateSliceAndAddToCatalog',
            slice__pb2.TransportSlice.SerializeToString,
            slice__pb2.SliceStatus.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
+78 −0
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: kpi_sample_types.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()




DESCRIPTOR = _descriptor.FileDescriptor(
  name='kpi_sample_types.proto',
  package='kpi_sample_types',
  syntax='proto3',
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n\x16kpi_sample_types.proto\x12\x10kpi_sample_types*\xbe\x01\n\rKpiSampleType\x12\x19\n\x15KPISAMPLETYPE_UNKNOWN\x10\x00\x12%\n!KPISAMPLETYPE_PACKETS_TRANSMITTED\x10\x65\x12\"\n\x1eKPISAMPLETYPE_PACKETS_RECEIVED\x10\x66\x12$\n\x1fKPISAMPLETYPE_BYTES_TRANSMITTED\x10\xc9\x01\x12!\n\x1cKPISAMPLETYPE_BYTES_RECEIVED\x10\xca\x01\x62\x06proto3'
)

_KPISAMPLETYPE = _descriptor.EnumDescriptor(
  name='KpiSampleType',
  full_name='kpi_sample_types.KpiSampleType',
  filename=None,
  file=DESCRIPTOR,
  create_key=_descriptor._internal_create_key,
  values=[
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_UNKNOWN', index=0, number=0,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_PACKETS_TRANSMITTED', index=1, number=101,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_PACKETS_RECEIVED', index=2, number=102,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_BYTES_TRANSMITTED', index=3, number=201,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_BYTES_RECEIVED', index=4, number=202,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=45,
  serialized_end=235,
)
_sym_db.RegisterEnumDescriptor(_KPISAMPLETYPE)

KpiSampleType = enum_type_wrapper.EnumTypeWrapper(_KPISAMPLETYPE)
KPISAMPLETYPE_UNKNOWN = 0
KPISAMPLETYPE_PACKETS_TRANSMITTED = 101
KPISAMPLETYPE_PACKETS_RECEIVED = 102
KPISAMPLETYPE_BYTES_TRANSMITTED = 201
KPISAMPLETYPE_BYTES_RECEIVED = 202


DESCRIPTOR.enum_types_by_name['KpiSampleType'] = _KPISAMPLETYPE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)


# @@protoc_insertion_point(module_scope)
Loading