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

Merge branch 'feat/service-fix-new-database-api' into 'develop'

Multiple fixes to correct problems with common.database in Compute, Service and CentralizedAttackDetector.

See merge request teraflow-h2020/controller!30
parents eff7b2f2 77991f00
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               ) {}
}
+1 −3
Original line number Diff line number Diff line
@@ -4,10 +4,8 @@ package service;
import "context.proto";

service ServiceService {
  rpc GetServiceList   (context.Empty    ) returns (context.ServiceList   ) {}
  rpc CreateService    (context.Service  ) returns (context.ServiceId     ) {}
  rpc UpdateService    (context.Service  ) returns (context.ServiceId     ) {}
  rpc DeleteService    (context.ServiceId) returns (context.Empty         ) {}
  rpc GetServiceById   (context.ServiceId) returns (context.Service       ) {}
  rpc GetConnectionList(context.Empty    ) returns (context.ConnectionList) {}
  rpc GetConnectionList(context.ServiceId) returns (context.ConnectionList) {}
}
+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,
Loading