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

Core components:

- Enabled gRPC Reflection
- Added scripts to inspect core gRPC components
parent 6f9c0bd2
No related branches found
No related tags found
3 merge requests!346Draft: support for restconf protocol,!345Draft: support ipinfusion devices via netconf,!312Resolve "Enable gRPC reflection in Python-based services"
Showing with 254 additions and 17 deletions
#!/bin/bash
# Copyright 2022-2024 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
# Ref: https://github.com/fullstorydev/grpcurl
source tfs_runtime_env_vars.sh
GRPC_ENDPOINT="$CONTEXTSERVICE_SERVICE_HOST:$CONTEXTSERVICE_SERVICE_PORT_GRPC"
GRP_CURL_CMD="docker run fullstorydev/grpcurl --plaintext $GRPC_ENDPOINT"
GRPC_SERVICES=`$GRP_CURL_CMD list`
echo "gRPC Services found in $GRPC_ENDPOINT:"
printf "\n"
for GRPC_SERVICE in $GRPC_SERVICES; do
echo "gRPC Service: $GRPC_SERVICE"
$GRP_CURL_CMD describe $GRPC_SERVICE
printf "\n"
done
echo "Done!"
#!/bin/bash
# Copyright 2022-2024 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
# Ref: https://github.com/fullstorydev/grpcurl
source tfs_runtime_env_vars.sh
GRPC_ENDPOINT="$DEVICESERVICE_SERVICE_HOST:$DEVICESERVICE_SERVICE_PORT_GRPC"
GRP_CURL_CMD="docker run fullstorydev/grpcurl --plaintext $GRPC_ENDPOINT"
GRPC_SERVICES=`$GRP_CURL_CMD list`
echo "gRPC Services found in $GRPC_ENDPOINT:"
printf "\n"
for GRPC_SERVICE in $GRPC_SERVICES; do
echo "gRPC Service: $GRPC_SERVICE"
$GRP_CURL_CMD describe $GRPC_SERVICE
printf "\n"
done
echo "Done!"
#!/bin/bash
# Copyright 2022-2024 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
# Ref: https://github.com/fullstorydev/grpcurl
source tfs_runtime_env_vars.sh
GRPC_ENDPOINT="$PATHCOMPSERVICE_SERVICE_HOST:$PATHCOMPSERVICE_SERVICE_PORT_GRPC"
GRP_CURL_CMD="docker run fullstorydev/grpcurl --plaintext $GRPC_ENDPOINT"
GRPC_SERVICES=`$GRP_CURL_CMD list`
echo "gRPC Services found in $GRPC_ENDPOINT:"
printf "\n"
for GRPC_SERVICE in $GRPC_SERVICES; do
echo "gRPC Service: $GRPC_SERVICE"
$GRP_CURL_CMD describe $GRPC_SERVICE
printf "\n"
done
echo "Done!"
#!/bin/bash
# Copyright 2022-2024 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
# Ref: https://github.com/fullstorydev/grpcurl
source tfs_runtime_env_vars.sh
GRPC_ENDPOINT="$SERVICESERVICE_SERVICE_HOST:$SERVICESERVICE_SERVICE_PORT_GRPC"
GRP_CURL_CMD="docker run fullstorydev/grpcurl --plaintext $GRPC_ENDPOINT"
GRPC_SERVICES=`$GRP_CURL_CMD list`
echo "gRPC Services found in $GRPC_ENDPOINT:"
printf "\n"
for GRPC_SERVICE in $GRPC_SERVICES; do
echo "gRPC Service: $GRPC_SERVICE"
$GRP_CURL_CMD describe $GRPC_SERVICE
printf "\n"
done
echo "Done!"
#!/bin/bash
# Copyright 2022-2024 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.
########################################################################################################################
# Define your deployment settings here
########################################################################################################################
# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}
########################################################################################################################
# Automated steps start here
########################################################################################################################
# Ref: https://github.com/fullstorydev/grpcurl
source tfs_runtime_env_vars.sh
GRPC_ENDPOINT="$SLICESERVICE_SERVICE_HOST:$SLICESERVICE_SERVICE_PORT_GRPC"
GRP_CURL_CMD="docker run fullstorydev/grpcurl --plaintext $GRPC_ENDPOINT"
GRPC_SERVICES=`$GRP_CURL_CMD list`
echo "gRPC Services found in $GRPC_ENDPOINT:"
printf "\n"
for GRPC_SERVICE in $GRPC_SERVICES; do
echo "gRPC Service: $GRPC_SERVICE"
$GRP_CURL_CMD describe $GRPC_SERVICE
printf "\n"
done
echo "Done!"
...@@ -16,7 +16,9 @@ import logging, sqlalchemy ...@@ -16,7 +16,9 @@ import logging, sqlalchemy
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.message_broker.MessageBroker import MessageBroker from common.message_broker.MessageBroker import MessageBroker
from common.proto.context_pb2 import DESCRIPTOR as CONTEXT_DESCRIPTOR
from common.proto.context_pb2_grpc import add_ContextServiceServicer_to_server from common.proto.context_pb2_grpc import add_ContextServiceServicer_to_server
from common.proto.context_policy_pb2 import DESCRIPTOR as CONTEXT_POLICY_DESCRIPTOR
from common.proto.context_policy_pb2_grpc import add_ContextPolicyServiceServicer_to_server from common.proto.context_policy_pb2_grpc import add_ContextPolicyServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from .ContextServiceServicerImpl import ContextServiceServicerImpl from .ContextServiceServicerImpl import ContextServiceServicerImpl
...@@ -36,3 +38,6 @@ class ContextService(GenericGrpcService): ...@@ -36,3 +38,6 @@ class ContextService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
add_ContextServiceServicer_to_server(self.context_servicer, self.server) add_ContextServiceServicer_to_server(self.context_servicer, self.server)
add_ContextPolicyServiceServicer_to_server(self.context_servicer, self.server) add_ContextPolicyServiceServicer_to_server(self.context_servicer, self.server)
self.add_reflection_service_name(CONTEXT_DESCRIPTOR, 'ContextService')
self.add_reflection_service_name(CONTEXT_POLICY_DESCRIPTOR, 'ContextPolicyService')
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import os
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.device_pb2 import DESCRIPTOR as DEVICE_DESCRIPTOR
from common.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server from common.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server
from common.proto.optical_device_pb2 import DESCRIPTOR as OPTICAL_DEVICE_DESCRIPTOR
from common.proto.optical_device_pb2_grpc import add_OpenConfigServiceServicer_to_server from common.proto.optical_device_pb2_grpc import add_OpenConfigServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from device.Config import LOAD_ALL_DEVICE_DRIVERS from device.Config import LOAD_ALL_DEVICE_DRIVERS
...@@ -41,8 +42,11 @@ class DeviceService(GenericGrpcService): ...@@ -41,8 +42,11 @@ class DeviceService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
self.monitoring_loops.start() self.monitoring_loops.start()
add_DeviceServiceServicer_to_server(self.device_servicer, self.server) add_DeviceServiceServicer_to_server(self.device_servicer, self.server)
self.add_reflection_service_name(DEVICE_DESCRIPTOR, 'DeviceService')
if LOAD_ALL_DEVICE_DRIVERS: if LOAD_ALL_DEVICE_DRIVERS:
add_OpenConfigServiceServicer_to_server(self.openconfig_device_servicer,self.server) add_OpenConfigServiceServicer_to_server(self.openconfig_device_servicer,self.server)
self.add_reflection_service_name(OPTICAL_DEVICE_DESCRIPTOR, 'OpenConfigService')
def stop(self): def stop(self):
super().stop() super().stop()
......
...@@ -12,19 +12,15 @@ ...@@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.proto.e2eorchestrator_pb2_grpc import add_E2EOrchestratorServiceServicer_to_server
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.e2eorchestrator_pb2 import DESCRIPTOR as E2EORCHESTRATOR_DESCRIPTOR
from common.proto.e2eorchestrator_pb2_grpc import add_E2EOrchestratorServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from .E2EOrchestratorServiceServicerImpl import E2EOrchestratorServiceServicerImpl from .E2EOrchestratorServiceServicerImpl import E2EOrchestratorServiceServicerImpl
LOGGER = logging.getLogger(__name__)
class E2EOrchestratorService(GenericGrpcService): class E2EOrchestratorService(GenericGrpcService):
def __init__(self, cls_name: str = __name__): def __init__(self, cls_name: str = __name__) -> None:
port = get_service_port_grpc(ServiceNameEnum.E2EORCHESTRATOR) port = get_service_port_grpc(ServiceNameEnum.E2EORCHESTRATOR)
super().__init__(port, cls_name=cls_name) super().__init__(port, cls_name=cls_name)
self.e2eorchestrator_servicer = E2EOrchestratorServiceServicerImpl() self.e2eorchestrator_servicer = E2EOrchestratorServiceServicerImpl()
...@@ -33,3 +29,5 @@ class E2EOrchestratorService(GenericGrpcService): ...@@ -33,3 +29,5 @@ class E2EOrchestratorService(GenericGrpcService):
add_E2EOrchestratorServiceServicer_to_server( add_E2EOrchestratorServiceServicer_to_server(
self.e2eorchestrator_servicer, self.server self.e2eorchestrator_servicer, self.server
) )
self.add_reflection_service_name(E2EORCHESTRATOR_DESCRIPTOR, 'E2EOrchestratorService')
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.forecaster_pb2 import DESCRIPTOR as FORECASTER_DESCRIPTOR
from common.proto.forecaster_pb2_grpc import add_ForecasterServiceServicer_to_server from common.proto.forecaster_pb2_grpc import add_ForecasterServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from .ForecasterServiceServicerImpl import ForecasterServiceServicerImpl from .ForecasterServiceServicerImpl import ForecasterServiceServicerImpl
...@@ -26,3 +27,5 @@ class ForecasterService(GenericGrpcService): ...@@ -26,3 +27,5 @@ class ForecasterService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
add_ForecasterServiceServicer_to_server(self.forecaster_servicer, self.server) add_ForecasterServiceServicer_to_server(self.forecaster_servicer, self.server)
self.add_reflection_service_name(FORECASTER_DESCRIPTOR, 'ForecasterService')
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.tools.service.GenericGrpcService import GenericGrpcService from common.proto.pathcomp_pb2 import DESCRIPTOR as PATHCOMP_DESCRIPTOR
from common.proto.pathcomp_pb2_grpc import add_PathCompServiceServicer_to_server from common.proto.pathcomp_pb2_grpc import add_PathCompServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService
from .PathCompServiceServicerImpl import PathCompServiceServicerImpl from .PathCompServiceServicerImpl import PathCompServiceServicerImpl
class PathCompService(GenericGrpcService): class PathCompService(GenericGrpcService):
...@@ -26,3 +27,5 @@ class PathCompService(GenericGrpcService): ...@@ -26,3 +27,5 @@ class PathCompService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
add_PathCompServiceServicer_to_server(self.pathcomp_servicer, self.server) add_PathCompServiceServicer_to_server(self.pathcomp_servicer, self.server)
self.add_reflection_service_name(PATHCOMP_DESCRIPTOR, 'PathCompService')
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.service_pb2 import DESCRIPTOR as SERVICE_DESCRIPTOR
from common.proto.service_pb2_grpc import add_ServiceServiceServicer_to_server from common.proto.service_pb2_grpc import add_ServiceServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from .ServiceServiceServicerImpl import ServiceServiceServicerImpl from .ServiceServiceServicerImpl import ServiceServiceServicerImpl
...@@ -27,3 +28,5 @@ class ServiceService(GenericGrpcService): ...@@ -27,3 +28,5 @@ class ServiceService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
add_ServiceServiceServicer_to_server(self.service_servicer, self.server) add_ServiceServiceServicer_to_server(self.service_servicer, self.server)
self.add_reflection_service_name(SERVICE_DESCRIPTOR, 'ServiceService')
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.slice_pb2 import DESCRIPTOR as SLICE_DESCRIPTOR
from common.proto.slice_pb2_grpc import add_SliceServiceServicer_to_server from common.proto.slice_pb2_grpc import add_SliceServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from slice.service.SliceServiceServicerImpl import SliceServiceServicerImpl from .SliceServiceServicerImpl import SliceServiceServicerImpl
class SliceService(GenericGrpcService): class SliceService(GenericGrpcService):
def __init__(self, cls_name: str = __name__) -> None: def __init__(self, cls_name: str = __name__) -> None:
...@@ -26,3 +27,5 @@ class SliceService(GenericGrpcService): ...@@ -26,3 +27,5 @@ class SliceService(GenericGrpcService):
def install_servicers(self): def install_servicers(self):
add_SliceServiceServicer_to_server(self.slice_servicer, self.server) add_SliceServiceServicer_to_server(self.slice_servicer, self.server)
self.add_reflection_service_name(SLICE_DESCRIPTOR, 'SliceService')
...@@ -12,19 +12,15 @@ ...@@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging
from common.Constants import ServiceNameEnum from common.Constants import ServiceNameEnum
from common.proto.vnt_manager_pb2_grpc import add_VNTManagerServiceServicer_to_server
from common.Settings import get_service_port_grpc from common.Settings import get_service_port_grpc
from common.proto.vnt_manager_pb2 import DESCRIPTOR as VNT_MANAGER_DESCRIPTOR
from common.proto.vnt_manager_pb2_grpc import add_VNTManagerServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService from common.tools.service.GenericGrpcService import GenericGrpcService
from .VNTManagerServiceServicerImpl import VNTManagerServiceServicerImpl from .VNTManagerServiceServicerImpl import VNTManagerServiceServicerImpl
LOGGER = logging.getLogger(__name__)
class VNTManagerService(GenericGrpcService): class VNTManagerService(GenericGrpcService):
def __init__(self, cls_name: str = __name__): def __init__(self, cls_name: str = __name__) -> None:
port = get_service_port_grpc(ServiceNameEnum.VNTMANAGER) port = get_service_port_grpc(ServiceNameEnum.VNTMANAGER)
super().__init__(port, cls_name=cls_name) super().__init__(port, cls_name=cls_name)
self.vntmanager_servicer = VNTManagerServiceServicerImpl() self.vntmanager_servicer = VNTManagerServiceServicerImpl()
...@@ -33,3 +29,5 @@ class VNTManagerService(GenericGrpcService): ...@@ -33,3 +29,5 @@ class VNTManagerService(GenericGrpcService):
add_VNTManagerServiceServicer_to_server( add_VNTManagerServiceServicer_to_server(
self.vntmanager_servicer, self.server self.vntmanager_servicer, self.server
) )
self.add_reflection_service_name(VNT_MANAGER_DESCRIPTOR, 'VNTManagerService')
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