Commit 4fdeccc1 authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Implementing the basic infrastructure for the optical attack detector.

parent 147fe0f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ REGISTRY_IMAGE=""
#REGISTRY_IMAGE="http://my-container-registry.local/"

# Set the list of components you want to build images for, and deploy.
COMPONENTS="context device service compute monitoring centralizedattackdetector"
COMPONENTS="context device service compute monitoring centralizedattackdetector opticalcentralizedattackdetector"

# Set the tag you want to use for your images.
IMAGE_TAG="tf-dev"
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ pip install --upgrade pip setuptools wheel pip-tools pylint pytest pytest-benchm
echo "" > requirements.in

#TODO: include here your component
COMPONENTS="compute context device monitoring centralizedattackdetector"
COMPONENTS="compute context device monitoring centralizedattackdetector opticalcentralizedattackdetector"

# compiling dependencies from all components
for component in $COMPONENTS
+70 −0
Original line number Diff line number Diff line
apiVersion: apps/v1
kind: Deployment
metadata:
  name: opticalcentralizedattackdetectorervice
spec:
  selector:
    matchLabels:
      app: opticalcentralizedattackdetectorervice
  template:
    metadata:
      labels:
        app: opticalcentralizedattackdetectorervice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
      - name: server
        image: registry.gitlab.com/teraflow-h2020/controller/opticalcentralizedattackdetectorervice:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 10005
        env:
        - name: DB_ENGINE
          value: "redis"
        - name: REDIS_DATABASE_ID
          value: "0"
        - name: LOG_LEVEL
          value: "DEBUG"
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:10005"]
        livenessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:10005"]
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 700m
            memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
  name: opticalcentralizedattackdetectorervice
spec:
  type: ClusterIP
  selector:
    app: opticalcentralizedattackdetectorervice
  ports:
  - name: grpc
    port: 10005
    targetPort: 10005
---
apiVersion: v1
kind: Service
metadata:
  name: opticalcentralizedattackdetectorervice-public
  labels:
    app: opticalcentralizedattackdetectorervice
spec:
  type: NodePort
  selector:
    app: opticalcentralizedattackdetectorervice
  ports:
  - name: grpc
    protocol: TCP
    port: 10005
    targetPort: 10005
---
+18 −0
Original line number Diff line number Diff line
// protocol buffers documentation: https://developers.google.com/protocol-buffers/docs/proto3
syntax = "proto3";
package centralized_attack_detector;

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

service OpticalCentralizedAttackDetectorService {
  rpc NotifyServiceUpdate (context.Service   ) returns (context.Empty) {}
  
  // rpc that triggers the attack detection loop
  rpc DetectAttack        (context.Empty     ) returns (context.Empty) {}

  // rpc called by the distributed component to report KPIs
  rpc ReportSummarizedKpi (monitoring.KpiList) returns (context.Empty) {}

  rpc ReportKpi           (monitoring.KpiList) returns (context.Empty) {}
}
+4 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

PROJECTDIR=`pwd`

cd $(dirname $0)/src
cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc
COVERAGEFILE=$PROJECTDIR/coverage/.coverage

@@ -29,6 +29,9 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    device/tests/test_unitary_driverapi.py \
    device/tests/test_unitary_service.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    opticalcentralizedattackdetector/tests/test_unitary.py

coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
    service/tests/test_unitary.py