diff --git a/manifests/computeservice.yaml b/manifests/computeservice.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cdca52eb890d832cfb56457b89d44a045ee4af57 --- /dev/null +++ b/manifests/computeservice.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: computeservice +spec: + selector: + matchLabels: + app: computeservice + template: + metadata: + labels: + app: computeservice + spec: + terminationGracePeriodSeconds: 5 + containers: + - name: server + image: registry.gitlab.com/teraflow-h2020/controller/compute:latest + imagePullPolicy: Always + ports: + - containerPort: 9090 + env: + - name: LOG_LEVEL + value: "DEBUG" + readinessProbe: + exec: + command: ["/bin/grpc_health_probe", "-addr=:9090"] + livenessProbe: + exec: + command: ["/bin/grpc_health_probe", "-addr=:9090"] + resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: 700m + memory: 1024Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: computeservice +spec: + type: ClusterIP + selector: + app: computeservice + ports: + - name: grpc + port: 9090 + targetPort: 9090 +--- +apiVersion: v1 +kind: Service +metadata: + name: computeservice-public + labels: + app: computeservice +spec: + type: NodePort + selector: + app: computeservice + ports: + - name: grpc + protocol: TCP + port: 9090 + targetPort: 9090 +--- diff --git a/proto/compute.proto b/proto/compute.proto index c3c1340ec6d7f2fb90afdb91768504fa4d3cca61..ac219471de73a9fc3574c8748983d56c17717947 100644 --- a/proto/compute.proto +++ b/proto/compute.proto @@ -1,4 +1,3 @@ -//Example of topology syntax = "proto3"; package compute; @@ -14,10 +13,3 @@ service ComputeService { rpc get_all_active_connectivity_services ( context.Empty ) returns ( service.ServiceIdList ) {} rpc clear_all_connectivity_services ( context.Empty ) returns ( context.Empty ) {} } - - - - - - - diff --git a/report_coverage_compute.sh b/report_coverage_compute.sh new file mode 100755 index 0000000000000000000000000000000000000000..b63d279ed587a6fce66d08bd71820bfa96e95140 --- /dev/null +++ b/report_coverage_compute.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./report_coverage_all.sh | grep --color -E -i "^compute/.*$|$" diff --git a/run_local_tests.sh b/run_local_tests.sh index 59aef4c79f8e179e432db74b37cfc9cc01a201b2..c817a792ddfbb203cb72d4aa9dcc1cbd56456196 100755 --- a/run_local_tests.sh +++ b/run_local_tests.sh @@ -22,6 +22,9 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ service/tests/test_unitary.py +coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ + compute/tests/test_unitary.py + # Run integration tests and analyze coverage of code at same time export DB_ENGINE='redis' export REDIS_SERVICE_HOST='10.1.7.194' diff --git a/src/compute/.gitlab-ci.yml b/src/compute/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..9021dd3f4fe948176b7427814596fada13de99bf --- /dev/null +++ b/src/compute/.gitlab-ci.yml @@ -0,0 +1,60 @@ +# Build, tag, and push the Docker images to the GitLab Docker registry +build compute: + variables: + IMAGE_NAME: 'compute' # name of the microservice + IMAGE_NAME_TEST: 'compute-test' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: build + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ + - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + rules: + - changes: + - src/$IMAGE_NAME/** + - .gitlab-ci.yml + +# Pull, execute, and run unitary tests for the Docker image from the GitLab registry +unit_test compute: + variables: + IMAGE_NAME: 'compute' # name of the microservice + IMAGE_NAME_TEST: 'compute-test' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: unit_test + needs: + - build compute + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi + script: + - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - docker run -d -p 9090:9090 --name $IMAGE_NAME --network=teraflowbridge "$IMAGE_NAME:$IMAGE_TAG" + - docker ps -a + - sleep 5 + - docker ps -a + - docker logs $IMAGE_NAME + - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py" + after_script: + - docker stop $IMAGE_NAME + - docker rm $IMAGE_NAME + rules: + - changes: + - src/$IMAGE_NAME/** + - .gitlab-ci.yml + +# Deployment of the service in Kubernetes Cluster +deploy compute: + stage: deploy + needs: + - build compute + - unit_test compute + - dependencies all + - integ_test execute + script: + - kubectl version + - kubectl get all + - kubectl apply -f "manifests/computeservice.yaml" + - kubectl delete pods --selector app=computeservice + - kubectl get all diff --git a/src/compute/Config.py b/src/compute/Config.py new file mode 100644 index 0000000000000000000000000000000000000000..15efeda4f38136a4d122b61be643212d9897680a --- /dev/null +++ b/src/compute/Config.py @@ -0,0 +1,12 @@ +import logging + +# General settings +LOG_LEVEL = logging.WARNING + +# gRPC settings +GRPC_SERVICE_PORT = 9090 +GRPC_MAX_WORKERS = 10 +GRPC_GRACE_PERIOD = 60 + +# Prometheus settings +METRICS_PORT = 9192 diff --git a/src/compute/Dockerfile b/src/compute/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..83e4fad35704dd8febb8aa627936d54c02e89f68 --- /dev/null +++ b/src/compute/Dockerfile @@ -0,0 +1,35 @@ +FROM python:3-slim + +# Install dependencies +RUN apt-get --yes --quiet --quiet update && \ + apt-get --yes --quiet --quiet install wget g++ && \ + rm -rf /var/lib/apt/lists/* + +# Set Python to show logs as they occur +ENV PYTHONUNBUFFERED=0 + +# Download the gRPC health probe +RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe + +# Get generic Python packages +RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools + +# Set working directory +WORKDIR /var/teraflow + +# Create module sub-folders +RUN mkdir -p /var/teraflow/compute + +# Get Python packages per module +COPY compute/requirements.in compute/requirements.in +RUN pip-compile --output-file=compute/requirements.txt compute/requirements.in +RUN python3 -m pip install -r compute/requirements.in + +# Add files into working directory +COPY common/. common +COPY compute/. compute + +# Start compute service +ENTRYPOINT ["python", "-m", "compute.service"] diff --git a/src/compute/__init__.py b/src/compute/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/compute/client/ComputeClient.py b/src/compute/client/ComputeClient.py new file mode 100644 index 0000000000000000000000000000000000000000..ad651303dd5a78b36720be2d6ef6a0f2383a4f29 --- /dev/null +++ b/src/compute/client/ComputeClient.py @@ -0,0 +1,82 @@ +import grpc, logging +from common.tools.client.RetryDecorator import retry, delay_exponential +from compute.proto.compute_pb2_grpc import ComputeServiceStub +from compute.proto.context_pb2 import AuthenticationResult, Empty, TeraFlowController +from compute.proto.service_pb2 import Service, ServiceId, ServiceIdList, ServiceState + +LOGGER = logging.getLogger(__name__) +MAX_RETRIES = 15 +DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) + +class ComputeClient: + def __init__(self, address, port): + self.endpoint = '{}:{}'.format(address, port) + LOGGER.debug('Creating channel to {}...'.format(self.endpoint)) + self.channel = None + self.stub = None + self.connect() + LOGGER.debug('Channel created') + + def connect(self): + self.channel = grpc.insecure_channel(self.endpoint) + self.stub = ComputeServiceStub(self.channel) + + def close(self): + if(self.channel is not None): self.channel.close() + self.channel = None + self.stub = None + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def CheckCredentials(self, request : TeraFlowController) -> AuthenticationResult: + LOGGER.debug('CheckCredentials request: {}'.format(request)) + response = self.stub.check_credentials(request) + LOGGER.debug('CheckCredentials result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def GetConnectivityServiceStatus(self, request : ServiceId) -> ServiceState: + LOGGER.debug('GetConnectivityServiceStatus request: {}'.format(request)) + response = self.stub.get_connectivity_service_status(request) + LOGGER.debug('GetConnectivityServiceStatus result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def CreateConnectivityService(self, request : Service) -> ServiceId: + LOGGER.debug('CreateConnectivityService request: {}'.format(request)) + response = self.stub.create_connectivity_service(request) + LOGGER.debug('CreateConnectivityService result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def EditConnectivityService(self, request : Service) -> ServiceId: + LOGGER.debug('EditConnectivityService request: {}'.format(request)) + response = self.stub.edit_connectivity_service(request) + LOGGER.debug('EditConnectivityService result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def DeleteConnectivityService(self, request : Service) -> Empty: + LOGGER.debug('DeleteConnectivityService request: {}'.format(request)) + response = self.stub.delete_connectivity_service(request) + LOGGER.debug('DeleteConnectivityService result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def GetAllActiveConnectivityServices(self, request : Empty) -> ServiceIdList: + LOGGER.debug('GetAllActiveConnectivityServices request: {}'.format(request)) + response = self.stub.get_all_active_connectivity_services(request) + LOGGER.debug('GetAllActiveConnectivityServices result: {}'.format(response)) + return response + + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def ClearAllConnectivityServices(self, request : Empty) -> Empty: + LOGGER.debug('ClearAllConnectivityServices request: {}'.format(request)) + response = self.stub.clear_all_connectivity_services(request) + LOGGER.debug('ClearAllConnectivityServices result: {}'.format(response)) + return response diff --git a/src/compute/client/__init__.py b/src/compute/client/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/compute/genproto.sh b/src/compute/genproto.sh new file mode 100755 index 0000000000000000000000000000000000000000..01c247db1659aa36f8bb68258ff7aba974a689c8 --- /dev/null +++ b/src/compute/genproto.sh @@ -0,0 +1,36 @@ +#!/bin/bash -eu +# +# Copyright 2018 Google LLC +# +# 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. + +#!/bin/bash -e + +# Make folder containing the script the root folder for its execution +cd $(dirname $0) + +rm -rf proto/*.py +rm -rf proto/__pycache__ +touch proto/__init__.py + +python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto context.proto +python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto service.proto +python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto compute.proto + +rm proto/context_pb2_grpc.py +rm proto/service_pb2_grpc.py + +sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/context_pb2.py +sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/service_pb2.py +sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/compute_pb2.py +sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/compute_pb2_grpc.py diff --git a/src/compute/proto/__init__.py b/src/compute/proto/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/compute/proto/compute_pb2.py b/src/compute/proto/compute_pb2.py new file mode 100644 index 0000000000000000000000000000000000000000..6cdb33c620a979c997cd9b5e1fe16f59f2f5ef29 --- /dev/null +++ b/src/compute/proto/compute_pb2.py @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: compute.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 +from . import service_pb2 as service__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='compute.proto', + package='compute', + syntax='proto3', + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n\rcompute.proto\x12\x07\x63ompute\x1a\rcontext.proto\x1a\rservice.proto2\x99\x04\n\x0e\x43omputeService\x12Q\n\x11\x63heck_credentials\x12\x1b.context.TeraFlowController\x1a\x1d.context.AuthenticationResult\"\x00\x12N\n\x1fget_connectivity_service_status\x12\x12.service.ServiceId\x1a\x15.service.ServiceState\"\x00\x12\x45\n\x1b\x63reate_connectivity_service\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12\x43\n\x19\x65\x64it_connectivity_service\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12\x41\n\x1b\x64\x65lete_connectivity_service\x12\x10.service.Service\x1a\x0e.context.Empty\"\x00\x12P\n$get_all_active_connectivity_services\x12\x0e.context.Empty\x1a\x16.service.ServiceIdList\"\x00\x12\x43\n\x1f\x63lear_all_connectivity_services\x12\x0e.context.Empty\x1a\x0e.context.Empty\"\x00\x62\x06proto3' + , + dependencies=[context__pb2.DESCRIPTOR,service__pb2.DESCRIPTOR,]) + + + +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + +_COMPUTESERVICE = _descriptor.ServiceDescriptor( + name='ComputeService', + full_name='compute.ComputeService', + file=DESCRIPTOR, + index=0, + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_start=57, + serialized_end=594, + methods=[ + _descriptor.MethodDescriptor( + name='check_credentials', + full_name='compute.ComputeService.check_credentials', + index=0, + containing_service=None, + input_type=context__pb2._TERAFLOWCONTROLLER, + output_type=context__pb2._AUTHENTICATIONRESULT, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='get_connectivity_service_status', + full_name='compute.ComputeService.get_connectivity_service_status', + index=1, + containing_service=None, + input_type=service__pb2._SERVICEID, + output_type=service__pb2._SERVICESTATE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='create_connectivity_service', + full_name='compute.ComputeService.create_connectivity_service', + index=2, + containing_service=None, + input_type=service__pb2._SERVICE, + output_type=service__pb2._SERVICEID, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='edit_connectivity_service', + full_name='compute.ComputeService.edit_connectivity_service', + index=3, + containing_service=None, + input_type=service__pb2._SERVICE, + output_type=service__pb2._SERVICEID, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='delete_connectivity_service', + full_name='compute.ComputeService.delete_connectivity_service', + index=4, + containing_service=None, + input_type=service__pb2._SERVICE, + output_type=context__pb2._EMPTY, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='get_all_active_connectivity_services', + full_name='compute.ComputeService.get_all_active_connectivity_services', + index=5, + containing_service=None, + input_type=context__pb2._EMPTY, + output_type=service__pb2._SERVICEIDLIST, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='clear_all_connectivity_services', + full_name='compute.ComputeService.clear_all_connectivity_services', + index=6, + containing_service=None, + input_type=context__pb2._EMPTY, + output_type=context__pb2._EMPTY, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), +]) +_sym_db.RegisterServiceDescriptor(_COMPUTESERVICE) + +DESCRIPTOR.services_by_name['ComputeService'] = _COMPUTESERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/src/compute/proto/compute_pb2_grpc.py b/src/compute/proto/compute_pb2_grpc.py new file mode 100644 index 0000000000000000000000000000000000000000..a5ceb93c594acc3440a7265caa4583ecaaf5feb1 --- /dev/null +++ b/src/compute/proto/compute_pb2_grpc.py @@ -0,0 +1,265 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +from . import context_pb2 as context__pb2 +from . import service_pb2 as service__pb2 + + +class ComputeServiceStub(object): + """Missing associated documentation comment in .proto file.""" + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.check_credentials = channel.unary_unary( + '/compute.ComputeService/check_credentials', + request_serializer=context__pb2.TeraFlowController.SerializeToString, + response_deserializer=context__pb2.AuthenticationResult.FromString, + ) + self.get_connectivity_service_status = channel.unary_unary( + '/compute.ComputeService/get_connectivity_service_status', + request_serializer=service__pb2.ServiceId.SerializeToString, + response_deserializer=service__pb2.ServiceState.FromString, + ) + self.create_connectivity_service = channel.unary_unary( + '/compute.ComputeService/create_connectivity_service', + request_serializer=service__pb2.Service.SerializeToString, + response_deserializer=service__pb2.ServiceId.FromString, + ) + self.edit_connectivity_service = channel.unary_unary( + '/compute.ComputeService/edit_connectivity_service', + request_serializer=service__pb2.Service.SerializeToString, + response_deserializer=service__pb2.ServiceId.FromString, + ) + self.delete_connectivity_service = channel.unary_unary( + '/compute.ComputeService/delete_connectivity_service', + request_serializer=service__pb2.Service.SerializeToString, + response_deserializer=context__pb2.Empty.FromString, + ) + self.get_all_active_connectivity_services = channel.unary_unary( + '/compute.ComputeService/get_all_active_connectivity_services', + request_serializer=context__pb2.Empty.SerializeToString, + response_deserializer=service__pb2.ServiceIdList.FromString, + ) + self.clear_all_connectivity_services = channel.unary_unary( + '/compute.ComputeService/clear_all_connectivity_services', + request_serializer=context__pb2.Empty.SerializeToString, + response_deserializer=context__pb2.Empty.FromString, + ) + + +class ComputeServiceServicer(object): + """Missing associated documentation comment in .proto file.""" + + def check_credentials(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 get_connectivity_service_status(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 create_connectivity_service(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 edit_connectivity_service(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 delete_connectivity_service(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 get_all_active_connectivity_services(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 clear_all_connectivity_services(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_ComputeServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + 'check_credentials': grpc.unary_unary_rpc_method_handler( + servicer.check_credentials, + request_deserializer=context__pb2.TeraFlowController.FromString, + response_serializer=context__pb2.AuthenticationResult.SerializeToString, + ), + 'get_connectivity_service_status': grpc.unary_unary_rpc_method_handler( + servicer.get_connectivity_service_status, + request_deserializer=service__pb2.ServiceId.FromString, + response_serializer=service__pb2.ServiceState.SerializeToString, + ), + 'create_connectivity_service': grpc.unary_unary_rpc_method_handler( + servicer.create_connectivity_service, + request_deserializer=service__pb2.Service.FromString, + response_serializer=service__pb2.ServiceId.SerializeToString, + ), + 'edit_connectivity_service': grpc.unary_unary_rpc_method_handler( + servicer.edit_connectivity_service, + request_deserializer=service__pb2.Service.FromString, + response_serializer=service__pb2.ServiceId.SerializeToString, + ), + 'delete_connectivity_service': grpc.unary_unary_rpc_method_handler( + servicer.delete_connectivity_service, + request_deserializer=service__pb2.Service.FromString, + response_serializer=context__pb2.Empty.SerializeToString, + ), + 'get_all_active_connectivity_services': grpc.unary_unary_rpc_method_handler( + servicer.get_all_active_connectivity_services, + request_deserializer=context__pb2.Empty.FromString, + response_serializer=service__pb2.ServiceIdList.SerializeToString, + ), + 'clear_all_connectivity_services': grpc.unary_unary_rpc_method_handler( + servicer.clear_all_connectivity_services, + request_deserializer=context__pb2.Empty.FromString, + response_serializer=context__pb2.Empty.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'compute.ComputeService', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class ComputeService(object): + """Missing associated documentation comment in .proto file.""" + + @staticmethod + def check_credentials(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/check_credentials', + context__pb2.TeraFlowController.SerializeToString, + context__pb2.AuthenticationResult.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def get_connectivity_service_status(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/get_connectivity_service_status', + service__pb2.ServiceId.SerializeToString, + service__pb2.ServiceState.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def create_connectivity_service(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/create_connectivity_service', + service__pb2.Service.SerializeToString, + service__pb2.ServiceId.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def edit_connectivity_service(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/edit_connectivity_service', + service__pb2.Service.SerializeToString, + service__pb2.ServiceId.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def delete_connectivity_service(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/delete_connectivity_service', + service__pb2.Service.SerializeToString, + context__pb2.Empty.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def get_all_active_connectivity_services(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/get_all_active_connectivity_services', + context__pb2.Empty.SerializeToString, + service__pb2.ServiceIdList.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def clear_all_connectivity_services(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/compute.ComputeService/clear_all_connectivity_services', + context__pb2.Empty.SerializeToString, + context__pb2.Empty.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/src/compute/proto/context_pb2.py b/src/compute/proto/context_pb2.py new file mode 100644 index 0000000000000000000000000000000000000000..a41b1de47f4df97a6e90b42a02fab7556feafd34 --- /dev/null +++ b/src/compute/proto/context_pb2.py @@ -0,0 +1,880 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: context.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='context.proto', + package='context', + syntax='proto3', + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n\rcontext.proto\x12\x07\x63ontext\"\x07\n\x05\x45mpty\"{\n\x07\x43ontext\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1f\n\x04topo\x18\x02 \x01(\x0b\x32\x11.context.Topology\x12(\n\x03\x63tl\x18\x03 \x01(\x0b\x32\x1b.context.TeraFlowController\"/\n\tContextId\x12\"\n\x0b\x63ontextUuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"m\n\x08Topology\x12#\n\x06topoId\x18\x02 \x01(\x0b\x32\x13.context.TopologyId\x12\x1f\n\x06\x64\x65vice\x18\x03 \x03(\x0b\x32\x0f.context.Device\x12\x1b\n\x04link\x18\x04 \x03(\x0b\x32\r.context.Link\"S\n\x04Link\x12 \n\x07link_id\x18\x01 \x01(\x0b\x32\x0f.context.LinkId\x12)\n\x0c\x65ndpointList\x18\x02 \x03(\x0b\x32\x13.context.EndPointId\"R\n\nTopologyId\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1d\n\x06topoId\x18\x02 \x01(\x0b\x32\r.context.Uuid\"?\n\nConstraint\x12\x17\n\x0f\x63onstraint_type\x18\x01 \x01(\t\x12\x18\n\x10\x63onstraint_value\x18\x02 \x01(\t\"\xda\x01\n\x06\x44\x65vice\x12$\n\tdevice_id\x18\x01 \x01(\x0b\x32\x11.context.DeviceId\x12\x13\n\x0b\x64\x65vice_type\x18\x02 \x01(\t\x12,\n\rdevice_config\x18\x03 \x01(\x0b\x32\x15.context.DeviceConfig\x12>\n\x14\x64\x65vOperationalStatus\x18\x04 \x01(\x0e\x32 .context.DeviceOperationalStatus\x12\'\n\x0c\x65ndpointList\x18\x05 \x03(\x0b\x32\x11.context.EndPoint\"%\n\x0c\x44\x65viceConfig\x12\x15\n\rdevice_config\x18\x01 \x01(\t\"C\n\x08\x45ndPoint\x12$\n\x07port_id\x18\x01 \x01(\x0b\x32\x13.context.EndPointId\x12\x11\n\tport_type\x18\x02 \x01(\t\"t\n\nEndPointId\x12#\n\x06topoId\x18\x01 \x01(\x0b\x32\x13.context.TopologyId\x12!\n\x06\x64\x65v_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\x12\x1e\n\x07port_id\x18\x03 \x01(\x0b\x32\r.context.Uuid\",\n\x08\x44\x65viceId\x12 \n\tdevice_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\"(\n\x06LinkId\x12\x1e\n\x07link_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\x14\n\x04Uuid\x12\x0c\n\x04uuid\x18\x01 \x01(\t\"K\n\x12TeraFlowController\x12\"\n\x06\x63tl_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x11\n\tipaddress\x18\x02 \x01(\t\"Q\n\x14\x41uthenticationResult\x12\"\n\x06\x63tl_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x15\n\rauthenticated\x18\x02 \x01(\x08*N\n\x17\x44\x65viceOperationalStatus\x12\x0f\n\x0bKEEP_STATUS\x10\x00\x12\x15\n\x08\x44ISABLED\x10\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01\x12\x0b\n\x07\x45NABLED\x10\x01\x32\xa2\x01\n\x0e\x43ontextService\x12\x32\n\x0bGetTopology\x12\x0e.context.Empty\x1a\x11.context.Topology\"\x00\x12+\n\x07\x41\x64\x64Link\x12\r.context.Link\x1a\x0f.context.LinkId\"\x00\x12/\n\nDeleteLink\x12\x0f.context.LinkId\x1a\x0e.context.Empty\"\x00\x62\x06proto3' +) + +_DEVICEOPERATIONALSTATUS = _descriptor.EnumDescriptor( + name='DeviceOperationalStatus', + full_name='context.DeviceOperationalStatus', + filename=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + values=[ + _descriptor.EnumValueDescriptor( + name='KEEP_STATUS', index=0, number=0, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='DISABLED', index=1, number=-1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='ENABLED', index=2, number=1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + ], + containing_type=None, + serialized_options=None, + serialized_start=1271, + serialized_end=1349, +) +_sym_db.RegisterEnumDescriptor(_DEVICEOPERATIONALSTATUS) + +DeviceOperationalStatus = enum_type_wrapper.EnumTypeWrapper(_DEVICEOPERATIONALSTATUS) +KEEP_STATUS = 0 +DISABLED = -1 +ENABLED = 1 + + + +_EMPTY = _descriptor.Descriptor( + name='Empty', + full_name='context.Empty', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=26, + serialized_end=33, +) + + +_CONTEXT = _descriptor.Descriptor( + name='Context', + full_name='context.Context', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contextId', full_name='context.Context.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='topo', full_name='context.Context.topo', 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), + _descriptor.FieldDescriptor( + name='ctl', full_name='context.Context.ctl', index=2, + number=3, 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=35, + serialized_end=158, +) + + +_CONTEXTID = _descriptor.Descriptor( + name='ContextId', + full_name='context.ContextId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contextUuid', full_name='context.ContextId.contextUuid', 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=160, + serialized_end=207, +) + + +_TOPOLOGY = _descriptor.Descriptor( + name='Topology', + full_name='context.Topology', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='topoId', full_name='context.Topology.topoId', index=0, + 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), + _descriptor.FieldDescriptor( + name='device', full_name='context.Topology.device', index=1, + 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='link', full_name='context.Topology.link', index=2, + 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=209, + serialized_end=318, +) + + +_LINK = _descriptor.Descriptor( + name='Link', + full_name='context.Link', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='link_id', full_name='context.Link.link_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='endpointList', full_name='context.Link.endpointList', 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=320, + serialized_end=403, +) + + +_TOPOLOGYID = _descriptor.Descriptor( + name='TopologyId', + full_name='context.TopologyId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contextId', full_name='context.TopologyId.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='topoId', full_name='context.TopologyId.topoId', 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=405, + serialized_end=487, +) + + +_CONSTRAINT = _descriptor.Descriptor( + name='Constraint', + full_name='context.Constraint', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='constraint_type', full_name='context.Constraint.constraint_type', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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='constraint_value', full_name='context.Constraint.constraint_value', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=489, + serialized_end=552, +) + + +_DEVICE = _descriptor.Descriptor( + name='Device', + full_name='context.Device', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='device_id', full_name='context.Device.device_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='device_type', full_name='context.Device.device_type', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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='device_config', full_name='context.Device.device_config', index=2, + number=3, 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='devOperationalStatus', full_name='context.Device.devOperationalStatus', index=3, + number=4, 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), + _descriptor.FieldDescriptor( + name='endpointList', full_name='context.Device.endpointList', 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=555, + serialized_end=773, +) + + +_DEVICECONFIG = _descriptor.Descriptor( + name='DeviceConfig', + full_name='context.DeviceConfig', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='device_config', full_name='context.DeviceConfig.device_config', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=775, + serialized_end=812, +) + + +_ENDPOINT = _descriptor.Descriptor( + name='EndPoint', + full_name='context.EndPoint', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='port_id', full_name='context.EndPoint.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), + _descriptor.FieldDescriptor( + name='port_type', full_name='context.EndPoint.port_type', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=814, + serialized_end=881, +) + + +_ENDPOINTID = _descriptor.Descriptor( + name='EndPointId', + full_name='context.EndPointId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='topoId', full_name='context.EndPointId.topoId', 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='dev_id', full_name='context.EndPointId.dev_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), + _descriptor.FieldDescriptor( + name='port_id', full_name='context.EndPointId.port_id', index=2, + number=3, 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=883, + serialized_end=999, +) + + +_DEVICEID = _descriptor.Descriptor( + name='DeviceId', + full_name='context.DeviceId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='device_id', full_name='context.DeviceId.device_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=1001, + serialized_end=1045, +) + + +_LINKID = _descriptor.Descriptor( + name='LinkId', + full_name='context.LinkId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='link_id', full_name='context.LinkId.link_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=1047, + serialized_end=1087, +) + + +_UUID = _descriptor.Descriptor( + name='Uuid', + full_name='context.Uuid', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='uuid', full_name='context.Uuid.uuid', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=1089, + serialized_end=1109, +) + + +_TERAFLOWCONTROLLER = _descriptor.Descriptor( + name='TeraFlowController', + full_name='context.TeraFlowController', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='ctl_id', full_name='context.TeraFlowController.ctl_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='ipaddress', full_name='context.TeraFlowController.ipaddress', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=1111, + serialized_end=1186, +) + + +_AUTHENTICATIONRESULT = _descriptor.Descriptor( + name='AuthenticationResult', + full_name='context.AuthenticationResult', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='ctl_id', full_name='context.AuthenticationResult.ctl_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='authenticated', full_name='context.AuthenticationResult.authenticated', index=1, + number=2, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + 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=1188, + serialized_end=1269, +) + +_CONTEXT.fields_by_name['contextId'].message_type = _CONTEXTID +_CONTEXT.fields_by_name['topo'].message_type = _TOPOLOGY +_CONTEXT.fields_by_name['ctl'].message_type = _TERAFLOWCONTROLLER +_CONTEXTID.fields_by_name['contextUuid'].message_type = _UUID +_TOPOLOGY.fields_by_name['topoId'].message_type = _TOPOLOGYID +_TOPOLOGY.fields_by_name['device'].message_type = _DEVICE +_TOPOLOGY.fields_by_name['link'].message_type = _LINK +_LINK.fields_by_name['link_id'].message_type = _LINKID +_LINK.fields_by_name['endpointList'].message_type = _ENDPOINTID +_TOPOLOGYID.fields_by_name['contextId'].message_type = _CONTEXTID +_TOPOLOGYID.fields_by_name['topoId'].message_type = _UUID +_DEVICE.fields_by_name['device_id'].message_type = _DEVICEID +_DEVICE.fields_by_name['device_config'].message_type = _DEVICECONFIG +_DEVICE.fields_by_name['devOperationalStatus'].enum_type = _DEVICEOPERATIONALSTATUS +_DEVICE.fields_by_name['endpointList'].message_type = _ENDPOINT +_ENDPOINT.fields_by_name['port_id'].message_type = _ENDPOINTID +_ENDPOINTID.fields_by_name['topoId'].message_type = _TOPOLOGYID +_ENDPOINTID.fields_by_name['dev_id'].message_type = _DEVICEID +_ENDPOINTID.fields_by_name['port_id'].message_type = _UUID +_DEVICEID.fields_by_name['device_id'].message_type = _UUID +_LINKID.fields_by_name['link_id'].message_type = _UUID +_TERAFLOWCONTROLLER.fields_by_name['ctl_id'].message_type = _CONTEXTID +_AUTHENTICATIONRESULT.fields_by_name['ctl_id'].message_type = _CONTEXTID +DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY +DESCRIPTOR.message_types_by_name['Context'] = _CONTEXT +DESCRIPTOR.message_types_by_name['ContextId'] = _CONTEXTID +DESCRIPTOR.message_types_by_name['Topology'] = _TOPOLOGY +DESCRIPTOR.message_types_by_name['Link'] = _LINK +DESCRIPTOR.message_types_by_name['TopologyId'] = _TOPOLOGYID +DESCRIPTOR.message_types_by_name['Constraint'] = _CONSTRAINT +DESCRIPTOR.message_types_by_name['Device'] = _DEVICE +DESCRIPTOR.message_types_by_name['DeviceConfig'] = _DEVICECONFIG +DESCRIPTOR.message_types_by_name['EndPoint'] = _ENDPOINT +DESCRIPTOR.message_types_by_name['EndPointId'] = _ENDPOINTID +DESCRIPTOR.message_types_by_name['DeviceId'] = _DEVICEID +DESCRIPTOR.message_types_by_name['LinkId'] = _LINKID +DESCRIPTOR.message_types_by_name['Uuid'] = _UUID +DESCRIPTOR.message_types_by_name['TeraFlowController'] = _TERAFLOWCONTROLLER +DESCRIPTOR.message_types_by_name['AuthenticationResult'] = _AUTHENTICATIONRESULT +DESCRIPTOR.enum_types_by_name['DeviceOperationalStatus'] = _DEVICEOPERATIONALSTATUS +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Empty = _reflection.GeneratedProtocolMessageType('Empty', (_message.Message,), { + 'DESCRIPTOR' : _EMPTY, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Empty) + }) +_sym_db.RegisterMessage(Empty) + +Context = _reflection.GeneratedProtocolMessageType('Context', (_message.Message,), { + 'DESCRIPTOR' : _CONTEXT, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Context) + }) +_sym_db.RegisterMessage(Context) + +ContextId = _reflection.GeneratedProtocolMessageType('ContextId', (_message.Message,), { + 'DESCRIPTOR' : _CONTEXTID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.ContextId) + }) +_sym_db.RegisterMessage(ContextId) + +Topology = _reflection.GeneratedProtocolMessageType('Topology', (_message.Message,), { + 'DESCRIPTOR' : _TOPOLOGY, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Topology) + }) +_sym_db.RegisterMessage(Topology) + +Link = _reflection.GeneratedProtocolMessageType('Link', (_message.Message,), { + 'DESCRIPTOR' : _LINK, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Link) + }) +_sym_db.RegisterMessage(Link) + +TopologyId = _reflection.GeneratedProtocolMessageType('TopologyId', (_message.Message,), { + 'DESCRIPTOR' : _TOPOLOGYID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.TopologyId) + }) +_sym_db.RegisterMessage(TopologyId) + +Constraint = _reflection.GeneratedProtocolMessageType('Constraint', (_message.Message,), { + 'DESCRIPTOR' : _CONSTRAINT, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Constraint) + }) +_sym_db.RegisterMessage(Constraint) + +Device = _reflection.GeneratedProtocolMessageType('Device', (_message.Message,), { + 'DESCRIPTOR' : _DEVICE, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Device) + }) +_sym_db.RegisterMessage(Device) + +DeviceConfig = _reflection.GeneratedProtocolMessageType('DeviceConfig', (_message.Message,), { + 'DESCRIPTOR' : _DEVICECONFIG, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.DeviceConfig) + }) +_sym_db.RegisterMessage(DeviceConfig) + +EndPoint = _reflection.GeneratedProtocolMessageType('EndPoint', (_message.Message,), { + 'DESCRIPTOR' : _ENDPOINT, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.EndPoint) + }) +_sym_db.RegisterMessage(EndPoint) + +EndPointId = _reflection.GeneratedProtocolMessageType('EndPointId', (_message.Message,), { + 'DESCRIPTOR' : _ENDPOINTID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.EndPointId) + }) +_sym_db.RegisterMessage(EndPointId) + +DeviceId = _reflection.GeneratedProtocolMessageType('DeviceId', (_message.Message,), { + 'DESCRIPTOR' : _DEVICEID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.DeviceId) + }) +_sym_db.RegisterMessage(DeviceId) + +LinkId = _reflection.GeneratedProtocolMessageType('LinkId', (_message.Message,), { + 'DESCRIPTOR' : _LINKID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.LinkId) + }) +_sym_db.RegisterMessage(LinkId) + +Uuid = _reflection.GeneratedProtocolMessageType('Uuid', (_message.Message,), { + 'DESCRIPTOR' : _UUID, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.Uuid) + }) +_sym_db.RegisterMessage(Uuid) + +TeraFlowController = _reflection.GeneratedProtocolMessageType('TeraFlowController', (_message.Message,), { + 'DESCRIPTOR' : _TERAFLOWCONTROLLER, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.TeraFlowController) + }) +_sym_db.RegisterMessage(TeraFlowController) + +AuthenticationResult = _reflection.GeneratedProtocolMessageType('AuthenticationResult', (_message.Message,), { + 'DESCRIPTOR' : _AUTHENTICATIONRESULT, + '__module__' : 'context_pb2' + # @@protoc_insertion_point(class_scope:context.AuthenticationResult) + }) +_sym_db.RegisterMessage(AuthenticationResult) + + + +_CONTEXTSERVICE = _descriptor.ServiceDescriptor( + name='ContextService', + full_name='context.ContextService', + file=DESCRIPTOR, + index=0, + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_start=1352, + serialized_end=1514, + methods=[ + _descriptor.MethodDescriptor( + name='GetTopology', + full_name='context.ContextService.GetTopology', + index=0, + containing_service=None, + input_type=_EMPTY, + output_type=_TOPOLOGY, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='AddLink', + full_name='context.ContextService.AddLink', + index=1, + containing_service=None, + input_type=_LINK, + output_type=_LINKID, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='DeleteLink', + full_name='context.ContextService.DeleteLink', + index=2, + containing_service=None, + input_type=_LINKID, + output_type=_EMPTY, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), +]) +_sym_db.RegisterServiceDescriptor(_CONTEXTSERVICE) + +DESCRIPTOR.services_by_name['ContextService'] = _CONTEXTSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/src/compute/proto/service_pb2.py b/src/compute/proto/service_pb2.py new file mode 100644 index 0000000000000000000000000000000000000000..ed248a038c6f6550994ebb204cbb4f626292c65c --- /dev/null +++ b/src/compute/proto/service_pb2.py @@ -0,0 +1,617 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: service.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='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.proto\"+\n\x0bServiceList\x12\x1c\n\x02\x63s\x18\x01 \x03(\x0b\x32\x10.service.Service\"\x87\x02\n\x07Service\x12!\n\x05\x63s_id\x18\x01 \x01(\x0b\x32\x12.service.ServiceId\x12)\n\x0bserviceType\x18\x02 \x01(\x0e\x32\x14.service.ServiceType\x12)\n\x0c\x65ndpointList\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\x12\'\n\nconstraint\x18\x04 \x03(\x0b\x32\x13.context.Constraint\x12+\n\x0cserviceState\x18\x05 \x01(\x0b\x32\x15.service.ServiceState\x12-\n\rserviceConfig\x18\x06 \x01(\x0b\x32\x16.service.ServiceConfig\"&\n\rServiceConfig\x12\x15\n\rserviceConfig\x18\x01 \x01(\t\"P\n\tServiceId\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1c\n\x05\x63s_id\x18\x02 \x01(\x0b\x32\r.context.Uuid\":\n\rServiceIdList\x12)\n\rserviceIdList\x18\x01 \x03(\x0b\x32\x12.service.ServiceId\"?\n\x0cServiceState\x12/\n\x0cserviceState\x18\x01 \x01(\x0e\x32\x19.service.ServiceStateEnum\"=\n\x0e\x43onnectionList\x12+\n\x0e\x63onnectionList\x18\x01 \x03(\x0b\x32\x13.service.Connection\"\x84\x01\n\nConnection\x12%\n\x06\x63on_id\x18\x01 \x01(\x0b\x32\x15.service.ConnectionId\x12,\n\x10relatedServiceId\x18\x02 \x01(\x0b\x32\x12.service.ServiceId\x12!\n\x04path\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\"-\n\x0c\x43onnectionId\x12\x1d\n\x06\x63on_id\x18\x01 \x01(\x0b\x32\r.context.Uuid*M\n\x0bServiceType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x08\n\x04L3NM\x10\x01\x12\x08\n\x04L2NM\x10\x02\x12\x1d\n\x19TAPI_CONNECTIVITY_SERVICE\x10\x03*@\n\x10ServiceStateEnum\x12\x0b\n\x07PLANNED\x10\x00\x12\n\n\x06\x41\x43TIVE\x10\x01\x12\x13\n\x0fPENDING_REMOVAL\x10\x02\x32\xed\x02\n\x0eServiceService\x12\x38\n\x0eGetServiceList\x12\x0e.context.Empty\x1a\x14.service.ServiceList\"\x00\x12\x37\n\rCreateService\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12\x37\n\rUpdateService\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12\x35\n\rDeleteService\x12\x12.service.ServiceId\x1a\x0e.context.Empty\"\x00\x12\x38\n\x0eGetServiceById\x12\x12.service.ServiceId\x1a\x10.service.Service\"\x00\x12>\n\x11GetConnectionList\x12\x0e.context.Empty\x1a\x17.service.ConnectionList\"\x00\x62\x06proto3' + , + dependencies=[context__pb2.DESCRIPTOR,]) + +_SERVICETYPE = _descriptor.EnumDescriptor( + name='ServiceType', + full_name='service.ServiceType', + filename=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + values=[ + _descriptor.EnumValueDescriptor( + name='UNKNOWN', index=0, number=0, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='L3NM', index=1, number=1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='L2NM', index=2, number=2, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='TAPI_CONNECTIVITY_SERVICE', index=3, number=3, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + ], + containing_type=None, + serialized_options=None, + serialized_start=844, + serialized_end=921, +) +_sym_db.RegisterEnumDescriptor(_SERVICETYPE) + +ServiceType = enum_type_wrapper.EnumTypeWrapper(_SERVICETYPE) +_SERVICESTATEENUM = _descriptor.EnumDescriptor( + name='ServiceStateEnum', + full_name='service.ServiceStateEnum', + 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='ACTIVE', index=1, number=1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='PENDING_REMOVAL', index=2, number=2, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + ], + containing_type=None, + serialized_options=None, + serialized_start=923, + serialized_end=987, +) +_sym_db.RegisterEnumDescriptor(_SERVICESTATEENUM) + +ServiceStateEnum = enum_type_wrapper.EnumTypeWrapper(_SERVICESTATEENUM) +UNKNOWN = 0 +L3NM = 1 +L2NM = 2 +TAPI_CONNECTIVITY_SERVICE = 3 +PLANNED = 0 +ACTIVE = 1 +PENDING_REMOVAL = 2 + + + +_SERVICELIST = _descriptor.Descriptor( + name='ServiceList', + full_name='service.ServiceList', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='cs', full_name='service.ServiceList.cs', index=0, + number=1, 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=41, + serialized_end=84, +) + + +_SERVICE = _descriptor.Descriptor( + name='Service', + full_name='service.Service', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='cs_id', full_name='service.Service.cs_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='serviceType', full_name='service.Service.serviceType', 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), + _descriptor.FieldDescriptor( + name='endpointList', full_name='service.Service.endpointList', 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='constraint', full_name='service.Service.constraint', 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='serviceState', full_name='service.Service.serviceState', index=4, + number=5, 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='serviceConfig', full_name='service.Service.serviceConfig', 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=87, + serialized_end=350, +) + + +_SERVICECONFIG = _descriptor.Descriptor( + name='ServiceConfig', + full_name='service.ServiceConfig', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='serviceConfig', full_name='service.ServiceConfig.serviceConfig', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + 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=352, + serialized_end=390, +) + + +_SERVICEID = _descriptor.Descriptor( + name='ServiceId', + full_name='service.ServiceId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contextId', full_name='service.ServiceId.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='cs_id', full_name='service.ServiceId.cs_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=392, + serialized_end=472, +) + + +_SERVICEIDLIST = _descriptor.Descriptor( + name='ServiceIdList', + full_name='service.ServiceIdList', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='serviceIdList', full_name='service.ServiceIdList.serviceIdList', index=0, + number=1, 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=474, + serialized_end=532, +) + + +_SERVICESTATE = _descriptor.Descriptor( + name='ServiceState', + full_name='service.ServiceState', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='serviceState', full_name='service.ServiceState.serviceState', index=0, + number=1, 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=534, + serialized_end=597, +) + + +_CONNECTIONLIST = _descriptor.Descriptor( + name='ConnectionList', + full_name='service.ConnectionList', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='connectionList', full_name='service.ConnectionList.connectionList', index=0, + number=1, 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=599, + serialized_end=660, +) + + +_CONNECTION = _descriptor.Descriptor( + name='Connection', + full_name='service.Connection', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='con_id', full_name='service.Connection.con_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='relatedServiceId', full_name='service.Connection.relatedServiceId', 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), + _descriptor.FieldDescriptor( + name='path', full_name='service.Connection.path', 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), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=663, + serialized_end=795, +) + + +_CONNECTIONID = _descriptor.Descriptor( + name='ConnectionId', + full_name='service.ConnectionId', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='con_id', full_name='service.ConnectionId.con_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=797, + serialized_end=842, +) + +_SERVICELIST.fields_by_name['cs'].message_type = _SERVICE +_SERVICE.fields_by_name['cs_id'].message_type = _SERVICEID +_SERVICE.fields_by_name['serviceType'].enum_type = _SERVICETYPE +_SERVICE.fields_by_name['endpointList'].message_type = context__pb2._ENDPOINTID +_SERVICE.fields_by_name['constraint'].message_type = context__pb2._CONSTRAINT +_SERVICE.fields_by_name['serviceState'].message_type = _SERVICESTATE +_SERVICE.fields_by_name['serviceConfig'].message_type = _SERVICECONFIG +_SERVICEID.fields_by_name['contextId'].message_type = context__pb2._CONTEXTID +_SERVICEID.fields_by_name['cs_id'].message_type = context__pb2._UUID +_SERVICEIDLIST.fields_by_name['serviceIdList'].message_type = _SERVICEID +_SERVICESTATE.fields_by_name['serviceState'].enum_type = _SERVICESTATEENUM +_CONNECTIONLIST.fields_by_name['connectionList'].message_type = _CONNECTION +_CONNECTION.fields_by_name['con_id'].message_type = _CONNECTIONID +_CONNECTION.fields_by_name['relatedServiceId'].message_type = _SERVICEID +_CONNECTION.fields_by_name['path'].message_type = context__pb2._ENDPOINTID +_CONNECTIONID.fields_by_name['con_id'].message_type = context__pb2._UUID +DESCRIPTOR.message_types_by_name['ServiceList'] = _SERVICELIST +DESCRIPTOR.message_types_by_name['Service'] = _SERVICE +DESCRIPTOR.message_types_by_name['ServiceConfig'] = _SERVICECONFIG +DESCRIPTOR.message_types_by_name['ServiceId'] = _SERVICEID +DESCRIPTOR.message_types_by_name['ServiceIdList'] = _SERVICEIDLIST +DESCRIPTOR.message_types_by_name['ServiceState'] = _SERVICESTATE +DESCRIPTOR.message_types_by_name['ConnectionList'] = _CONNECTIONLIST +DESCRIPTOR.message_types_by_name['Connection'] = _CONNECTION +DESCRIPTOR.message_types_by_name['ConnectionId'] = _CONNECTIONID +DESCRIPTOR.enum_types_by_name['ServiceType'] = _SERVICETYPE +DESCRIPTOR.enum_types_by_name['ServiceStateEnum'] = _SERVICESTATEENUM +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ServiceList = _reflection.GeneratedProtocolMessageType('ServiceList', (_message.Message,), { + 'DESCRIPTOR' : _SERVICELIST, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ServiceList) + }) +_sym_db.RegisterMessage(ServiceList) + +Service = _reflection.GeneratedProtocolMessageType('Service', (_message.Message,), { + 'DESCRIPTOR' : _SERVICE, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.Service) + }) +_sym_db.RegisterMessage(Service) + +ServiceConfig = _reflection.GeneratedProtocolMessageType('ServiceConfig', (_message.Message,), { + 'DESCRIPTOR' : _SERVICECONFIG, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ServiceConfig) + }) +_sym_db.RegisterMessage(ServiceConfig) + +ServiceId = _reflection.GeneratedProtocolMessageType('ServiceId', (_message.Message,), { + 'DESCRIPTOR' : _SERVICEID, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ServiceId) + }) +_sym_db.RegisterMessage(ServiceId) + +ServiceIdList = _reflection.GeneratedProtocolMessageType('ServiceIdList', (_message.Message,), { + 'DESCRIPTOR' : _SERVICEIDLIST, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ServiceIdList) + }) +_sym_db.RegisterMessage(ServiceIdList) + +ServiceState = _reflection.GeneratedProtocolMessageType('ServiceState', (_message.Message,), { + 'DESCRIPTOR' : _SERVICESTATE, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ServiceState) + }) +_sym_db.RegisterMessage(ServiceState) + +ConnectionList = _reflection.GeneratedProtocolMessageType('ConnectionList', (_message.Message,), { + 'DESCRIPTOR' : _CONNECTIONLIST, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ConnectionList) + }) +_sym_db.RegisterMessage(ConnectionList) + +Connection = _reflection.GeneratedProtocolMessageType('Connection', (_message.Message,), { + 'DESCRIPTOR' : _CONNECTION, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.Connection) + }) +_sym_db.RegisterMessage(Connection) + +ConnectionId = _reflection.GeneratedProtocolMessageType('ConnectionId', (_message.Message,), { + 'DESCRIPTOR' : _CONNECTIONID, + '__module__' : 'service_pb2' + # @@protoc_insertion_point(class_scope:service.ConnectionId) + }) +_sym_db.RegisterMessage(ConnectionId) + + + +_SERVICESERVICE = _descriptor.ServiceDescriptor( + name='ServiceService', + full_name='service.ServiceService', + file=DESCRIPTOR, + index=0, + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_start=990, + serialized_end=1355, + methods=[ + _descriptor.MethodDescriptor( + name='GetServiceList', + full_name='service.ServiceService.GetServiceList', + index=0, + containing_service=None, + input_type=context__pb2._EMPTY, + output_type=_SERVICELIST, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='CreateService', + full_name='service.ServiceService.CreateService', + index=1, + containing_service=None, + input_type=_SERVICE, + output_type=_SERVICEID, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='UpdateService', + full_name='service.ServiceService.UpdateService', + index=2, + containing_service=None, + input_type=_SERVICE, + output_type=_SERVICEID, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='DeleteService', + full_name='service.ServiceService.DeleteService', + index=3, + containing_service=None, + input_type=_SERVICEID, + output_type=context__pb2._EMPTY, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='GetServiceById', + full_name='service.ServiceService.GetServiceById', + index=4, + containing_service=None, + input_type=_SERVICEID, + output_type=_SERVICE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='GetConnectionList', + full_name='service.ServiceService.GetConnectionList', + index=5, + containing_service=None, + input_type=context__pb2._EMPTY, + output_type=_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) diff --git a/src/compute/requirements.in b/src/compute/requirements.in new file mode 100644 index 0000000000000000000000000000000000000000..1da334a54b1c42b01eb8f731d8fd5bd975edd2cf --- /dev/null +++ b/src/compute/requirements.in @@ -0,0 +1,5 @@ +grpcio-health-checking +grpcio +prometheus-client +pytest +pytest-benchmark diff --git a/src/compute/service/ComputeService.py b/src/compute/service/ComputeService.py new file mode 100644 index 0000000000000000000000000000000000000000..36d43283c43c82faff1748428943cb9a9687c840 --- /dev/null +++ b/src/compute/service/ComputeService.py @@ -0,0 +1,53 @@ +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 compute.proto.compute_pb2_grpc import add_ComputeServiceServicer_to_server +from compute.service.ComputeServiceServicerImpl import ComputeServiceServicerImpl +from compute.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD + +BIND_ADDRESS = '0.0.0.0' +LOGGER = logging.getLogger(__name__) + +class ComputeService: + def __init__(self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, + grace_period=GRPC_GRACE_PERIOD): + self.address = address + self.port = port + self.endpoint = None + self.max_workers = max_workers + self.grace_period = grace_period + self.compute_servicer = None + self.health_servicer = None + self.pool = None + self.server = None + + def start(self): + self.endpoint = '{}:{}'.format(self.address, self.port) + LOGGER.debug('Starting Service (tentative endpoint: {}, max_workers: {})...'.format( + self.endpoint, self.max_workers)) + + self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) + self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) + + self.compute_servicer = ComputeServiceServicerImpl() + add_ComputeServiceServicer_to_server(self.compute_servicer, self.server) + + 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) + + port = self.server.add_insecure_port(self.endpoint) + self.endpoint = '{}:{}'.format(self.address, port) + LOGGER.info('Listening on {}...'.format(self.endpoint)) + self.server.start() + 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)) + self.health_servicer.enter_graceful_shutdown() + self.server.stop(self.grace_period) + LOGGER.debug('Service stopped') diff --git a/src/compute/service/ComputeServiceServicerImpl.py b/src/compute/service/ComputeServiceServicerImpl.py new file mode 100644 index 0000000000000000000000000000000000000000..5d00031b93e6a5285578f8f399106e842b6d2645 --- /dev/null +++ b/src/compute/service/ComputeServiceServicerImpl.py @@ -0,0 +1,295 @@ +import grpc, logging +from prometheus_client import Counter, Histogram +from common.database.api.Database import Database +from common.exceptions.ServiceException import ServiceException +from compute.proto.compute_pb2_grpc import ComputeServiceServicer +from compute.proto.context_pb2 import AuthenticationResult, Empty, TeraFlowController +from compute.proto.service_pb2 import Service, ServiceId, ServiceIdList, ServiceState + +LOGGER = logging.getLogger(__name__) + +CHECKCREDENTIALS_COUNTER_STARTED = Counter( + 'compute_checkcredentials_counter_started', + 'Compute:CheckCredentials counter of requests started') +CHECKCREDENTIALS_COUNTER_COMPLETED = Counter( + 'compute_checkcredentials_counter_completed', + 'Compute:CheckCredentials counter of requests completed') +CHECKCREDENTIALS_COUNTER_FAILED = Counter( + 'compute_checkcredentials_counter_failed', + 'Compute:CheckCredentials counter of requests failed') +CHECKCREDENTIALS_HISTOGRAM_DURATION = Histogram( + 'compute_checkcredentials_histogram_duration', + 'Compute:CheckCredentials histogram of request duration') + +GETCONNECTIVITYSERVICESTATUS_COUNTER_STARTED = Counter( + 'compute_getconnectivityservicestatus_counter_started', + 'Compute:GetConnectivityServiceStatus counter of requests started') +GETCONNECTIVITYSERVICESTATUS_COUNTER_COMPLETED = Counter( + 'compute_getconnectivityservicestatus_counter_completed', + 'Compute:GetConnectivityServiceStatus counter of requests completed') +GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED = Counter( + 'compute_getconnectivityservicestatus_counter_failed', + 'Compute:GetConnectivityServiceStatus counter of requests failed') +GETCONNECTIVITYSERVICESTATUS_HISTOGRAM_DURATION = Histogram( + 'compute_getconnectivityservicestatus_histogram_duration', + 'Compute:GetConnectivityServiceStatus histogram of request duration') + +CREATECONNECTIVITYSERVICE_COUNTER_STARTED = Counter( + 'compute_createconnectivityservice_counter_started', + 'Compute:CreateConnectivityService counter of requests started' ) +CREATECONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter( + 'compute_createconnectivityservice_counter_completed', + 'Compute:CreateConnectivityService counter of requests completed') +CREATECONNECTIVITYSERVICE_COUNTER_FAILED = Counter( + 'compute_createconnectivityservice_counter_failed', + 'Compute:CreateConnectivityService counter of requests failed') +CREATECONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram( + 'compute_createconnectivityservice_histogram_duration', + 'Compute:CreateConnectivityService histogram of request duration') + +EDITCONNECTIVITYSERVICE_COUNTER_STARTED = Counter( + 'compute_editconnectivityservice_counter_started', + 'Compute:EditConnectivityService counter of requests started') +EDITCONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter( + 'compute_editconnectivityservice_counter_completed', + 'Compute:EditConnectivityService counter of requests completed') +EDITCONNECTIVITYSERVICE_COUNTER_FAILED = Counter( + 'compute_editconnectivityservice_counter_failed', + 'Compute:EditConnectivityService counter of requests failed') +EDITCONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram( + 'compute_editconnectivityservice_histogram_duration', + 'Compute:EditConnectivityService histogram of request duration') + +DELETECONNECTIVITYSERVICE_COUNTER_STARTED = Counter( + 'compute_deleteconnectivityservice_counter_started', + 'Compute:DeleteConnectivityService counter of requests started') +DELETECONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter( + 'compute_deleteconnectivityservice_counter_completed', + 'Compute:DeleteConnectivityService counter of requests completed') +DELETECONNECTIVITYSERVICE_COUNTER_FAILED = Counter( + 'compute_deleteconnectivityservice_counter_failed', + 'Compute:DeleteConnectivityService counter of requests failed') +DELETECONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram( + 'compute_deleteconnectivityservice_histogram_duration', + 'Compute:DeleteConnectivityService histogram of request duration') + +GETALLACTIVECONNECTIVITYSERVICES_COUNTER_STARTED = Counter( + 'compute_getallactiveconnectivityservices_counter_started', + 'Compute:GetAllActiveConnectivityServices counter of requests started') +GETALLACTIVECONNECTIVITYSERVICES_COUNTER_COMPLETED = Counter( + 'compute_getallactiveconnectivityservices_counter_completed', + 'Compute:GetAllActiveConnectivityServices counter of requests completed') +GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED = Counter( + 'compute_getallactiveconnectivityservices_counter_failed', + 'Compute:GetAllActiveConnectivityServices counter of requests failed') +GETALLACTIVECONNECTIVITYSERVICES_HISTOGRAM_DURATION = Histogram( + 'compute_getallactiveconnectivityservices_histogram_duration', + 'Compute:GetAllActiveConnectivityServices histogram of request duration') + +CLEARALLCONNECTIVITYSERVICES_COUNTER_STARTED = Counter( + 'compute_clearallconnectivityservices_counter_started', + 'Compute:ClearAllConnectivityServices counter of requests started') +CLEARALLCONNECTIVITYSERVICES_COUNTER_COMPLETED = Counter( + 'compute_clearallconnectivityservices_counter_completed', + 'Compute:ClearAllConnectivityServices counter of requests completed') +CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED = Counter( + 'compute_clearallconnectivityservices_counter_failed', + 'Compute:ClearAllConnectivityServices counter of requests failed') +CLEARALLCONNECTIVITYSERVICES_HISTOGRAM_DURATION = Histogram( + 'compute_clearallconnectivityservices_histogram_duration', + 'Compute:ClearAllConnectivityServices histogram of request duration') + + +class ComputeServiceServicerImpl(ComputeServiceServicer): + def __init__(self): + LOGGER.info('Creating Servicer...') + LOGGER.info('Servicer Created') + + @CHECKCREDENTIALS_HISTOGRAM_DURATION.time() + def check_credentials( + self, request : TeraFlowController, grpc_context : grpc.ServicerContext) -> AuthenticationResult: + + CHECKCREDENTIALS_COUNTER_STARTED.inc() + try: + LOGGER.info('check_credentials request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = AuthenticationResult() + LOGGER.info('check_credentials reply: {}'.format(str(reply))) + CHECKCREDENTIALS_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('check_credentials exception') + CHECKCREDENTIALS_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('check_credentials exception') + CHECKCREDENTIALS_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @GETCONNECTIVITYSERVICESTATUS_HISTOGRAM_DURATION.time() + def get_connectivity_service_status( + self, request : ServiceId, grpc_context : grpc.ServicerContext) -> ServiceState: + + GETCONNECTIVITYSERVICESTATUS_COUNTER_STARTED.inc() + try: + LOGGER.info('get_connectivity_service_status request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = ServiceState() + LOGGER.info('get_connectivity_service_status reply: {}'.format(str(reply))) + GETCONNECTIVITYSERVICESTATUS_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('get_connectivity_service_status exception') + GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('get_connectivity_service_status exception') + GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @CREATECONNECTIVITYSERVICE_HISTOGRAM_DURATION.time() + def create_connectivity_service( + self, request : Service, grpc_context : grpc.ServicerContext) -> ServiceId: + + CREATECONNECTIVITYSERVICE_COUNTER_STARTED.inc() + try: + LOGGER.info('create_connectivity_service request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = ServiceId() + LOGGER.info('create_connectivity_service reply: {}'.format(str(reply))) + CREATECONNECTIVITYSERVICE_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('create_connectivity_service exception') + CREATECONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('create_connectivity_service exception') + CREATECONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @EDITCONNECTIVITYSERVICE_HISTOGRAM_DURATION.time() + def edit_connectivity_service( + self, request : Service, grpc_context : grpc.ServicerContext) -> ServiceId: + + EDITCONNECTIVITYSERVICE_COUNTER_STARTED.inc() + try: + LOGGER.info('edit_connectivity_service request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = ServiceId() + LOGGER.info('edit_connectivity_service reply: {}'.format(str(reply))) + EDITCONNECTIVITYSERVICE_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('edit_connectivity_service exception') + EDITCONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('edit_connectivity_service exception') + EDITCONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @DELETECONNECTIVITYSERVICE_HISTOGRAM_DURATION.time() + def delete_connectivity_service( + self, request : Service, grpc_context : grpc.ServicerContext) -> Empty: + + DELETECONNECTIVITYSERVICE_COUNTER_STARTED.inc() + try: + LOGGER.info('delete_connectivity_service request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = Empty() + LOGGER.info('delete_connectivity_service reply: {}'.format(str(reply))) + DELETECONNECTIVITYSERVICE_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('delete_connectivity_service exception') + DELETECONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('delete_connectivity_service exception') + DELETECONNECTIVITYSERVICE_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @GETALLACTIVECONNECTIVITYSERVICES_HISTOGRAM_DURATION.time() + def get_all_active_connectivity_services( + self, request : Empty, grpc_context : grpc.ServicerContext) -> ServiceIdList: + + GETALLACTIVECONNECTIVITYSERVICES_COUNTER_STARTED.inc() + try: + LOGGER.info('get_all_active_connectivity_services request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = ServiceIdList() + LOGGER.info('get_all_active_connectivity_services reply: {}'.format(str(reply))) + GETALLACTIVECONNECTIVITYSERVICES_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('get_all_active_connectivity_services exception') + GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('get_all_active_connectivity_services exception') + GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) + + @CLEARALLCONNECTIVITYSERVICES_HISTOGRAM_DURATION.time() + def clear_all_connectivity_services( + self, request : Empty, grpc_context : grpc.ServicerContext) -> Empty: + + CLEARALLCONNECTIVITYSERVICES_COUNTER_STARTED.inc() + try: + LOGGER.info('clear_all_connectivity_services request: {}'.format(str(request))) + LOGGER.warning('NOT IMPLEMENTED') + + # ----- Validate request data and pre-conditions ----------------------------------------------------------- + + # ----- Retrieve data from the database -------------------------------------------------------------------- + + # ----- Compose reply -------------------------------------------------------------------------------------- + reply = Empty() + LOGGER.info('clear_all_connectivity_services reply: {}'.format(str(reply))) + CLEARALLCONNECTIVITYSERVICES_COUNTER_COMPLETED.inc() + return reply + except ServiceException as e: # pragma: no cover (ServiceException not thrown) + LOGGER.exception('clear_all_connectivity_services exception') + CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED.inc() + grpc_context.abort(e.code, e.details) + except Exception as e: # pragma: no cover + LOGGER.exception('clear_all_connectivity_services exception') + CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED.inc() + grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) diff --git a/src/compute/service/__init__.py b/src/compute/service/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/compute/service/__main__.py b/src/compute/service/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..94a79ff1570e1a77b4cadc9150298cab672992b8 --- /dev/null +++ b/src/compute/service/__main__.py @@ -0,0 +1,48 @@ +import logging, os, signal, sys, threading +from prometheus_client import start_http_server +from compute.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT +from compute.service.ComputeService import ComputeService + +terminate = threading.Event() +logger = None + +def signal_handler(signal, frame): + global terminate, logger + logger.warning('Terminate signal received') + terminate.set() + +def main(): + global terminate, logger + + grpc_service_port = os.environ.get('COMPUTESERVICE_SERVICE_PORT_GRPC', GRPC_SERVICE_PORT ) + max_workers = os.environ.get('MAX_WORKERS', GRPC_MAX_WORKERS ) + grace_period = os.environ.get('GRACE_PERIOD', GRPC_GRACE_PERIOD ) + log_level = os.environ.get('LOG_LEVEL', LOG_LEVEL ) + metrics_port = os.environ.get('METRICS_PORT', METRICS_PORT ) + + logging.basicConfig(level=log_level) + logger = logging.getLogger(__name__) + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) + + logger.info('Starting...') + + # Start metrics server + start_http_server(metrics_port) + + # Starting compute service + grpc_service = ComputeService(port=grpc_service_port, max_workers=max_workers, grace_period=grace_period) + grpc_service.start() + + # Wait for Ctrl+C or termination signal + while not terminate.wait(timeout=0.1): pass + + logger.info('Terminating...') + grpc_service.stop() + + logger.info('Bye') + return 0 + +if __name__ == '__main__': + sys.exit(main()) diff --git a/src/compute/tests/__init__.py b/src/compute/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/compute/tests/test_unitary.py b/src/compute/tests/test_unitary.py new file mode 100644 index 0000000000000000000000000000000000000000..ff8cd233b0b42a4e492a8de19a770a50aeb97571 --- /dev/null +++ b/src/compute/tests/test_unitary.py @@ -0,0 +1,33 @@ +import logging, pytest +from google.protobuf.json_format import MessageToDict +from common.tests.Assertions import validate_service_id +from compute.client.ComputeClient import ComputeClient +from compute.proto.service_pb2 import Service +from compute.service.ComputeService import ComputeService +from compute.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD + +grpc_port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + +@pytest.fixture(scope='session') +def compute_service(): + _service = ComputeService(port=grpc_port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) + _service.start() + yield _service + _service.stop() + +@pytest.fixture(scope='session') +def compute_client(compute_service): + _client = ComputeClient(address='127.0.0.1', port=grpc_port) + yield _client + _client.close() + +def test_dummy_create_connectivity_service(compute_client : ComputeClient): + # dummy test: should fail with assertion error + with pytest.raises(AssertionError): + validate_service_id(MessageToDict( + compute_client.CreateConnectivityService(Service()), + including_default_value_fields=True, preserving_proto_field_name=True, + use_integers_for_enums=False))