Commit 77991f00 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Problem resolutions to enable CI/CD pipeline to work with Compute and Centralized Attack Detector.

parent e85e7af4
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -3,13 +3,10 @@ syntax = "proto3";
package centralized_attack_detector;

import "context.proto";
import "service.proto";
import "monitoring.proto";


service CentralizedAttackDetectorService {

  rpc NotifyServiceUpdate (service.Service) returns (context.Empty) {}
  rpc NotifyServiceUpdate (context.Service   ) returns (context.Empty) {}
  
  // rpc that triggers the attack detection loop
  rpc DetectAttack        (context.Empty     ) returns (context.Empty) {}
@@ -18,6 +15,4 @@ service CentralizedAttackDetectorService {
  rpc ReportSummarizedKpi (monitoring.KpiList) returns (context.Empty) {}

  rpc ReportKpi           (monitoring.KpiList) returns (context.Empty) {}

}
+7 −8
Original line number Diff line number Diff line
@@ -2,14 +2,13 @@ syntax = "proto3";
package compute;

import "context.proto";
import "service.proto";

service ComputeService {
  rpc CheckCredentials                 (context.TeraFlowController) returns (context.AuthenticationResult) {}
  rpc GetConnectivityServiceStatus ( service.ServiceId ) returns (service.ServiceState) {}
  rpc CreateConnectivityService ( service.Service ) returns (service.ServiceId) {}
  rpc EditConnectivityService ( service.Service ) returns (service.ServiceId) {}
  rpc DeleteConnectivityService ( service.Service ) returns ( context.Empty ) {}
  rpc GetAllActiveConnectivityServices ( context.Empty ) returns ( service.ServiceIdList ) {}
  rpc GetConnectivityServiceStatus     (context.ServiceId         ) returns (context.ServiceStatus       ) {}
  rpc CreateConnectivityService        (context.Service           ) returns (context.ServiceId           ) {}
  rpc EditConnectivityService          (context.Service           ) returns (context.ServiceId           ) {}
  rpc DeleteConnectivityService        (context.Service           ) returns (context.Empty               ) {}
  rpc GetAllActiveConnectivityServices (context.Empty             ) returns (context.ServiceIdList       ) {}
  rpc ClearAllConnectivityServices     (context.Empty             ) returns (context.Empty               ) {}
}
+11 −12
Original line number Diff line number Diff line
import grpc, logging
from common.tools.client.RetryDecorator import retry, delay_exponential
from centralizedattackdetector.proto.context_pb2 import Empty
from centralizedattackdetector.proto.service_pb2 import Service
from centralizedattackdetector.proto.context_pb2 import Empty, Service
from centralizedattackdetector.proto.monitoring_pb2 import KpiList
from centralizedattackdetector.proto.centralized_attack_detector_pb2_grpc import CentralizedAttackDetectorServiceStub

@@ -11,8 +10,8 @@ DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0)

class CentralizedAttackDetectorClient:
    def __init__(self, address, port):
        self.endpoint = '{}:{}'.format(address, port)
        LOGGER.debug('Creating channel to {}...'.format(self.endpoint))
        self.endpoint = '{:s}:{:s}'.format(str(address), str(port))
        LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint)))
        self.channel = None
        self.stub = None
        self.connect()
@@ -29,28 +28,28 @@ class CentralizedAttackDetectorClient:

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

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

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

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    def ReportKpi(self, request : KpiList) -> Empty:
        LOGGER.debug('ReportKpi request: {}'.format(request))
        LOGGER.debug('ReportKpi request: {:s}'.format(str(request)))
        response = self.stub.ReportKpi(request)
        LOGGER.debug('ReportKpi result: {}'.format(response))
        LOGGER.debug('ReportKpi result: {:s}'.format(str(response)))
        return response
+5 −6
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ _sym_db = _symbol_database.Default()


from . import context_pb2 as context__pb2
from . import service_pb2 as service__pb2
from . import monitoring_pb2 as monitoring__pb2


@@ -22,9 +21,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
  syntax='proto3',
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n!centralized_attack_detector.proto\x12\x1b\x63\x65ntralized_attack_detector\x1a\rcontext.proto\x1a\rservice.proto\x1a\x10monitoring.proto2\x81\x02\n CentralizedAttackDetectorService\x12\x39\n\x13NotifyServiceUpdate\x12\x10.service.Service\x1a\x0e.context.Empty\"\x00\x12\x30\n\x0c\x44\x65tectAttack\x12\x0e.context.Empty\x1a\x0e.context.Empty\"\x00\x12<\n\x13ReportSummarizedKpi\x12\x13.monitoring.KpiList\x1a\x0e.context.Empty\"\x00\x12\x32\n\tReportKpi\x12\x13.monitoring.KpiList\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
  serialized_pb=b'\n!centralized_attack_detector.proto\x12\x1b\x63\x65ntralized_attack_detector\x1a\rcontext.proto\x1a\x10monitoring.proto2\x81\x02\n CentralizedAttackDetectorService\x12\x39\n\x13NotifyServiceUpdate\x12\x10.context.Service\x1a\x0e.context.Empty\"\x00\x12\x30\n\x0c\x44\x65tectAttack\x12\x0e.context.Empty\x1a\x0e.context.Empty\"\x00\x12<\n\x13ReportSummarizedKpi\x12\x13.monitoring.KpiList\x1a\x0e.context.Empty\"\x00\x12\x32\n\tReportKpi\x12\x13.monitoring.KpiList\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
  ,
  dependencies=[context__pb2.DESCRIPTOR,service__pb2.DESCRIPTOR,monitoring__pb2.DESCRIPTOR,])
  dependencies=[context__pb2.DESCRIPTOR,monitoring__pb2.DESCRIPTOR,])



@@ -39,15 +38,15 @@ _CENTRALIZEDATTACKDETECTORSERVICE = _descriptor.ServiceDescriptor(
  index=0,
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_start=115,
  serialized_end=372,
  serialized_start=100,
  serialized_end=357,
  methods=[
  _descriptor.MethodDescriptor(
    name='NotifyServiceUpdate',
    full_name='centralized_attack_detector.CentralizedAttackDetectorService.NotifyServiceUpdate',
    index=0,
    containing_service=None,
    input_type=service__pb2._SERVICE,
    input_type=context__pb2._SERVICE,
    output_type=context__pb2._EMPTY,
    serialized_options=None,
    create_key=_descriptor._internal_create_key,
+3 −4
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ import grpc

from . import context_pb2 as context__pb2
from . import monitoring_pb2 as monitoring__pb2
from . import service_pb2 as service__pb2


class CentralizedAttackDetectorServiceStub(object):
@@ -18,7 +17,7 @@ class CentralizedAttackDetectorServiceStub(object):
        """
        self.NotifyServiceUpdate = channel.unary_unary(
                '/centralized_attack_detector.CentralizedAttackDetectorService/NotifyServiceUpdate',
                request_serializer=service__pb2.Service.SerializeToString,
                request_serializer=context__pb2.Service.SerializeToString,
                response_deserializer=context__pb2.Empty.FromString,
                )
        self.DetectAttack = channel.unary_unary(
@@ -72,7 +71,7 @@ def add_CentralizedAttackDetectorServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'NotifyServiceUpdate': grpc.unary_unary_rpc_method_handler(
                    servicer.NotifyServiceUpdate,
                    request_deserializer=service__pb2.Service.FromString,
                    request_deserializer=context__pb2.Service.FromString,
                    response_serializer=context__pb2.Empty.SerializeToString,
            ),
            'DetectAttack': grpc.unary_unary_rpc_method_handler(
@@ -112,7 +111,7 @@ class CentralizedAttackDetectorService(object):
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(request, target, '/centralized_attack_detector.CentralizedAttackDetectorService/NotifyServiceUpdate',
            service__pb2.Service.SerializeToString,
            context__pb2.Service.SerializeToString,
            context__pb2.Empty.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading