Skip to content
Snippets Groups Projects
Commit eaee6c8c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Defined/Corrected skeleton for Interdomain component

parent 37f647b9
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!42Interdomain Component
......@@ -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"]
......@@ -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)
......
# 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.
......@@ -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)
# -*- 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)
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: service.proto
"""Generated protocol buffer code."""
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()
from . import context_pb2 as context__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='service.proto',
package='service',
syntax='proto3',
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\rservice.proto\x12\x07service\x1a\rcontext.proto2\xfd\x01\n\x0eServiceService\x12\x37\n\rCreateService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x37\n\rUpdateService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x35\n\rDeleteService\x12\x12.context.ServiceId\x1a\x0e.context.Empty\"\x00\x12\x42\n\x11GetConnectionList\x12\x12.context.ServiceId\x1a\x17.context.ConnectionList\"\x00\x62\x06proto3'
,
dependencies=[context__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_SERVICESERVICE = _descriptor.ServiceDescriptor(
name='ServiceService',
full_name='service.ServiceService',
file=DESCRIPTOR,
index=0,
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_start=42,
serialized_end=295,
methods=[
_descriptor.MethodDescriptor(
name='CreateService',
full_name='service.ServiceService.CreateService',
index=0,
containing_service=None,
input_type=context__pb2._SERVICE,
output_type=context__pb2._SERVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='UpdateService',
full_name='service.ServiceService.UpdateService',
index=1,
containing_service=None,
input_type=context__pb2._SERVICE,
output_type=context__pb2._SERVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='DeleteService',
full_name='service.ServiceService.DeleteService',
index=2,
containing_service=None,
input_type=context__pb2._SERVICEID,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='GetConnectionList',
full_name='service.ServiceService.GetConnectionList',
index=3,
containing_service=None,
input_type=context__pb2._SERVICEID,
output_type=context__pb2._CONNECTIONLIST,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
])
_sym_db.RegisterServiceDescriptor(_SERVICESERVICE)
DESCRIPTOR.services_by_name['ServiceService'] = _SERVICESERVICE
# @@protoc_insertion_point(module_scope)
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: slice.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()
from . import context_pb2 as context__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='slice.proto',
package='slice',
syntax='proto3',
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x0bslice.proto\x12\x05slice\x1a\rcontext.proto\"3\n\rSliceEndpoint\x12\"\n\x07port_id\x18\x01 \x01(\x0b\x32\x11.context.EndPoint\"\xf4\x01\n\x0eTransportSlice\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12\'\n\tendpoints\x18\x02 \x03(\x0b\x32\x14.slice.SliceEndpoint\x12(\n\x0b\x63onstraints\x18\x03 \x03(\x0b\x32\x13.context.Constraint\x12$\n\x08services\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\x12#\n\x0bsubSlicesId\x18\x05 \x03(\x0b\x32\x0e.slice.SliceId\x12\"\n\x06status\x18\x06 \x01(\x0b\x32\x12.slice.SliceStatus\"Q\n\x07SliceId\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1f\n\x08slice_id\x18\x02 \x01(\x0b\x32\r.context.Uuid\"W\n\x0bSliceStatus\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12&\n\x06status\x18\x02 \x01(\x0e\x32\x16.slice.SliceStatusEnum*@\n\x0fSliceStatusEnum\x12\x0b\n\x07PLANNED\x10\x00\x12\x08\n\x04INIT\x10\x01\x12\n\n\x06\x41\x43TIVE\x10\x02\x12\n\n\x06\x44\x45INIT\x10\x03\x32\x88\x01\n\x0cSliceService\x12@\n\x11\x43reateUpdateSlice\x12\x15.slice.TransportSlice\x1a\x12.slice.SliceStatus\"\x00\x12\x36\n\x0b\x44\x65leteSlice\x12\x15.slice.TransportSlice\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
,
dependencies=[context__pb2.DESCRIPTOR,])
_SLICESTATUSENUM = _descriptor.EnumDescriptor(
name='SliceStatusEnum',
full_name='slice.SliceStatusEnum',
filename=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
values=[
_descriptor.EnumValueDescriptor(
name='PLANNED', index=0, number=0,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='INIT', index=1, number=1,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='ACTIVE', index=2, number=2,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
_descriptor.EnumValueDescriptor(
name='DEINIT', index=3, number=3,
serialized_options=None,
type=None,
create_key=_descriptor._internal_create_key),
],
containing_type=None,
serialized_options=None,
serialized_start=509,
serialized_end=573,
)
_sym_db.RegisterEnumDescriptor(_SLICESTATUSENUM)
SliceStatusEnum = enum_type_wrapper.EnumTypeWrapper(_SLICESTATUSENUM)
PLANNED = 0
INIT = 1
ACTIVE = 2
DEINIT = 3
_SLICEENDPOINT = _descriptor.Descriptor(
name='SliceEndpoint',
full_name='slice.SliceEndpoint',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='port_id', full_name='slice.SliceEndpoint.port_id', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=37,
serialized_end=88,
)
_TRANSPORTSLICE = _descriptor.Descriptor(
name='TransportSlice',
full_name='slice.TransportSlice',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='slice_id', full_name='slice.TransportSlice.slice_id', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='endpoints', full_name='slice.TransportSlice.endpoints', index=1,
number=2, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='constraints', full_name='slice.TransportSlice.constraints', index=2,
number=3, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='services', full_name='slice.TransportSlice.services', index=3,
number=4, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='subSlicesId', full_name='slice.TransportSlice.subSlicesId', index=4,
number=5, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='status', full_name='slice.TransportSlice.status', index=5,
number=6, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=91,
serialized_end=335,
)
_SLICEID = _descriptor.Descriptor(
name='SliceId',
full_name='slice.SliceId',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='contextId', full_name='slice.SliceId.contextId', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='slice_id', full_name='slice.SliceId.slice_id', index=1,
number=2, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=337,
serialized_end=418,
)
_SLICESTATUS = _descriptor.Descriptor(
name='SliceStatus',
full_name='slice.SliceStatus',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='slice_id', full_name='slice.SliceStatus.slice_id', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
_descriptor.FieldDescriptor(
name='status', full_name='slice.SliceStatus.status', index=1,
number=2, type=14, cpp_type=8, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=420,
serialized_end=507,
)
_SLICEENDPOINT.fields_by_name['port_id'].message_type = context__pb2._ENDPOINT
_TRANSPORTSLICE.fields_by_name['slice_id'].message_type = _SLICEID
_TRANSPORTSLICE.fields_by_name['endpoints'].message_type = _SLICEENDPOINT
_TRANSPORTSLICE.fields_by_name['constraints'].message_type = context__pb2._CONSTRAINT
_TRANSPORTSLICE.fields_by_name['services'].message_type = context__pb2._SERVICEID
_TRANSPORTSLICE.fields_by_name['subSlicesId'].message_type = _SLICEID
_TRANSPORTSLICE.fields_by_name['status'].message_type = _SLICESTATUS
_SLICEID.fields_by_name['contextId'].message_type = context__pb2._CONTEXTID
_SLICEID.fields_by_name['slice_id'].message_type = context__pb2._UUID
_SLICESTATUS.fields_by_name['slice_id'].message_type = _SLICEID
_SLICESTATUS.fields_by_name['status'].enum_type = _SLICESTATUSENUM
DESCRIPTOR.message_types_by_name['SliceEndpoint'] = _SLICEENDPOINT
DESCRIPTOR.message_types_by_name['TransportSlice'] = _TRANSPORTSLICE
DESCRIPTOR.message_types_by_name['SliceId'] = _SLICEID
DESCRIPTOR.message_types_by_name['SliceStatus'] = _SLICESTATUS
DESCRIPTOR.enum_types_by_name['SliceStatusEnum'] = _SLICESTATUSENUM
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
SliceEndpoint = _reflection.GeneratedProtocolMessageType('SliceEndpoint', (_message.Message,), {
'DESCRIPTOR' : _SLICEENDPOINT,
'__module__' : 'slice_pb2'
# @@protoc_insertion_point(class_scope:slice.SliceEndpoint)
})
_sym_db.RegisterMessage(SliceEndpoint)
TransportSlice = _reflection.GeneratedProtocolMessageType('TransportSlice', (_message.Message,), {
'DESCRIPTOR' : _TRANSPORTSLICE,
'__module__' : 'slice_pb2'
# @@protoc_insertion_point(class_scope:slice.TransportSlice)
})
_sym_db.RegisterMessage(TransportSlice)
SliceId = _reflection.GeneratedProtocolMessageType('SliceId', (_message.Message,), {
'DESCRIPTOR' : _SLICEID,
'__module__' : 'slice_pb2'
# @@protoc_insertion_point(class_scope:slice.SliceId)
})
_sym_db.RegisterMessage(SliceId)
SliceStatus = _reflection.GeneratedProtocolMessageType('SliceStatus', (_message.Message,), {
'DESCRIPTOR' : _SLICESTATUS,
'__module__' : 'slice_pb2'
# @@protoc_insertion_point(class_scope:slice.SliceStatus)
})
_sym_db.RegisterMessage(SliceStatus)
_SLICESERVICE = _descriptor.ServiceDescriptor(
name='SliceService',
full_name='slice.SliceService',
file=DESCRIPTOR,
index=0,
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_start=576,
serialized_end=712,
methods=[
_descriptor.MethodDescriptor(
name='CreateUpdateSlice',
full_name='slice.SliceService.CreateUpdateSlice',
index=0,
containing_service=None,
input_type=_TRANSPORTSLICE,
output_type=_SLICESTATUS,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='DeleteSlice',
full_name='slice.SliceService.DeleteSlice',
index=1,
containing_service=None,
input_type=_TRANSPORTSLICE,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
])
_sym_db.RegisterServiceDescriptor(_SLICESERVICE)
DESCRIPTOR.services_by_name['SliceService'] = _SLICESERVICE
# @@protoc_insertion_point(module_scope)
anytree
apscheduler
fastcache
flask-restful
grpcio-health-checking
grpcio
Jinja2
netconf-client #1.7.3
prometheus-client
pytest
pytest-benchmark
python-json-logger
pytz
redis
requests
xmltodict
p4runtime==1.3.0
coverage
grpcio==1.43.0
grpcio-health-checking==1.43.0
prometheus-client==0.13.0
pytest==6.2.5
pytest-benchmark==3.4.1
from concurrent import futures
import grpc
from interdomain.service.InterdomainServiceServicerImpl import InterdomainServiceServicerImpl
from interdomain.Config import GRPC_SLICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD
from interdomain.proto.interdomain_pb2_grpc import add_InterdomainServiceServicer_to_server
# 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.
from grpc_health.v1 import health
from grpc_health.v1 import health_pb2
import grpc, logging
from concurrent import futures
from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH
from grpc_health.v1.health_pb2 import HealthCheckResponse
from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server
from common.logger import getJSONLogger
LOGGER = getJSONLogger('interdomainservice-server')
LOGGER.setLevel('DEBUG')
from interdomain.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD
from interdomain.proto.interdomain_pb2_grpc import add_InterdomainServiceServicer_to_server
from .InterdomainServiceServicerImpl import InterdomainServiceServicerImpl
BIND_ADDRESS = '0.0.0.0'
LOGGER = logging.getLogger(__name__)
class InterdomainService:
def __init__(self, address=BIND_ADDRESS, slice_client=None, port=GRPC_INTERDOMAIN_PORT, max_workers=GRPC_MAX_WORKERS,
grace_period=GRPC_GRACE_PERIOD):
self.address = address
def __init__(
self, slice_client,
address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD):
self.slice_client = slice_client
self.address = address
self.port = port
self.endpoint = None
self.max_workers = max_workers
self.grace_period = grace_period
self.monitoring_servicer = None
self.interdomain_servicer = None
self.health_servicer = None
self.pool = None
self.server = None
def start(self):
# create gRPC server
self.server = grpc.server(futures.ThreadPoolExecutor(max_workers=self.max_workers)) # ,interceptors=(tracer_interceptor,))
self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port))
LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format(
str(self.endpoint), str(self.max_workers)))
self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers)
self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,))
# add monitoring servicer class to gRPC server
self.interdomain_servicer = InterdomainServiceServicerImpl()
add_InterdomainServiceServicer_to_server(self.interdomain_servicer, self.server)
# add gRPC health checker servicer class to gRPC server
self.health_servicer = health.HealthServicer(
self.health_servicer = HealthServicer(
experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1))
add_HealthServicer_to_server(self.health_servicer, self.server)
# start server
endpoint = '{}:{}'.format(self.address, self.port)
LOGGER.info('Listening on {}'.format(endpoint))
self.server.add_insecure_port(endpoint)
port = self.server.add_insecure_port(self.endpoint)
self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port))
LOGGER.info('Listening on {:s}...'.format(str(self.endpoint)))
self.server.start()
self.health_servicer.set('', health_pb2.HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member
self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member
LOGGER.debug('Service started')
def stop(self):
LOGGER.debug('Stopping service (grace period {} seconds)...'.format(self.grace_period))
LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period)))
self.health_servicer.enter_graceful_shutdown()
self.server.stop(self.grace_period)
LOGGER.debug('Service stopped')
import os,grpc
from interdomain.proto import interdomain_pb2
from interdomain.proto import interdomain_pb2_grpc
from common.rpc_method_wrapper.ServiceExceptions import ServiceException
from common.logger import getJSONLogger
from context.proto import context_pb2
from slice.Config import GRPC_SERVICE_PORT
from slice.client.SliceClient import SliceClient
from slice.proto import slice_pb2
LOGGER = getJSONLogger('interdomainservice-server')
LOGGER.setLevel('DEBUG')
class InterdomainServiceServicerImpl(interdomain_pb2_grpc.InterdomainServiceServicer):
# 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.
import grpc, logging
from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method
from interdomain.proto.context_pb2 import AuthenticationResult, TeraFlowController
from interdomain.proto.slice_pb2 import SliceId, SliceStatus, TransportSlice
from interdomain.proto.interdomain_pb2_grpc import InterdomainServiceServicer
LOGGER = logging.getLogger(__name__)
SERVICE_NAME = 'Interdomain'
METHOD_NAMES = ['Authenticate', 'LookUpSlice', 'OrderSliceFromCatalog', 'CreateSliceAndAddToCatalog']
METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES)
class InterdomainServiceServicerImpl(InterdomainServiceServicer):
def __init__(self):
LOGGER.info('Init InterdomainService')
LOGGER.debug('Creating Servicer...')
LOGGER.debug('Servicer Created')
# rpc Authenticate (context.TeraFlowController) returns (context.AuthenticationResult) {}
def Authenticate(self, request : context_pb2.TeraFlowController) -> context_pb2.AuthenticationResult :
LOGGER.info('Authenticate')
auth_result = context_pb2.AuthenticationResult()
auth_result.context_id = 0
@safe_and_metered_rpc_method(METRICS, LOGGER)
def Authenticate(self, request : TeraFlowController, context : grpc.ServicerContext) -> AuthenticationResult:
auth_result = AuthenticationResult()
#auth_result.context_id = ...
auth_result.authenticated = True
return auth_result
# rpc LookUpSlice(slice.TransportSlice) returns (slice.SliceId) {}
def LookUpSlice ( self, request : slice_pb2.TransportSlice) -> slice_pb2.SliceId:
LOGGER.info('LookUpSlice')
try:
slice_id = slice_pb2.SliceId()
return sliceId
except Exception as e:
LOGGER.exception('LookUpSlice exception')
# rpc OrderSliceFromCatalog(slice.TransportSlice) returns (slice.SliceStatus) {}
def OrderSliceFromCatalog(self, request : slice_pb2.TransportSlice) -> slice_pb2.SliceStatus:
LOGGER.info('OrderSliceFromCatalog')
try:
slice_status=slice_pb2.SliceStatus()
return slice_status
except Exception as e: # pragma: no cover
LOGGER.exception('OrderSliceFromCatalog exception')
# rpc CreateSliceAndAddToCatalog(slice.TransportSlice) returns (slice.SliceStatus) {}
def CreateSliceAndAddToCatalog(self, request : slice_pb2.TransportSlice) -> slice_pb2.SliceStatus:
LOGGER.info('OrderSliceFromCatalog')
try:
slice_status=slice_pb2.SliceStatus()
return slice_status
except Exception as e: # pragma: no cover
LOGGER.exception('OrderSliceFromCatalog exception')
@safe_and_metered_rpc_method(METRICS, LOGGER)
def LookUpSlice(self, request : TransportSlice, context : grpc.ServicerContext) -> SliceId:
return SliceId()
@safe_and_metered_rpc_method(METRICS, LOGGER)
def OrderSliceFromCatalog(self, request : TransportSlice, context : grpc.ServicerContext) -> SliceStatus:
return SliceStatus()
@safe_and_metered_rpc_method(METRICS, LOGGER)
def CreateSliceAndAddToCatalog(self, request : TransportSlice, context : grpc.ServicerContext) -> SliceStatus:
return SliceStatus()
......@@ -14,15 +14,13 @@
import logging, signal, sys, threading
from prometheus_client import start_http_server
from common.Settings import get_setting
from common.Settings import get_setting, wait_for_environment_variables
from slice.client.SliceClient import SliceClient
from interdomain.Config import (
SLICE_SERVICE_HOST, SLICE_SERVICE_PORT, GRPC_INTERDOMAIN_PORT,
GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT)
SLICE_SERVICE_HOST, SLICE_SERVICE_PORT, GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL,
METRICS_PORT)
from .InterdomainService import InterdomainService
terminate = threading.Event()
LOGGER : logging.Logger = None
......@@ -33,22 +31,22 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name
def main():
global LOGGER # pylint: disable=global-statement
grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT )
max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS )
grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD )
log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL )
metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT )
grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT )
max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS )
grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD )
log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL )
metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT )
logging.basicConfig(level=log_level)
LOGGER = logging.getLogger(__name__)
wait_for_environment_variables([
'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC',
'MONITORINGSERVICE_SERVICE_HOST', 'MONITORINGSERVICE_SERVICE_PORT_GRPC'
])
#wait_for_environment_variables([
# 'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC',
# 'MONITORINGSERVICE_SERVICE_HOST', 'MONITORINGSERVICE_SERVICE_PORT_GRPC'
#])
slice_service_host = get_setting('SLICESERVICE_SERVICE_HOST', default=SLICE_SERVICE_HOST )
slice_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=SLICE_SERVICE_PORT )
slice_service_host = get_setting('SLICESERVICE_SERVICE_HOST', default=SLICE_SERVICE_HOST )
slice_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=SLICE_SERVICE_PORT )
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
......@@ -58,23 +56,23 @@ def main():
# Start metrics server
start_http_server(metrics_port)
# Initialize Slice Client
if slice_service_host is None or slice_service_port is None:
raise Exception('Wrong address({:s}):port({:s}) of Slice component'.format(
str(slice_service_host), str(slice_service_port)))
slice_client = SliceClient(slice_service_host, slice_service_port)
## Initialize Slice Client
#if slice_service_host is None or slice_service_port is None:
# raise Exception('Wrong address({:s}):port({:s}) of Slice component'.format(
# str(slice_service_host), str(slice_service_port)))
#slice_client = SliceClient(slice_service_host, slice_service_port)
# Starting Interdomain service
grpc_interdomain = InterdomainService(
slice_client=slice_client, port=grpc_interdomain_port, max_workers=max_workers,
grpc_service = InterdomainService(
slice_client, port=grpc_service_port, max_workers=max_workers,
grace_period=grace_period)
grpc_interdomain.start()
grpc_service.start()
# Wait for Ctrl+C or termination signal
while not terminate.wait(timeout=0.1): pass
LOGGER.info('Terminating...')
grpc_interdomain.stop()
grpc_service.stop()
LOGGER.info('Bye')
return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment