diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..2023843d5a54f20b86b4d8fd11e8821a06299717 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +src/common/proto \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7e3b0cd6a26b755aeac4422f530c331d25a0cc43..d30172e3993d5c024bc6c105486d3678b5435d30 100644 --- a/.gitignore +++ b/.gitignore @@ -167,5 +167,8 @@ delete_local_deployment.sh local_docker_deployment.sh local_k8s_deployment.sh +# data under NDA +src/opticalattackdetector/stats.h5 + # Other logs **/logs/*.log.* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dac76342a9fdb48247cc171cfdf37fd6b60600ba..d828418a04a0074a52390ab6cb0ca400b9ba1bf3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,8 @@ include: - local: '/src/service/.gitlab-ci.yml' - local: '/src/dbscanserving/.gitlab-ci.yml' - local: '/src/opticalattackmitigator/.gitlab-ci.yml' - - local: '/src/opticalcentralizedattackdetector/.gitlab-ci.yml' + - local: '/src/opticalattackdetector/.gitlab-ci.yml' + - local: '/src/opticalattackmanager/.gitlab-ci.yml' - local: '/src/automation/.gitlab-ci.yml' - local: '/src/policy/.gitlab-ci.yml' - local: '/src/webui/.gitlab-ci.yml' diff --git a/deploy.sh b/deploy.sh index add41fa139a0127cb26d652f5b47decfe8658ad0..a9445e3f3437e61fe97f8992f12baed28f7a99df 100755 --- a/deploy.sh +++ b/deploy.sh @@ -233,6 +233,25 @@ for EXTRA_MANIFEST in $TFS_EXTRA_MANIFESTS; do done printf "\n" +# capturing host and port of the caching component +COMPONENT_OBJNAME="caching" +SERVICE_DATA=$(kubectl get service ${COMPONENT_OBJNAME}service --namespace $TFS_K8S_NAMESPACE -o json) +if [ ! -z "${SERVICE_DATA}" ]; then + # Env vars for service's host address + SERVICE_HOST=$(kubectl get service ${COMPONENT_OBJNAME}service --namespace $TFS_K8S_NAMESPACE -o json | jq -r '.spec.clusterIP') + if [ ! -z "${SERVICE_HOST}" ]; then + ENVVAR_HOST=$(echo "${COMPONENT_OBJNAME}service_SERVICE_HOST" | tr '[:lower:]' '[:upper:]') + echo "export ${ENVVAR_HOST}=${SERVICE_HOST}" >> $ENV_VARS_SCRIPT + fi + + # Env vars for service's 'redis' port (if any) + SERVICE_PORT_REDIS=$(kubectl get service ${COMPONENT_OBJNAME}service --namespace $TFS_K8S_NAMESPACE -o json | jq -r '.spec.ports[] | select(.name=="redis") | .port') + if [ ! -z "${SERVICE_PORT_REDIS}" ]; then + ENVVAR_PORT_REDIS=$(echo "${COMPONENT_OBJNAME}service_SERVICE_PORT_REDIS" | tr '[:lower:]' '[:upper:]') + echo "export ${ENVVAR_PORT_REDIS}=${SERVICE_PORT_REDIS}" >> $ENV_VARS_SCRIPT + fi +fi + # By now, leave these controls here. Some component dependencies are not well handled. if [[ "$TFS_COMPONENTS" == *"monitoring"* ]]; then @@ -256,12 +275,10 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" echo "Configuring WebUI DataStores and Dashboards..." sleep 3 - # INFLUXDB_HOST="monitoringservice" - # INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}') - # INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}" - # INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode) - # INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode) - # INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode) + REDIS_PASSWORD=`uuidgen` + kubectl create secret generic redis-secrets --namespace=$TFS_K8S_NAMESPACE \ + --from-literal=REDIS_PASSWORD=$REDIS_PASSWORD + echo "export REDIS_PASSWORD=${REDIS_PASSWORD}" >> $ENV_VARS_SCRIPT # Exposed through the ingress controller "tfs-ingress" GRAFANA_HOSTNAME="127.0.0.1" diff --git a/install_requirements.sh b/install_requirements.sh index ea9385729a6199be29926e4c13b6a05152446155..c601ac8c596ac20800e388c319eb226215d4c426 100755 --- a/install_requirements.sh +++ b/install_requirements.sh @@ -40,6 +40,12 @@ for COMPONENT in $TFS_COMPONENTS do if [ "$COMPONENT" == "automation" ] || [ "$COMPONENT" == "policy" ]; then continue; fi diff requirements.in src/$COMPONENT/requirements.in | grep '^>' | sed 's/^>\ //' >> requirements.in + echo "Dependencies from $COMPONENT:" + for d in `diff requirements.in src/$COMPONENT/requirements.in | grep '^>' | sed 's/^>\ //'` + do + echo " $d" + done + done printf "\n" diff --git a/manifests/cachingservice.yaml b/manifests/cachingservice.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e2eac81f56053292f24c59fbd015a6148d91c82 --- /dev/null +++ b/manifests/cachingservice.yaml @@ -0,0 +1,57 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cachingservice +spec: + selector: + matchLabels: + app: cachingservice + template: + metadata: + labels: + app: cachingservice + spec: + containers: + - name: redis + image: redis:7.0-alpine + env: + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis-secrets + key: REDIS_PASSWORD + ports: + - containerPort: 6379 + name: client + command: ["redis-server"] + args: + - --requirepass + - $(REDIS_PASSWORD) +--- +apiVersion: v1 +kind: Service +metadata: + name: cachingservice +spec: + type: ClusterIP + selector: + app: cachingservice + ports: + - name: redis + port: 6379 + targetPort: 6379 diff --git a/manifests/dbscanservingservice.yaml b/manifests/dbscanservingservice.yaml index 9553ed556bddaa437d89881f0c4220ae6e418239..883cc138e6a42aef7f2a1669b9b85d4c4712bd5b 100644 --- a/manifests/dbscanservingservice.yaml +++ b/manifests/dbscanservingservice.yaml @@ -31,16 +31,16 @@ spec: image: registry.gitlab.com/teraflow-h2020/controller/dbscanserving:latest imagePullPolicy: Always ports: - - containerPort: 10006 + - containerPort: 10008 env: - name: LOG_LEVEL value: "DEBUG" readinessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:10006"] + command: ["/bin/grpc_health_probe", "-addr=:10008"] livenessProbe: exec: - command: ["/bin/grpc_health_probe", "-addr=:10006"] + command: ["/bin/grpc_health_probe", "-addr=:10008"] resources: requests: cpu: 250m @@ -59,5 +59,5 @@ spec: app: dbscanservingservice ports: - name: grpc - port: 10006 - targetPort: 10006 + port: 10008 + targetPort: 10008 diff --git a/manifests/opticalattackdetectorservice.yaml b/manifests/opticalattackdetectorservice.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8b96918bd4dd2d42d9a7e260b390c938bae030a7 --- /dev/null +++ b/manifests/opticalattackdetectorservice.yaml @@ -0,0 +1,68 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: opticalattackdetectorservice +spec: + selector: + matchLabels: + app: opticalattackdetectorservice + template: + metadata: + labels: + app: opticalattackdetectorservice + spec: + terminationGracePeriodSeconds: 5 + containers: + - name: server + image: registry.gitlab.com/teraflow-h2020/controller/opticalattackdetector:latest + imagePullPolicy: Always + ports: + - containerPort: 10006 + env: + - name: LOG_LEVEL + value: "DEBUG" + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis-secrets + key: REDIS_PASSWORD + readinessProbe: + exec: + command: ["/bin/grpc_health_probe", "-addr=:10006"] + livenessProbe: + exec: + command: ["/bin/grpc_health_probe", "-addr=:10006"] + resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: 700m + memory: 1024Mi +--- +apiVersion: v1 +kind: Service +metadata: + name: opticalattackdetectorservice +spec: + type: ClusterIP + selector: + app: opticalattackdetectorservice + ports: + - name: grpc + port: 10006 + targetPort: 10006 diff --git a/manifests/opticalcentralizedattackdetectorservice.yaml b/manifests/opticalattackmanagerservice.yaml similarity index 68% rename from manifests/opticalcentralizedattackdetectorservice.yaml rename to manifests/opticalattackmanagerservice.yaml index 664bcb54348e533ff40c7f882b5668f727a39053..21309ab8f91e7a10dc22c26c8cfc83fa1a9f4b6b 100644 --- a/manifests/opticalcentralizedattackdetectorservice.yaml +++ b/manifests/opticalattackmanagerservice.yaml @@ -15,32 +15,26 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: opticalcentralizedattackdetectorservice + name: opticalattackmanagerservice spec: selector: matchLabels: - app: opticalcentralizedattackdetectorservice + app: opticalattackmanagerservice template: metadata: labels: - app: opticalcentralizedattackdetectorservice + app: opticalattackmanagerservice spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: registry.gitlab.com/teraflow-h2020/controller/opticalcentralizedattackdetector:latest + image: registry.gitlab.com/teraflow-h2020/controller/opticalattackmanager:latest imagePullPolicy: Always ports: - containerPort: 10005 - envFrom: - - secretRef: - name: monitoring-secrets - readinessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:10005"] - livenessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:10005"] + env: + - name: LOG_LEVEL + value: "DEBUG" resources: requests: cpu: 250m @@ -52,11 +46,11 @@ spec: apiVersion: v1 kind: Service metadata: - name: opticalcentralizedattackdetectorservice + name: opticalattackmanagerservice spec: type: ClusterIP selector: - app: opticalcentralizedattackdetectorservice + app: opticalattackmanagerservice ports: - name: grpc port: 10005 diff --git a/my_deploy.sh b/my_deploy.sh index e70a12e1556ab06f6daa89c316c6a6ed61c4e059..65d440cdfcc4e5304d70afa40d111f4bacb84157 100644 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -9,6 +9,9 @@ export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/" # l3_attackmitigator l3_centralizedattackdetector l3_distributedattackdetector export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui" +# including components of the optical cybersecurity app +export TFS_COMPONENTS="${TFS_COMPONENTS} dbscanserving opticalattackmitigator" # opticalattackdetector opticalattackmanager" + # Set the tag you want to use for your images. export TFS_IMAGE_TAG="dev" @@ -16,7 +19,7 @@ export TFS_IMAGE_TAG="dev" export TFS_K8S_NAMESPACE="tfs" # Set additional manifest files to be applied after the deployment -export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml" +export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml manifests/cachingservice.yaml" # Set the neew Grafana admin password export TFS_GRAFANA_PASSWORD="admin123+" diff --git a/proto/attack_mitigator.proto b/proto/attack_mitigator.proto deleted file mode 100644 index e538a9d2e62f7bc0cf91497b6b13414c36e1bc41..0000000000000000000000000000000000000000 --- a/proto/attack_mitigator.proto +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -// -// 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. - -// protocol buffers documentation: https://developers.google.com/protocol-buffers/docs/proto3 -syntax = "proto3"; -package attack_mitigator; - -import "context.proto"; - -service AttackMitigator { - rpc NotifyAttack (AttackDescription) returns (AttackResponse) {} -} - -message AttackDescription { - context.Uuid cs_id = 1; - int32 attack_id = 2; - float confidence = 3; - string attack_description = 4; -} - -message AttackResponse { - context.Uuid cs_id = 1; - int32 attack_id = 2; - string attack_description = 3; - int32 response_strategy_id = 4; - string response_strategy_description = 5; -} diff --git a/proto/centralized_attack_detector.proto b/proto/centralized_attack_detector.proto deleted file mode 100644 index 4ce34cfa443b67aa8d060802dca6c9c29b2f7087..0000000000000000000000000000000000000000 --- a/proto/centralized_attack_detector.proto +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -// -// 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. - -// protocol buffers documentation: https://developers.google.com/protocol-buffers/docs/proto3 -syntax = "proto3"; -package centralized_attack_detector; - -import "context.proto"; -import "monitoring.proto"; - -service CentralizedAttackDetectorService { - 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) {} -} diff --git a/proto/generate_code_python.sh b/proto/generate_code_python.sh index b0df357eb079fb2721cffca43465588f7013e341..42626bf1d431509dde1cf04349b71d62748e4c1b 100755 --- a/proto/generate_code_python.sh +++ b/proto/generate_code_python.sh @@ -19,6 +19,9 @@ cd $(dirname $0) mkdir -p src/python rm -rf src/python/*.py +mkdir -p src/python/asyncio +rm -rf src/python/asyncio/*.py + tee src/python/__init__.py << EOF > /dev/null # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) # @@ -35,8 +38,28 @@ tee src/python/__init__.py << EOF > /dev/null # limitations under the License. EOF +tee src/python/asyncio/__init__.py << EOF > /dev/null +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. +EOF + + # Generate Python code python3 -m grpc_tools.protoc -I=./ --python_out=src/python/ --grpc_python_out=src/python/ *.proto +# new line added to generate protobuf for the `grpclib` library +python3 -m grpc_tools.protoc -I=./ --python_out=src/python/asyncio --grpclib_python_out=src/python/asyncio *.proto + # Arrange generated code imports to enable imports from arbitrary subpackages find src/python -type f -iname *.py -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; diff --git a/proto/distributed_cybersecurity.proto b/proto/optical_attack_detector.proto similarity index 74% rename from proto/distributed_cybersecurity.proto rename to proto/optical_attack_detector.proto index 664e1383f162ee874d1ef89b0e59c70ac2ee62e1..6d363f99872a1f5d54d90fbaa28f43d281ae08dc 100644 --- a/proto/distributed_cybersecurity.proto +++ b/proto/optical_attack_detector.proto @@ -14,17 +14,19 @@ // protocol buffers documentation: https://developers.google.com/protocol-buffers/docs/proto3 syntax = "proto3"; -package distributed_cybersecurity; +package optical_attack_detector; import "context.proto"; import "monitoring.proto"; -service DistributedCyberSecurityService { - // rpc that triggers the attack detection loop - rpc DetectAttack (context.Empty) returns (context.Empty) {} +service OpticalAttackDetectorService { + + // rpc that executes the detection loop for a particular service + rpc DetectAttack (DetectionRequest) returns (context.Empty) {} - // receiving KPIs from monitored devices (packed processors) - rpc ReportKpi(monitoring.KpiList) returns (context.Empty) {} } - +message DetectionRequest { + context.ServiceId service_id = 1; + monitoring.KpiId kpi_id = 2; +} diff --git a/proto/optical_centralized_attack_detector.proto b/proto/optical_centralized_attack_detector.proto deleted file mode 100644 index d480054f2ca3b1cf32cbb40c51df51c562f9b4d5..0000000000000000000000000000000000000000 --- a/proto/optical_centralized_attack_detector.proto +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -// -// 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. - -// 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) {} -} diff --git a/scripts/build_run_report_tests_locally.sh b/scripts/build_run_report_tests_locally.sh index 9bdc81d9894df35a6bcc325d78e7f1f5214e8a96..74d40998981062304aeddf2ffd77e87aba718fdc 100755 --- a/scripts/build_run_report_tests_locally.sh +++ b/scripts/build_run_report_tests_locally.sh @@ -38,8 +38,16 @@ fi docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$COMPONENT_NAME/Dockerfile . -docker run --name $IMAGE_NAME -d -v "${PWD}/src/${COMPONENT_NAME}/tests:/home/${COMPONENT_NAME}/results" --network=teraflowbridge --rm $IMAGE_NAME:$IMAGE_TAG +# detecting the existence of a dotenv file to be used when launching the component +ENV_FILE="" +if [ -f "./src/$COMPONENT_NAME/.env" ] +then + ENV_FILE="--env-file ./src/$COMPONENT_NAME/.env" +fi + +docker run --name $IMAGE_NAME -d $ENV_FILE -v "${PWD}/src/${COMPONENT_NAME}/tests:/home/${COMPONENT_NAME}/results" --network=teraflowbridge --rm $IMAGE_NAME:$IMAGE_TAG +# executes the test and exports the report docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $COMPONENT_NAME/tests/ --junitxml=/home/${COMPONENT_NAME}/results/${COMPONENT_NAME}_report.xml" PROJECTDIR=`pwd` diff --git a/src/common/Constants.py b/src/common/Constants.py index a536ef60047eb1f210f8d98d207134d377adcbed..867561b3997b3fca9271449ce926efb74d57a713 100644 --- a/src/common/Constants.py +++ b/src/common/Constants.py @@ -35,37 +35,46 @@ DEFAULT_TOPOLOGY_UUID = 'admin' # Default service names class ServiceNameEnum(Enum): - CONTEXT = 'context' - DEVICE = 'device' - SERVICE = 'service' - SLICE = 'slice' - AUTOMATION = 'automation' - POLICY = 'policy' - MONITORING = 'monitoring' - DLT = 'dlt' - COMPUTE = 'compute' - CYBERSECURITY = 'cybersecurity' - INTERDOMAIN = 'interdomain' - PATHCOMP = 'pathcomp' - WEBUI = 'webui' + CONTEXT = 'context' + DEVICE = 'device' + SERVICE = 'service' + SLICE = 'slice' + AUTOMATION = 'automation' + POLICY = 'policy' + MONITORING = 'monitoring' + DLT = 'dlt' + COMPUTE = 'compute' + CYBERSECURITY = 'cybersecurity' + INTERDOMAIN = 'interdomain' + PATHCOMP = 'pathcomp' + WEBUI = 'webui' + DBSCANSERVING = 'dbscanserving' + OPTICALATTACKMANAGER = 'opticalattackmanager' + OPTICALATTACKDETECTOR = 'opticalattackdetector' + OPTICALATTACKMITIGATOR = 'opticalattackmitigator' + CACHING = 'caching' # Used for test and debugging only DLT_GATEWAY = 'dlt-gateway' + # Default gRPC service ports DEFAULT_SERVICE_GRPC_PORTS = { - ServiceNameEnum.CONTEXT .value : 1010, - ServiceNameEnum.DEVICE .value : 2020, - ServiceNameEnum.SERVICE .value : 3030, - ServiceNameEnum.SLICE .value : 4040, - ServiceNameEnum.AUTOMATION .value : 5050, - ServiceNameEnum.POLICY .value : 6060, - ServiceNameEnum.MONITORING .value : 7070, - ServiceNameEnum.DLT .value : 8080, - ServiceNameEnum.COMPUTE .value : 9090, - ServiceNameEnum.CYBERSECURITY.value : 10000, - ServiceNameEnum.INTERDOMAIN .value : 10010, - ServiceNameEnum.PATHCOMP .value : 10020, + ServiceNameEnum.CONTEXT .value : 1010, + ServiceNameEnum.DEVICE .value : 2020, + ServiceNameEnum.SERVICE .value : 3030, + ServiceNameEnum.SLICE .value : 4040, + ServiceNameEnum.AUTOMATION .value : 5050, + ServiceNameEnum.POLICY .value : 6060, + ServiceNameEnum.MONITORING .value : 7070, + ServiceNameEnum.DLT .value : 8080, + ServiceNameEnum.COMPUTE .value : 9090, + ServiceNameEnum.INTERDOMAIN .value : 10010, + ServiceNameEnum.PATHCOMP .value : 10020, + ServiceNameEnum.OPTICALATTACKMANAGER .value : 10005, + ServiceNameEnum.OPTICALATTACKDETECTOR .value : 10006, + ServiceNameEnum.OPTICALATTACKMITIGATOR .value : 10007, + ServiceNameEnum.DBSCANSERVING .value : 10008, # Used for test and debugging only ServiceNameEnum.DLT_GATEWAY .value : 50051, diff --git a/src/common/Settings.py b/src/common/Settings.py index e9d5f406d2acad0d31ae94b604183c129d28f146..9de8cfcc74a3235b6bc703acaf3413b7a337cbd4 100644 --- a/src/common/Settings.py +++ b/src/common/Settings.py @@ -83,7 +83,7 @@ def get_log_level(): return get_setting(ENVVAR_LOG_LEVEL, default=DEFAULT_LOG_LEVEL) def get_metrics_port(): - return get_setting(ENVVAR_METRICS_PORT, default=DEFAULT_METRICS_PORT) + return int(get_setting(ENVVAR_METRICS_PORT, default=DEFAULT_METRICS_PORT)) def get_grpc_bind_address(): return get_setting(ENVVAR_GRPC_BIND_ADDRESS, default=DEFAULT_GRPC_BIND_ADDRESS) diff --git a/src/dbscanserving/.gitlab-ci.yml b/src/dbscanserving/.gitlab-ci.yml index fd0d66bac25bbb5417a9f90415f3d0732312516b..ae3aa231214f26f38c5c9f98633bc02898151a52 100644 --- a/src/dbscanserving/.gitlab-ci.yml +++ b/src/dbscanserving/.gitlab-ci.yml @@ -21,7 +21,7 @@ build dbscanserving: 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 build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile . - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" after_script: @@ -51,11 +51,11 @@ unit test dbscanserving: - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - - docker run --name $IMAGE_NAME -d -p 10006:10006 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG + - docker run --name $IMAGE_NAME -d -p 10008:10008 -v "$PWD/src/$IMAGE_NAME/tests:/home/${IMAGE_NAME}/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG - sleep 5 - docker ps -a - docker logs $IMAGE_NAME - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/home/${IMAGE_NAME}/results/${IMAGE_NAME}_report.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: diff --git a/src/dbscanserving/Config.py b/src/dbscanserving/Config.py index 6604abe6cda5bd203621de9f09f48ca5f6c8256e..5e462dac105205a3140ddb7b3a9a95c5feee3478 100644 --- a/src/dbscanserving/Config.py +++ b/src/dbscanserving/Config.py @@ -18,9 +18,7 @@ import logging LOG_LEVEL = logging.DEBUG # gRPC settings -GRPC_SERVICE_PORT = 10006 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 +GRPC_SERVICE_PORT = 10008 # Prometheus settings METRICS_PORT = 9192 diff --git a/src/dbscanserving/Dockerfile b/src/dbscanserving/Dockerfile index 31cf21b0ea8da830b72c726ee3e63dd1bc61d094..f6e5aa02dcf426025e4b79768a3e8d256da13a62 100644 --- a/src/dbscanserving/Dockerfile +++ b/src/dbscanserving/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3-slim +FROM python:3.9-slim # Install dependencies RUN apt-get --yes --quiet --quiet update && \ @@ -27,22 +27,55 @@ 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 +# Creating a user for security reasons +RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow +USER teraflow + +RUN mkdir -p /home/teraflow/controller/common/proto + +# set working directory +WORKDIR /home/teraflow/controller + +# Get Python packages per module +ENV VIRTUAL_ENV=/home/teraflow/venv +RUN python3 -m venv ${VIRTUAL_ENV} +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" + # Get generic Python packages -RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade setuptools wheel +RUN python3 -m pip install --upgrade pip-tools + +# Get common Python packages +# Note: this step enables sharing the previous Docker build steps among all the Python components +COPY --chown=teraflow:teraflow common_requirements.in common_requirements.in +RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in +RUN python3 -m pip install -r common_requirements.txt + +# Add common files into working directory +WORKDIR /home/teraflow/controller/common +COPY --chown=teraflow:teraflow src/common/. ./ -# Set working directory -WORKDIR /var/teraflow +# Create proto sub-folder, copy .proto files, and generate Python code +WORKDIR /home/teraflow/controller/common/proto +RUN touch __init__.py +COPY --chown=teraflow:teraflow proto/*.proto ./ +RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto +RUN rm *.proto +RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; # Create module sub-folders -RUN mkdir -p /var/teraflow/dbscanserving +RUN mkdir -p /home/teraflow/controller/dbscanserving +WORKDIR /home/teraflow/controller # Get Python packages per module -COPY dbscanserving/requirements.in dbscanserving/requirements.in -RUN pip-compile --output-file=dbscanserving/requirements.txt dbscanserving/requirements.in +COPY --chown=teraflow:teraflow ./src/dbscanserving/requirements.in dbscanserving/requirements.in +# consider common and specific requirements to avoid inconsistencies with dependencies +RUN pip-compile --quiet --output-file=dbscanserving/requirements.txt dbscanserving/requirements.in common_requirements.in RUN python3 -m pip install -r dbscanserving/requirements.txt -COPY common/. common -COPY dbscanserving/. dbscanserving +# Add component files into working directory +COPY --chown=teraflow:teraflow ./src/dbscanserving/. dbscanserving # Start dbscanserving service ENTRYPOINT ["python", "-m", "dbscanserving.service"] diff --git a/src/dbscanserving/__init__.py b/src/dbscanserving/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/dbscanserving/__init__.py +++ b/src/dbscanserving/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/dbscanserving/client/DbscanServingClient.py b/src/dbscanserving/client/DbscanServingClient.py index 286b3318e7568f3edcfff9032c30b1244d826533..362f0975a0f8c4e7bfd670ce228a647df91db7af 100644 --- a/src/dbscanserving/client/DbscanServingClient.py +++ b/src/dbscanserving/client/DbscanServingClient.py @@ -12,37 +12,62 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from common.tools.client.RetryDecorator import retry, delay_exponential -from dbscanserving.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse -from dbscanserving.proto.dbscanserving_pb2_grpc import DetectorStub +import logging +from typing import Counter +import grpc + +from common.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse +from common.proto.dbscanserving_pb2_grpc import DetectorStub +from common.Settings import get_log_level, get_setting +from common.tools.client.RetryDecorator import delay_exponential, retry + +log_level = get_log_level() +logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) -RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') +RETRY_DECORATOR = retry( + max_retries=MAX_RETRIES, + delay_function=DELAY_FUNCTION, + prepare_method_name="connect", +) + class DbscanServingClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) - LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) + def __init__(self, host=None, port=None): + if not host: + host = get_setting("DBSCANSERVINGSERVICE_SERVICE_HOST") + if not port: + port = get_setting("DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC") + self.endpoint = "{:s}:{:s}".format(str(host), str(port)) + LOGGER.debug("Creating channel to {:s}...".format(str(self.endpoint))) self.channel = None self.stub = None self.connect() - LOGGER.debug('Channel created') + LOGGER.debug("Channel created") def connect(self): self.channel = grpc.insecure_channel(self.endpoint) self.stub = DetectorStub(self.channel) def close(self): - if(self.channel is not None): self.channel.close() + if self.channel is not None: + self.channel.close() self.channel = None self.stub = None @RETRY_DECORATOR - def Detect(self, request : DetectionRequest) -> DetectionResponse: - LOGGER.debug('Detect request: {:s}'.format(str(request))) - response = self.stub.Detect(request) - LOGGER.debug('Detect result: {:s}'.format(str(response))) + def Detect(self, request: DetectionRequest) -> DetectionResponse: + LOGGER.debug( + "Detect request with {} samples and {} features".format( + request.num_samples, request.num_features + ) + ) + response: DetectionResponse = self.stub.Detect(request) + LOGGER.debug( + "Detect result with {} cluster indices [{}]".format( + len(response.cluster_indices), Counter(response.cluster_indices) + ) + ) return response diff --git a/src/dbscanserving/client/__init__.py b/src/dbscanserving/client/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/dbscanserving/client/__init__.py +++ b/src/dbscanserving/client/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/dbscanserving/proto/dbscanserving_pb2.py b/src/dbscanserving/proto/dbscanserving_pb2.py deleted file mode 100644 index f2d6c37c7c567394d3b12392a1fa4e0f748f6625..0000000000000000000000000000000000000000 --- a/src/dbscanserving/proto/dbscanserving_pb2.py +++ /dev/null @@ -1,244 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: dbscanserving.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='dbscanserving.proto', - package='dbscanserving', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x13\x64\x62scanserving.proto\x12\rdbscanserving\"\x1a\n\x06Sample\x12\x10\n\x08\x66\x65\x61tures\x18\x01 \x03(\x02\"\xc2\x01\n\x10\x44\x65tectionRequest\x12\x0b\n\x03\x65ps\x18\x01 \x01(\x02\x12\x13\n\x0bmin_samples\x18\x02 \x01(\x05\x12%\n\x06metric\x18\x03 \x01(\x0e\x32\x15.dbscanserving.Metric\x12\x13\n\x0bnum_samples\x18\x04 \x01(\x05\x12\x14\n\x0cnum_features\x18\x05 \x01(\x05\x12&\n\x07samples\x18\x06 \x03(\x0b\x32\x15.dbscanserving.Sample\x12\x12\n\nidentifier\x18\x07 \x01(\x05\",\n\x11\x44\x65tectionResponse\x12\x17\n\x0f\x63luster_indices\x18\x01 \x03(\x05*\x17\n\x06Metric\x12\r\n\tEUCLIDEAN\x10\x00\x32W\n\x08\x44\x65tector\x12K\n\x06\x44\x65tect\x12\x1f.dbscanserving.DetectionRequest\x1a .dbscanserving.DetectionResponseb\x06proto3' -) - -_METRIC = _descriptor.EnumDescriptor( - name='Metric', - full_name='dbscanserving.Metric', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='EUCLIDEAN', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=309, - serialized_end=332, -) -_sym_db.RegisterEnumDescriptor(_METRIC) - -Metric = enum_type_wrapper.EnumTypeWrapper(_METRIC) -EUCLIDEAN = 0 - - - -_SAMPLE = _descriptor.Descriptor( - name='Sample', - full_name='dbscanserving.Sample', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='features', full_name='dbscanserving.Sample.features', index=0, - number=1, type=2, cpp_type=6, 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=38, - serialized_end=64, -) - - -_DETECTIONREQUEST = _descriptor.Descriptor( - name='DetectionRequest', - full_name='dbscanserving.DetectionRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='eps', full_name='dbscanserving.DetectionRequest.eps', index=0, - number=1, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(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='min_samples', full_name='dbscanserving.DetectionRequest.min_samples', index=1, - number=2, type=5, cpp_type=1, 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='metric', full_name='dbscanserving.DetectionRequest.metric', index=2, - number=3, 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='num_samples', full_name='dbscanserving.DetectionRequest.num_samples', index=3, - number=4, type=5, cpp_type=1, 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='num_features', full_name='dbscanserving.DetectionRequest.num_features', index=4, - number=5, type=5, cpp_type=1, 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='samples', full_name='dbscanserving.DetectionRequest.samples', index=5, - number=6, 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='identifier', full_name='dbscanserving.DetectionRequest.identifier', index=6, - number=7, type=5, cpp_type=1, 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=67, - serialized_end=261, -) - - -_DETECTIONRESPONSE = _descriptor.Descriptor( - name='DetectionResponse', - full_name='dbscanserving.DetectionResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='cluster_indices', full_name='dbscanserving.DetectionResponse.cluster_indices', index=0, - number=1, type=5, cpp_type=1, 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=263, - serialized_end=307, -) - -_DETECTIONREQUEST.fields_by_name['metric'].enum_type = _METRIC -_DETECTIONREQUEST.fields_by_name['samples'].message_type = _SAMPLE -DESCRIPTOR.message_types_by_name['Sample'] = _SAMPLE -DESCRIPTOR.message_types_by_name['DetectionRequest'] = _DETECTIONREQUEST -DESCRIPTOR.message_types_by_name['DetectionResponse'] = _DETECTIONRESPONSE -DESCRIPTOR.enum_types_by_name['Metric'] = _METRIC -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -Sample = _reflection.GeneratedProtocolMessageType('Sample', (_message.Message,), { - 'DESCRIPTOR' : _SAMPLE, - '__module__' : 'dbscanserving_pb2' - # @@protoc_insertion_point(class_scope:dbscanserving.Sample) - }) -_sym_db.RegisterMessage(Sample) - -DetectionRequest = _reflection.GeneratedProtocolMessageType('DetectionRequest', (_message.Message,), { - 'DESCRIPTOR' : _DETECTIONREQUEST, - '__module__' : 'dbscanserving_pb2' - # @@protoc_insertion_point(class_scope:dbscanserving.DetectionRequest) - }) -_sym_db.RegisterMessage(DetectionRequest) - -DetectionResponse = _reflection.GeneratedProtocolMessageType('DetectionResponse', (_message.Message,), { - 'DESCRIPTOR' : _DETECTIONRESPONSE, - '__module__' : 'dbscanserving_pb2' - # @@protoc_insertion_point(class_scope:dbscanserving.DetectionResponse) - }) -_sym_db.RegisterMessage(DetectionResponse) - - - -_DETECTOR = _descriptor.ServiceDescriptor( - name='Detector', - full_name='dbscanserving.Detector', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=334, - serialized_end=421, - methods=[ - _descriptor.MethodDescriptor( - name='Detect', - full_name='dbscanserving.Detector.Detect', - index=0, - containing_service=None, - input_type=_DETECTIONREQUEST, - output_type=_DETECTIONRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), -]) -_sym_db.RegisterServiceDescriptor(_DETECTOR) - -DESCRIPTOR.services_by_name['Detector'] = _DETECTOR - -# @@protoc_insertion_point(module_scope) diff --git a/src/dbscanserving/proto/dbscanserving_pb2_grpc.py b/src/dbscanserving/proto/dbscanserving_pb2_grpc.py deleted file mode 100644 index 895ced1484df2101bb055f28b6a6d3631e7e68da..0000000000000000000000000000000000000000 --- a/src/dbscanserving/proto/dbscanserving_pb2_grpc.py +++ /dev/null @@ -1,66 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from . import dbscanserving_pb2 as dbscanserving__pb2 - - -class DetectorStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.Detect = channel.unary_unary( - '/dbscanserving.Detector/Detect', - request_serializer=dbscanserving__pb2.DetectionRequest.SerializeToString, - response_deserializer=dbscanserving__pb2.DetectionResponse.FromString, - ) - - -class DetectorServicer(object): - """Missing associated documentation comment in .proto file.""" - - def Detect(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_DetectorServicer_to_server(servicer, server): - rpc_method_handlers = { - 'Detect': grpc.unary_unary_rpc_method_handler( - servicer.Detect, - request_deserializer=dbscanserving__pb2.DetectionRequest.FromString, - response_serializer=dbscanserving__pb2.DetectionResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'dbscanserving.Detector', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class Detector(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def Detect(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, '/dbscanserving.Detector/Detect', - dbscanserving__pb2.DetectionRequest.SerializeToString, - dbscanserving__pb2.DetectionResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/src/dbscanserving/requirements.in b/src/dbscanserving/requirements.in index 56f9e0673f4899ea9b4d6abcba5e13d005454b13..d5e06028d853376200623c16ebcf4992f4ae60c2 100644 --- a/src/dbscanserving/requirements.in +++ b/src/dbscanserving/requirements.in @@ -1,7 +1 @@ -grpcio-health-checking -prometheus-client -pytest -pytest-benchmark -grpcio scikit-learn -coverage \ No newline at end of file diff --git a/src/dbscanserving/requirements.txt b/src/dbscanserving/requirements.txt deleted file mode 100644 index 4f9bee9891129ad09e4281180e1aee2858df0c29..0000000000000000000000000000000000000000 --- a/src/dbscanserving/requirements.txt +++ /dev/null @@ -1,52 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: -# -# pip-compile --output-file=requirements.txt requirements.in -# -attrs==21.2.0 - # via pytest -grpcio==1.42.0 - # via - # -r requirements.in - # grpcio-health-checking -grpcio-health-checking==1.42.0 - # via -r requirements.in -iniconfig==1.1.1 - # via pytest -joblib==1.1.0 - # via scikit-learn -numpy==1.21.4 - # via - # scikit-learn - # scipy -packaging==21.3 - # via pytest -pluggy==1.0.0 - # via pytest -prometheus-client==0.12.0 - # via -r requirements.in -protobuf==3.19.1 - # via grpcio-health-checking -py==1.11.0 - # via pytest -py-cpuinfo==8.0.0 - # via pytest-benchmark -pyparsing==3.0.6 - # via packaging -pytest==6.2.5 - # via - # -r requirements.in - # pytest-benchmark -pytest-benchmark==3.4.1 - # via -r requirements.in -scikit-learn==1.0.1 - # via -r requirements.in -scipy==1.7.3 - # via scikit-learn -six==1.16.0 - # via grpcio -threadpoolctl==3.0.0 - # via scikit-learn -toml==0.10.2 - # via pytest diff --git a/src/dbscanserving/service/DbscanService.py b/src/dbscanserving/service/DbscanService.py index 97654fa30532d2544cfdbbc9260b049f293ed395..3511e4e5fdcf85085dc783dc73688b4422c5736e 100644 --- a/src/dbscanserving/service/DbscanService.py +++ b/src/dbscanserving/service/DbscanService.py @@ -12,23 +12,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc import logging from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH + +import grpc +from grpc_health.v1.health import OVERALL_HEALTH, HealthServicer from grpc_health.v1.health_pb2 import HealthCheckResponse from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server -from dbscanserving.proto.dbscanserving_pb2_grpc import add_DetectorServicer_to_server -from dbscanserving.service.DbscanServiceServicerImpl import DbscanServiceServicerImpl -from dbscanserving.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -BIND_ADDRESS = '0.0.0.0' +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.proto.dbscanserving_pb2_grpc import add_DetectorServicer_to_server +from dbscanserving.Config import GRPC_SERVICE_PORT +from dbscanserving.service.DbscanServiceServicerImpl import \ + DbscanServiceServicerImpl + +BIND_ADDRESS = "0.0.0.0" LOGGER = logging.getLogger(__name__) + class DbscanService: def __init__( - self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): + self, + address=BIND_ADDRESS, + port=GRPC_SERVICE_PORT, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + ): self.address = address self.port = port @@ -41,30 +51,41 @@ class DbscanService: self.server = None def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.debug('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) + self.endpoint = "{:s}:{:s}".format(str(self.address), str(self.port)) + LOGGER.debug( + "Starting Service (tentative endpoint: {:s}, max_workers: {:s})...".format( + str(self.endpoint), str(self.max_workers) + ) + ) self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) + self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.dbscan_servicer = DbscanServiceServicerImpl() add_DetectorServicer_to_server(self.dbscan_servicer, self.server) self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) + 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 = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(self.endpoint)) + self.endpoint = "{:s}:{:s}".format(str(self.address), str(port)) + LOGGER.info("Listening on {:s}...".format(self.endpoint)) self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member + self.health_servicer.set( + OVERALL_HEALTH, HealthCheckResponse.SERVING + ) # pylint: disable=maybe-no-member - LOGGER.debug('Service started') + LOGGER.debug("Service started") def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) + LOGGER.debug( + "Stopping service (grace period {:s} seconds)...".format( + str(self.grace_period) + ) + ) self.health_servicer.enter_graceful_shutdown() self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') + LOGGER.debug("Service stopped") diff --git a/src/dbscanserving/service/DbscanServiceServicerImpl.py b/src/dbscanserving/service/DbscanServiceServicerImpl.py index 5560eec1e333c16c0ea980a5af14e856c3909431..584a1ae0f9905e55eb1eda965f9a68ff8a50c32a 100644 --- a/src/dbscanserving/service/DbscanServiceServicerImpl.py +++ b/src/dbscanserving/service/DbscanServiceServicerImpl.py @@ -12,34 +12,45 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, grpc, logging +import logging + +import grpc from sklearn.cluster import DBSCAN -from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method -from dbscanserving.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse -from dbscanserving.proto.dbscanserving_pb2_grpc import DetectorServicer + +from common.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse +from common.proto.dbscanserving_pb2_grpc import DetectorServicer +from common.rpc_method_wrapper.Decorator import (create_metrics, + safe_and_metered_rpc_method) LOGGER = logging.getLogger(__name__) -SERVICE_NAME = 'DbscanServing' -METHOD_NAMES = ['Detect'] +SERVICE_NAME = "DbscanServing" +METHOD_NAMES = ["Detect"] METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class DbscanServiceServicerImpl(DetectorServicer): - def __init__(self): - LOGGER.debug('Creating Servicer...') - LOGGER.debug('Servicer Created') + LOGGER.debug("Creating Servicer...") + LOGGER.debug("Servicer Created") @safe_and_metered_rpc_method(METRICS, LOGGER) - def Detect(self, request : DetectionRequest, context : grpc.ServicerContext) -> DetectionResponse: + def Detect( + self, request: DetectionRequest, context: grpc.ServicerContext + ) -> DetectionResponse: if request.num_samples != len(request.samples): - context.set_details("The sample dimension declared does not match with the number of samples received.") - LOGGER.debug(f"The sample dimension declared does not match with the number of samples received. Declared: {request.num_samples} - Received: {len(request.samples)}") + context.set_details( + f"The sample dimension declared ({request.num_samples}) does not match with the number of samples received ({len(request.samples)})." + ) + LOGGER.debug( + f"The sample dimension declared does not match with the number of samples received. Declared: {request.num_samples} - Received: {len(request.samples)}" + ) context.set_code(grpc.StatusCode.INVALID_ARGUMENT) return DetectionResponse() # TODO: implement the validation of the features dimension - clusters = DBSCAN(eps=request.eps, min_samples=request.min_samples).fit_predict([[x for x in sample.features] for sample in request.samples]) + clusters = DBSCAN(eps=request.eps, min_samples=request.min_samples).fit_predict( + [[x for x in sample.features] for sample in request.samples] + ) response = DetectionResponse() for cluster in clusters: response.cluster_indices.append(cluster) diff --git a/src/dbscanserving/service/__init__.py b/src/dbscanserving/service/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/dbscanserving/service/__init__.py +++ b/src/dbscanserving/service/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/dbscanserving/service/__main__.py b/src/dbscanserving/service/__main__.py index cad074a409af9e3106d84c81d3f20c6e6d9b1274..154effde2e171022aedc11ced909f44c46335ed6 100644 --- a/src/dbscanserving/service/__main__.py +++ b/src/dbscanserving/service/__main__.py @@ -12,53 +12,66 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, logging, signal, sys, time, threading, multiprocessing +import logging +import signal +import sys +import threading + from prometheus_client import start_http_server -from common.Settings import get_setting -from dbscanserving.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT) + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.Settings import get_log_level, get_metrics_port, get_setting +from dbscanserving.Config import GRPC_SERVICE_PORT from dbscanserving.service.DbscanService import DbscanService terminate = threading.Event() LOGGER = None -def signal_handler(signal, frame): # pylint: disable=redefined-outer-name - LOGGER.warning('Terminate signal received') + +def signal_handler(signal, frame): # pylint: disable=redefined-outer-name + LOGGER.warning("Terminate signal received") terminate.set() -def main(): - global LOGGER # pylint: disable=global-statement - service_port = get_setting('DBSCANSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) +def main(): + global LOGGER # pylint: disable=global-statement + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) - signal.signal(signal.SIGINT, signal_handler) + service_port = get_setting( + "DBSCANSERVICE_SERVICE_PORT_GRPC", default=GRPC_SERVICE_PORT + ) + grace_period = get_setting("GRACE_PERIOD", default=DEFAULT_GRPC_GRACE_PERIOD) + max_workers = get_setting("MAX_WORKERS", default=DEFAULT_GRPC_MAX_WORKERS) + + signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) - LOGGER.info('Starting...') + LOGGER.info("Starting...") # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) # Starting CentralizedCybersecurity service grpc_service = DbscanService( - port=service_port, max_workers=max_workers, grace_period=grace_period) + port=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 + while not terminate.wait(timeout=0.1): + pass - LOGGER.info('Terminating...') + LOGGER.info("Terminating...") grpc_service.stop() - LOGGER.info('Bye') + LOGGER.info("Bye") return 0 -if __name__ == '__main__': + +if __name__ == "__main__": sys.exit(main()) diff --git a/src/dbscanserving/tests/__init__.py b/src/dbscanserving/tests/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/dbscanserving/tests/__init__.py +++ b/src/dbscanserving/tests/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/dbscanserving/tests/test_unitary.py b/src/dbscanserving/tests/test_unitary.py index 8198c9e215d13cfee62bc7ee13a0daa8224f37a5..877727f0b81b4fe24b0d28f12f10e58f072ba223 100644 --- a/src/dbscanserving/tests/test_unitary.py +++ b/src/dbscanserving/tests/test_unitary.py @@ -12,32 +12,51 @@ # See the License for the specific language governing permissions and # limitations under the License. -import random, logging, pytest, numpy -from dbscanserving.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD +import logging +import os +import random +from unittest.mock import patch + +import pytest + +from common.proto.dbscanserving_pb2 import (DetectionRequest, + DetectionResponse, Sample) from dbscanserving.client.DbscanServingClient import DbscanServingClient +from dbscanserving.Config import GRPC_SERVICE_PORT from dbscanserving.service.DbscanService import DbscanService -from dbscanserving.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse, Sample -port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports +port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -@pytest.fixture(scope='session') + +@pytest.fixture(scope="session") def dbscanserving_service(): - _service = DbscanService( - port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) + _service = DbscanService(port=port) _service.start() yield _service _service.stop() -@pytest.fixture(scope='session') + +@pytest.fixture(scope="session") def dbscanserving_client(): - _client = DbscanServingClient(address='127.0.0.1', port=port) - yield _client + with patch.dict( + os.environ, + { + "DBSCANSERVINGSERVICE_SERVICE_HOST": "127.0.0.1", + "DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC": str(port), + }, + clear=True, + ): + _client = DbscanServingClient() + yield _client _client.close() -def test_detection_correct(dbscanserving_service, dbscanserving_client: DbscanServingClient): + +def test_detection_correct( + dbscanserving_service, dbscanserving_client: DbscanServingClient +): request: DetectionRequest = DetectionRequest() request.num_samples = 310 @@ -48,25 +67,28 @@ def test_detection_correct(dbscanserving_service, dbscanserving_client: DbscanSe for _ in range(200): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(0., 10.)) + grpc_sample.features.append(random.uniform(0.0, 10.0)) request.samples.append(grpc_sample) - + for _ in range(100): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(50., 60.)) + grpc_sample.features.append(random.uniform(50.0, 60.0)) request.samples.append(grpc_sample) - + for _ in range(10): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(5000., 6000.)) + grpc_sample.features.append(random.uniform(5000.0, 6000.0)) request.samples.append(grpc_sample) response: DetectionResponse = dbscanserving_client.Detect(request) assert len(response.cluster_indices) == 310 -def test_detection_incorrect(dbscanserving_service, dbscanserving_client: DbscanServingClient): + +def test_detection_incorrect( + dbscanserving_service, dbscanserving_client: DbscanServingClient +): request: DetectionRequest = DetectionRequest() request.num_samples = 210 @@ -77,25 +99,28 @@ def test_detection_incorrect(dbscanserving_service, dbscanserving_client: Dbscan for _ in range(200): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(0., 10.)) + grpc_sample.features.append(random.uniform(0.0, 10.0)) request.samples.append(grpc_sample) - + for _ in range(100): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(50., 60.)) + grpc_sample.features.append(random.uniform(50.0, 60.0)) request.samples.append(grpc_sample) - + for _ in range(10): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(5000., 6000.)) + grpc_sample.features.append(random.uniform(5000.0, 6000.0)) request.samples.append(grpc_sample) with pytest.raises(Exception): - response: DetectionResponse = dbscanserving_client.Detect(request) + _: DetectionResponse = dbscanserving_client.Detect(request) -def test_detection_clusters(dbscanserving_service, dbscanserving_client: DbscanServingClient): + +def test_detection_clusters( + dbscanserving_service, dbscanserving_client: DbscanServingClient +): request: DetectionRequest = DetectionRequest() request.num_samples = 310 @@ -106,19 +131,19 @@ def test_detection_clusters(dbscanserving_service, dbscanserving_client: DbscanS for _ in range(200): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(0., 10.)) + grpc_sample.features.append(random.uniform(0.0, 10.0)) request.samples.append(grpc_sample) - + for _ in range(100): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(50., 60.)) + grpc_sample.features.append(random.uniform(50.0, 60.0)) request.samples.append(grpc_sample) - + for _ in range(10): grpc_sample = Sample() for __ in range(100): - grpc_sample.features.append(random.uniform(5000., 6000.)) + grpc_sample.features.append(random.uniform(5000.0, 6000.0)) request.samples.append(grpc_sample) response: DetectionResponse = dbscanserving_client.Detect(request) diff --git a/src/opticalattackdetector/.env b/src/opticalattackdetector/.env new file mode 100644 index 0000000000000000000000000000000000000000..3f6429af9c86c4b241dd09c4c63f4a2562866ca0 --- /dev/null +++ b/src/opticalattackdetector/.env @@ -0,0 +1,5 @@ +OPTICALATTACKDETECTORSERVICE_SERVICE_HOST=127.0.0.1 +OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC=10006 +DBSCANSERVINGSERVICE_SERVICE_HOST=127.0.0.1 +DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC=10007 +LOG_LEVEL=DEBUG \ No newline at end of file diff --git a/src/opticalcentralizedattackdetector/.gitlab-ci.yml b/src/opticalattackdetector/.gitlab-ci.yml similarity index 78% rename from src/opticalcentralizedattackdetector/.gitlab-ci.yml rename to src/opticalattackdetector/.gitlab-ci.yml index c3d91aec6e10c7450cfda0b74d0bc3bbe613558b..4d3fd8f29f94986cc809b874fd705ea9e3763668 100644 --- a/src/opticalcentralizedattackdetector/.gitlab-ci.yml +++ b/src/opticalattackdetector/.gitlab-ci.yml @@ -13,15 +13,15 @@ # limitations under the License. # build, tag and push the Docker image to the gitlab registry -build opticalcentralizedattackdetector: +build opticalattackdetector: variables: - IMAGE_NAME: 'opticalcentralizedattackdetector' # name of the microservice + IMAGE_NAME: 'opticalattackdetector' # 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 build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile . - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" after_script: @@ -37,25 +37,25 @@ build opticalcentralizedattackdetector: - manifests/${IMAGE_NAME}service.yaml - .gitlab-ci.yml -# apply unit test to the opticalcentralizedattackdetector component -unit test opticalcentralizedattackdetector: +# apply unit test to the opticalattackdetector component +unit test opticalattackdetector: variables: - IMAGE_NAME: 'opticalcentralizedattackdetector' # name of the microservice + IMAGE_NAME: 'opticalattackdetector' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: unit_test needs: - - build opticalcentralizedattackdetector + - build opticalattackdetector 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 - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - - docker run --name $IMAGE_NAME -d -p 10005:10005 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG + - docker run --name $IMAGE_NAME -d -p 10006:10006 --env-file "$PWD/src/$IMAGE_NAME/.env" -v "$PWD/src/$IMAGE_NAME/tests:/home/${IMAGE_NAME}/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG - sleep 5 - docker ps -a - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" + - docker logs $IMAGE_NAME + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/home/${IMAGE_NAME}/results/${IMAGE_NAME}_report.xml; coverage xml -o /home/${IMAGE_NAME}/results/${IMAGE_NAME}_coverage.xml; coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME @@ -76,14 +76,14 @@ unit test opticalcentralizedattackdetector: junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml -# Deployment of the opticalcentralizedattackdetector service in Kubernetes Cluster -deploy opticalcentralizedattackdetector: +# Deployment of the opticalattackdetector service in Kubernetes Cluster +deploy opticalattackdetector: variables: - IMAGE_NAME: 'opticalcentralizedattackdetector' # name of the microservice + IMAGE_NAME: 'opticalattackdetector' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) stage: deploy needs: - - unit test opticalcentralizedattackdetector + - unit test opticalattackdetector # - integ_test execute script: - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml' diff --git a/src/opticalattackdetector/Config.py b/src/opticalattackdetector/Config.py new file mode 100644 index 0000000000000000000000000000000000000000..1c356766d30f30b47ca99573a7171b824850ae03 --- /dev/null +++ b/src/opticalattackdetector/Config.py @@ -0,0 +1,27 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging + +# General settings +LOG_LEVEL = logging.DEBUG + +# gRPC settings +GRPC_SERVICE_PORT = 10006 + +# service settings +MONITORING_INTERVAL = 10 # monitoring interval in seconds + +# Prometheus settings +METRICS_PORT = 9192 diff --git a/src/opticalattackdetector/Dockerfile b/src/opticalattackdetector/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..80f76a762904d59c904c34fa869d8053bfe0931f --- /dev/null +++ b/src/opticalattackdetector/Dockerfile @@ -0,0 +1,86 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +FROM python:3.9-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 +ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python + +# 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 + +# Creating a user for security reasons +RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow +USER teraflow + +# set working directory +RUN mkdir -p /home/teraflow/controller/common/proto +WORKDIR /home/teraflow/controller + +# Get Python packages per module +ENV VIRTUAL_ENV=/home/teraflow/venv +RUN python3 -m venv ${VIRTUAL_ENV} +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" + +# Get generic Python packages +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade setuptools wheel +RUN python3 -m pip install --upgrade pip-tools + +# Get common Python packages +# Note: this step enables sharing the previous Docker build steps among all the Python components +COPY --chown=teraflow:teraflow common_requirements.in common_requirements.in +RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in +RUN python3 -m pip install -r common_requirements.txt + +# Add common files into working directory +WORKDIR /home/teraflow/controller/common +COPY --chown=teraflow:teraflow src/common/. ./ + +# Create proto sub-folder, copy .proto files, and generate Python code +WORKDIR /home/teraflow/controller/common/proto +RUN touch __init__.py +COPY --chown=teraflow:teraflow proto/*.proto ./ +RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto +RUN rm *.proto +RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; + +# Create module sub-folders +RUN mkdir -p /home/teraflow/controller/opticalattackdetector +WORKDIR /home/teraflow/controller + +# Get Python packages per module +COPY --chown=teraflow:teraflow src/opticalattackdetector/requirements.in opticalattackdetector/requirements.in +# consider common and specific requirements to avoid inconsistencies with dependencies +RUN pip-compile --quiet --output-file=opticalattackdetector/requirements.txt opticalattackdetector/requirements.in common_requirements.in +RUN python3 -m pip install -r opticalattackdetector/requirements.txt + +# Add files into working directory +COPY --chown=teraflow:teraflow src/context/. context +COPY --chown=teraflow:teraflow src/service/. service +COPY --chown=teraflow:teraflow src/monitoring/. monitoring +COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving +COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator +COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector + +# Start opticalattackdetector service +ENTRYPOINT ["python", "-m", "opticalattackdetector.service"] diff --git a/src/dbscanserving/proto/__init__.py b/src/opticalattackdetector/__init__.py similarity index 99% rename from src/dbscanserving/proto/__init__.py rename to src/opticalattackdetector/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/dbscanserving/proto/__init__.py +++ b/src/opticalattackdetector/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackdetector/client/OpticalAttackDetectorClient.py b/src/opticalattackdetector/client/OpticalAttackDetectorClient.py new file mode 100644 index 0000000000000000000000000000000000000000..47308f1a8ba0469a498d5d747ccbaa90f25e32a0 --- /dev/null +++ b/src/opticalattackdetector/client/OpticalAttackDetectorClient.py @@ -0,0 +1,72 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging + +import grpc + +from common.proto.context_pb2 import Empty +from common.proto.optical_attack_detector_pb2_grpc import \ + OpticalAttackDetectorServiceStub +from common.Settings import get_setting +from common.tools.client.RetryDecorator import delay_exponential, retry +from common.tools.grpc.Tools import grpc_message_to_json + +LOGGER = logging.getLogger(__name__) +MAX_RETRIES = 15 +DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) +RETRY_DECORATOR = retry( + max_retries=MAX_RETRIES, + delay_function=DELAY_FUNCTION, + prepare_method_name="connect", +) + + +class OpticalAttackDetectorClient: + def __init__(self, host=None, port=None): + if not host: + host = get_setting( + "OPTICALATTACKDETECTORSERVICE_SERVICE_HOST", default="DBSCANSERVING" + ) + if not port: + port = get_setting( + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC", default=10007 + ) + self.endpoint = "{:s}:{:s}".format(str(host), str(port)) + LOGGER.debug("Creating channel to {:s}...".format(str(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 = OpticalAttackDetectorServiceStub(self.channel) + + def close(self): + if self.channel is not None: + self.channel.close() + self.channel = None + self.stub = None + + @RETRY_DECORATOR + def DetectAttack(self, request: Empty) -> Empty: + LOGGER.debug( + "DetectAttack request: {:s}".format(str(grpc_message_to_json(request))) + ) + response = self.stub.DetectAttack(request) + LOGGER.debug( + "DetectAttack result: {:s}".format(str(grpc_message_to_json(response))) + ) + return response diff --git a/src/opticalcentralizedattackdetector/client/__init__.py b/src/opticalattackdetector/client/__init__.py similarity index 99% rename from src/opticalcentralizedattackdetector/client/__init__.py rename to src/opticalattackdetector/client/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalcentralizedattackdetector/client/__init__.py +++ b/src/opticalattackdetector/client/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackdetector/requirements.in b/src/opticalattackdetector/requirements.in new file mode 100644 index 0000000000000000000000000000000000000000..175421f97c93d7fe1da5efa2c2339b5b4b6ac931 --- /dev/null +++ b/src/opticalattackdetector/requirements.in @@ -0,0 +1,2 @@ +numpy +redis-py \ No newline at end of file diff --git a/src/opticalattackdetector/service/OpticalAttackDetectorService.py b/src/opticalattackdetector/service/OpticalAttackDetectorService.py new file mode 100644 index 0000000000000000000000000000000000000000..c6a141371b6ea2790adfa0ef8488b2cf4fda8249 --- /dev/null +++ b/src/opticalattackdetector/service/OpticalAttackDetectorService.py @@ -0,0 +1,94 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +from concurrent import futures + +import grpc +from grpc_health.v1.health import OVERALL_HEALTH, HealthServicer +from grpc_health.v1.health_pb2 import HealthCheckResponse +from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server + +from common.Constants import (DEFAULT_GRPC_BIND_ADDRESS, + DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.proto.optical_attack_detector_pb2_grpc import \ + add_OpticalAttackDetectorServiceServicer_to_server +from opticalattackdetector.Config import GRPC_SERVICE_PORT +from opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl import \ + OpticalAttackDetectorServiceServicerImpl + +LOGGER = logging.getLogger(__name__) + + +class OpticalAttackDetectorService: + def __init__( + self, + address=DEFAULT_GRPC_BIND_ADDRESS, + port=GRPC_SERVICE_PORT, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + ): + + self.address = address + self.port = port + self.endpoint = None + self.max_workers = max_workers + self.grace_period = grace_period + self.attack_detector_servicer = None + self.health_servicer = None + self.pool = None + self.server = None + + def start(self): + self.endpoint = "{:s}:{:s}".format(str(self.address), str(self.port)) + LOGGER.debug( + "Starting Service (tentative endpoint: {:s}, max_workers: {:s})...".format( + str(self.endpoint), str(self.max_workers) + ) + ) + + self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) + self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) + + self.attack_detector_servicer = OpticalAttackDetectorServiceServicerImpl() + add_OpticalAttackDetectorServiceServicer_to_server( + self.attack_detector_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 = "{:s}:{:s}".format(str(self.address), str(port)) + LOGGER.info("Listening on {:s}...".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 {:s} seconds)...".format( + str(self.grace_period) + ) + ) + self.health_servicer.enter_graceful_shutdown() + self.server.stop(self.grace_period) + LOGGER.debug("Service stopped") diff --git a/src/opticalattackdetector/service/OpticalAttackDetectorServiceServicerImpl.py b/src/opticalattackdetector/service/OpticalAttackDetectorServiceServicerImpl.py new file mode 100644 index 0000000000000000000000000000000000000000..86654e1522c4e06fb6c373f846b2ae5051116487 --- /dev/null +++ b/src/opticalattackdetector/service/OpticalAttackDetectorServiceServicerImpl.py @@ -0,0 +1,228 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import pickle +import random + +import grpc +import numpy as np +import redis + +from common.Constants import ServiceNameEnum +from common.proto import dbscanserving_pb2 as dbscan +from common.proto import optical_attack_detector_pb2 as oad +from common.proto.context_pb2 import Empty +from common.proto.monitoring_pb2 import Kpi +from common.proto.optical_attack_detector_pb2_grpc import \ + OpticalAttackDetectorServiceServicer +from common.proto.optical_attack_mitigator_pb2 import (AttackDescription, + AttackResponse) +from common.rpc_method_wrapper.Decorator import (create_metrics, + get_histogram_duration, + safe_and_metered_rpc_method) +from common.Settings import get_service_host, get_setting +from common.tools.timestamp.Converters import timestamp_utcnow_to_float +from dbscanserving.client.DbscanServingClient import DbscanServingClient +from monitoring.client.MonitoringClient import MonitoringClient +from opticalattackmitigator.client.OpticalAttackMitigatorClient import \ + OpticalAttackMitigatorClient + +LOGGER = logging.getLogger(__name__) + +SERVICE_NAME = "OpticalAttackDetector" +METHOD_NAMES = ["DetectAttack"] +METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) +DETECTION_RESPONSE_TIME = get_histogram_duration( + "ATTACK_DETECTOR_INFERENCE_RESPONSE_TIME" +) +MONITORING_RESPONSE_TIME = get_histogram_duration( + "ATTACK_DETECTOR_MONITORING_RESPONSE_TIME" +) +MITIGATION_RESPONSE_TIME = get_histogram_duration( + "ATTACK_DETECTOR_MITIGATION_RESPONSE_TIME" +) +CACHE_RESPONSE_TIME = get_histogram_duration("ATTACK_DETECTOR_CACHE_RESPONSE_TIME") + +monitoring_client: MonitoringClient = MonitoringClient() +dbscanserving_client: DbscanServingClient = DbscanServingClient() +attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient() + +redis_host = get_service_host(ServiceNameEnum.CACHING) +r = None +if redis_host is not None: + redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS")) + redis_password = get_setting("REDIS_PASSWORD") + + r = redis.Redis(host=redis_host, port=redis_port, password=redis_password) + +# detecting preloading of the stats +path = get_setting("PATH_OPM_INFORMATION_SUMMARY", default=None) +if path is not None and len(path) > 0: + with open(path, "rb") as file: + opm_information_stats = pickle.load(file) + LOGGER.info("Using provided dataset: {}".format(path)) +else: + opm_information_stats = None + +WAD_WINDOW = 20 +WAD_SAMPLES = 9 + + +class OpticalAttackDetectorServiceServicerImpl(OpticalAttackDetectorServiceServicer): + def __init__(self): + LOGGER.debug("Creating Servicer...") + LOGGER.debug("Servicer Created") + + @safe_and_metered_rpc_method(METRICS, LOGGER) + def DetectAttack( + self, request: oad.DetectionRequest, context: grpc.ServicerContext + ) -> Empty: + + s_uuid = request.service_id.service_uuid.uuid + + # detect if specific configuration is required + # to set the variable on the fly, try: + # https://stackoverflow.com/questions/45050050/can-i-modify-containers-environment-variables-without-restarting-pod-using-kube + _temp = r.get("CLASS_SERVICE_{}".format(s_uuid.replace("-", "_"))) + if _temp is not None and len(_temp) > 0: + _class = int(_temp) + else: # if not, assume no attack is present + _class = 0 + LOGGER.debug("Using class {} for service {}".format(_class, s_uuid)) + + _temp = r.get("PREVIOUS_CLASS_SERVICE_{}".format(s_uuid.replace("-", "_"))) + if _temp is not None and int(_temp) != 0 and _class == 0: + # if value changed to no-attack + # reset the experiment + r.delete("opm_{}".format(s_uuid.replace("-", "_"))) + r.set("PREVIOUS_CLASS_SERVICE_{}".format(s_uuid.replace("-", "_")), _class) + + # code used to validate resiliency against failures and timeouts + # if random.random() > 0.5: + # time.sleep(10) + + # run attack detection for every service + detection_request: dbscan.DetectionRequest = dbscan.DetectionRequest() + detection_request.num_samples = 310 + detection_request.num_features = 11 + + # checking if we have enough samples already for this service + length = r.llen("opm_{}".format(s_uuid.replace("-", "_"))) + if length < detection_request.num_samples: + # if the number of samples is not sufficient, + # we insert new samples + for _ in range(detection_request.num_samples - length): + detection_sample = [] + if opm_information_stats is not None: + for col in range(1, len(opm_information_stats.columns), 2): + name = opm_information_stats.columns[col][0] + # [result.columns[x][0] for x in range(1, len(result.columns), 2)] + detection_sample.append( + np.random.normal( + loc=opm_information_stats[name]["mean"][_class], + scale=opm_information_stats[name]["std"][_class], + ) + ) + else: + for __ in range(detection_request.num_features): + detection_sample.append(random.uniform(0.0, 10.0)) + # push the sample into the list + r.rpush( + "opm_{}".format(s_uuid.replace("-", "_")), + pickle.dumps(tuple(detection_sample)), + ) + + # remove the oldest sample from the list + r.lpop("opm_{}".format(s_uuid.replace("-", "_"))) + + # generate the latest sample + detection_sample = [] + if opm_information_stats is not None: + + for col in range(1, len(opm_information_stats.columns), 2): + name = opm_information_stats.columns[col][0] + # [result.columns[x][0] for x in range(1, len(result.columns), 2)] + detection_sample.append( + np.random.normal( + loc=opm_information_stats[name]["mean"][_class], + scale=opm_information_stats[name]["std"][_class], + ) + ) + + # generate data based on the stats based on the configuration of + # https://dx.doi.org/10.1109/JLT.2020.2987032 + detection_request.eps = 1.0 + detection_request.min_samples = 5 + else: + detection_request.eps = 100.5 + detection_request.min_samples = 5 + + if _class == 0: + for __ in range(detection_request.num_features): + detection_sample.append(random.uniform(0.0, 10.0)) + else: # if not, assume no attack is present + for __ in range(detection_request.num_features): + detection_sample.append(random.uniform(5000.0, 6000.0)) + + # adding the sample to the cache and recovering the cache + with CACHE_RESPONSE_TIME.time(): + r.rpush( + "opm_{}".format(s_uuid.replace("-", "_")), + pickle.dumps(tuple(detection_sample)), + ) + cached_samples = r.lrange("opm_{}".format(s_uuid.replace("-", "_")), 0, -1) + LOGGER.info( + "Recovered {} samples from the cache".format(len(cached_samples)) + ) + + for raw_sample in cached_samples: + sample = pickle.loads(raw_sample) + detection_sample = dbscan.Sample() + for feature in sample: + detection_sample.features.append(feature) + detection_request.samples.append(detection_sample) + + with DETECTION_RESPONSE_TIME.time(): + response: dbscan.DetectionResponse = dbscanserving_client.Detect( + detection_request + ) + + # including KPI + kpi = Kpi() + kpi.kpi_id.kpi_id.uuid = request.kpi_id.kpi_id.uuid + kpi.timestamp.timestamp = timestamp_utcnow_to_float() + # implementing WAD from https://ieeexplore.ieee.org/abstract/document/9064530 + if response.cluster_indices[-WAD_WINDOW:].count(-1) >= WAD_SAMPLES: + kpi.kpi_value.int32Val = 1 + LOGGER.info( + "Attack detected for service {}".format( + request.service_id.service_uuid.uuid + ) + ) + else: + kpi.kpi_value.int32Val = 0 + + with MONITORING_RESPONSE_TIME.time(): + monitoring_client.IncludeKpi(kpi) + + # if -1 in response.cluster_indices: # attack detected + if kpi.kpi_value.int32Val == -1: + attack = AttackDescription() + attack.cs_id.uuid = request.service_id.service_uuid.uuid + with MITIGATION_RESPONSE_TIME.time(): + response: AttackResponse = attack_mitigator_client.NotifyAttack(attack) + + # if attack is detected, run the attack mitigator + return Empty() diff --git a/src/opticalattackmitigator/proto/__init__.py b/src/opticalattackdetector/service/__init__.py similarity index 99% rename from src/opticalattackmitigator/proto/__init__.py rename to src/opticalattackdetector/service/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalattackmitigator/proto/__init__.py +++ b/src/opticalattackdetector/service/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackdetector/service/__main__.py b/src/opticalattackdetector/service/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..028f576e2ffae2dd4a83f12fba260cb418f3ed54 --- /dev/null +++ b/src/opticalattackdetector/service/__main__.py @@ -0,0 +1,105 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import signal +import sys +import threading + +from prometheus_client import start_http_server + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS, ServiceNameEnum) +from common.Settings import (ENVVAR_SUFIX_SERVICE_HOST, + ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, + get_log_level, get_metrics_port, get_setting, + wait_for_environment_variables) +from opticalattackdetector.client.OpticalAttackDetectorClient import \ + OpticalAttackDetectorClient +from opticalattackdetector.Config import GRPC_SERVICE_PORT +from opticalattackdetector.service.OpticalAttackDetectorService import \ + OpticalAttackDetectorService + +terminate = threading.Event() +LOGGER = None + +client: OpticalAttackDetectorClient = None + + +def signal_handler(signal, frame): # pylint: disable=redefined-outer-name + LOGGER.warning("Terminate signal received") + terminate.set() + + +def main(): + global LOGGER # pylint: disable=global-statement + + log_level = get_log_level() + logging.basicConfig(level=log_level) + LOGGER = logging.getLogger(__name__) + + wait_for_environment_variables( + [ + get_env_var_name(ServiceNameEnum.DBSCANSERVING, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name( + ServiceNameEnum.DBSCANSERVING, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + ] + ) + + wait_for_environment_variables( + [ + get_env_var_name( + ServiceNameEnum.OPTICALATTACKMITIGATOR, ENVVAR_SUFIX_SERVICE_HOST + ), + get_env_var_name( + ServiceNameEnum.OPTICALATTACKMITIGATOR, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + ] + ) + + service_port = get_setting( + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC", default=GRPC_SERVICE_PORT + ) + max_workers = get_setting("MAX_WORKERS", default=DEFAULT_GRPC_MAX_WORKERS) + grace_period = get_setting("GRACE_PERIOD", default=DEFAULT_GRPC_GRACE_PERIOD) + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) + + LOGGER.info("Starting...") + + # Start metrics server + metrics_port = get_metrics_port() + start_http_server(metrics_port) # TODO: make sure this is uncommented + + # Starting CentralizedCybersecurity service + grpc_service = OpticalAttackDetectorService( + port=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/opticalcentralizedattackdetector/__init__.py b/src/opticalattackdetector/tests/__init__.py similarity index 99% rename from src/opticalcentralizedattackdetector/__init__.py rename to src/opticalattackdetector/tests/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalcentralizedattackdetector/__init__.py +++ b/src/opticalattackdetector/tests/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackdetector/tests/example_objects.py b/src/opticalattackdetector/tests/example_objects.py new file mode 100644 index 0000000000000000000000000000000000000000..6ce094db8f830f5052b2d64bf42af0567781f5a6 --- /dev/null +++ b/src/opticalattackdetector/tests/example_objects.py @@ -0,0 +1,247 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +from copy import deepcopy + +from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID +from common.proto.context_pb2 import (ConfigActionEnum, DeviceDriverEnum, + DeviceOperationalStatusEnum, + ServiceStatusEnum, ServiceTypeEnum) + +# Some example objects to be used by the tests + +# Helper methods +def config_rule(action, resource_value): + return {"action": action, "resource_value": resource_value} + + +def endpoint_id(topology_id, device_id, endpoint_uuid): + return { + "topology_id": deepcopy(topology_id), + "device_id": deepcopy(device_id), + "endpoint_uuid": {"uuid": endpoint_uuid}, + } + + +def endpoint(topology_id, device_id, endpoint_uuid, endpoint_type): + return { + "endpoint_id": endpoint_id(topology_id, device_id, endpoint_uuid), + "endpoint_type": endpoint_type, + } + + +# use "deepcopy" to prevent propagating forced changes during tests +CONTEXT_ID = {"context_uuid": {"uuid": DEFAULT_CONTEXT_UUID}} +CONTEXT = { + "context_id": deepcopy(CONTEXT_ID), + "topology_ids": [], + "service_ids": [], +} + +CONTEXT_ID_2 = {"context_uuid": {"uuid": "test"}} +CONTEXT_2 = { + "context_id": deepcopy(CONTEXT_ID_2), + "topology_ids": [], + "service_ids": [], +} + +TOPOLOGY_ID = { + "context_id": deepcopy(CONTEXT_ID), + "topology_uuid": {"uuid": DEFAULT_TOPOLOGY_UUID}, +} +TOPOLOGY = { + "topology_id": deepcopy(TOPOLOGY_ID), + "device_ids": [], + "link_ids": [], +} + +DEVICE1_UUID = "DEV1" +DEVICE1_ID = {"device_uuid": {"uuid": DEVICE1_UUID}} +DEVICE1 = { + "device_id": deepcopy(DEVICE1_ID), + "device_type": "packet-router", + "device_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "value1"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "value2"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "value3"), + ] + }, + "device_operational_status": DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, + "device_drivers": [ + DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, + DeviceDriverEnum.DEVICEDRIVER_P4, + ], + "device_endpoints": [ + endpoint(TOPOLOGY_ID, DEVICE1_ID, "EP2", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE1_ID, "EP3", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE1_ID, "EP100", "port-packet-10G"), + ], +} + +DEVICE2_UUID = "DEV2" +DEVICE2_ID = {"device_uuid": {"uuid": DEVICE2_UUID}} +DEVICE2 = { + "device_id": deepcopy(DEVICE2_ID), + "device_type": "packet-router", + "device_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc1/value", "value4"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc2/value", "value5"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc3/value", "value6"), + ] + }, + "device_operational_status": DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, + "device_drivers": [ + DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, + DeviceDriverEnum.DEVICEDRIVER_P4, + ], + "device_endpoints": [ + endpoint(TOPOLOGY_ID, DEVICE2_ID, "EP1", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE2_ID, "EP3", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE2_ID, "EP100", "port-packet-10G"), + ], +} + +DEVICE3_UUID = "DEV3" +DEVICE3_ID = {"device_uuid": {"uuid": DEVICE3_UUID}} +DEVICE3 = { + "device_id": deepcopy(DEVICE3_ID), + "device_type": "packet-router", + "device_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc1/value", "value4"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc2/value", "value5"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "dev/rsrc3/value", "value6"), + ] + }, + "device_operational_status": DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, + "device_drivers": [ + DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, + DeviceDriverEnum.DEVICEDRIVER_P4, + ], + "device_endpoints": [ + endpoint(TOPOLOGY_ID, DEVICE3_ID, "EP1", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE3_ID, "EP2", "port-packet-100G"), + endpoint(TOPOLOGY_ID, DEVICE3_ID, "EP100", "port-packet-10G"), + ], +} + +LINK_DEV1_DEV2_UUID = "DEV1/EP2 ==> DEV2/EP1" +LINK_DEV1_DEV2_ID = {"link_uuid": {"uuid": LINK_DEV1_DEV2_UUID}} +LINK_DEV1_DEV2 = { + "link_id": deepcopy(LINK_DEV1_DEV2_ID), + "link_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE1_ID, "EP2"), + endpoint_id(TOPOLOGY_ID, DEVICE2_ID, "EP1"), + ], +} + +LINK_DEV2_DEV3_UUID = "DEV2/EP3 ==> DEV3/EP2" +LINK_DEV2_DEV3_ID = {"link_uuid": {"uuid": LINK_DEV2_DEV3_UUID}} +LINK_DEV2_DEV3 = { + "link_id": deepcopy(LINK_DEV2_DEV3_ID), + "link_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE2_ID, "EP3"), + endpoint_id(TOPOLOGY_ID, DEVICE3_ID, "EP2"), + ], +} + +LINK_DEV1_DEV3_UUID = "DEV1/EP3 ==> DEV3/EP1" +LINK_DEV1_DEV3_ID = {"link_uuid": {"uuid": LINK_DEV1_DEV3_UUID}} +LINK_DEV1_DEV3 = { + "link_id": deepcopy(LINK_DEV1_DEV3_ID), + "link_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE1_ID, "EP3"), + endpoint_id(TOPOLOGY_ID, DEVICE3_ID, "EP1"), + ], +} + +SERVICE_DEV1_DEV2_UUID = "SVC:DEV1/EP100-DEV2/EP100" +SERVICE_DEV1_DEV2_ID = { + "context_id": deepcopy(CONTEXT_ID), + "service_uuid": {"uuid": SERVICE_DEV1_DEV2_UUID}, +} +SERVICE_DEV1_DEV2 = { + "service_id": deepcopy(SERVICE_DEV1_DEV2_ID), + "service_type": ServiceTypeEnum.SERVICETYPE_L3NM, + "service_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE1_ID, "EP100"), + endpoint_id(TOPOLOGY_ID, DEVICE2_ID, "EP100"), + ], + # 'service_constraints': [ + # {'constraint_type': 'latency_ms', 'constraint_value': '15.2'}, + # {'constraint_type': 'jitter_us', 'constraint_value': '1.2'}, + # ], + "service_status": {"service_status": ServiceStatusEnum.SERVICESTATUS_ACTIVE}, + "service_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc1/value", "value7"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc2/value", "value8"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc3/value", "value9"), + ] + }, +} + +SERVICE_DEV1_DEV3_UUID = "SVC:DEV1/EP100-DEV3/EP100" +SERVICE_DEV1_DEV3_ID = { + "context_id": deepcopy(CONTEXT_ID), + "service_uuid": {"uuid": SERVICE_DEV1_DEV3_UUID}, +} +SERVICE_DEV1_DEV3 = { + "service_id": deepcopy(SERVICE_DEV1_DEV3_ID), + "service_type": ServiceTypeEnum.SERVICETYPE_L3NM, + "service_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE1_ID, "EP100"), + endpoint_id(TOPOLOGY_ID, DEVICE3_ID, "EP100"), + ], + # 'service_constraints': [ + # {'constraint_type': 'latency_ms', 'constraint_value': '5.8'}, + # {'constraint_type': 'jitter_us', 'constraint_value': '0.1'}, + # ], + "service_status": {"service_status": ServiceStatusEnum.SERVICESTATUS_ACTIVE}, + "service_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc1/value", "value7"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc2/value", "value8"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc3/value", "value9"), + ] + }, +} + +SERVICE_DEV2_DEV3_UUID = "SVC:DEV2/EP100-DEV3/EP100" +SERVICE_DEV2_DEV3_ID = { + "context_id": deepcopy(CONTEXT_ID), + "service_uuid": {"uuid": SERVICE_DEV2_DEV3_UUID}, +} +SERVICE_DEV2_DEV3 = { + "service_id": deepcopy(SERVICE_DEV2_DEV3_ID), + "service_type": ServiceTypeEnum.SERVICETYPE_L3NM, + "service_endpoint_ids": [ + endpoint_id(TOPOLOGY_ID, DEVICE2_ID, "EP100"), + endpoint_id(TOPOLOGY_ID, DEVICE3_ID, "EP100"), + ], + # 'service_constraints': [ + # {'constraint_type': 'latency_ms', 'constraint_value': '23.1'}, + # {'constraint_type': 'jitter_us', 'constraint_value': '3.4'}, + # ], + "service_status": {"service_status": ServiceStatusEnum.SERVICESTATUS_ACTIVE}, + "service_config": { + "config_rules": [ + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc1/value", "value7"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc2/value", "value8"), + config_rule(ConfigActionEnum.CONFIGACTION_SET, "svc/rsrc3/value", "value9"), + ] + }, +} diff --git a/src/opticalattackdetector/tests/test_unitary.py b/src/opticalattackdetector/tests/test_unitary.py new file mode 100644 index 0000000000000000000000000000000000000000..55b6ebaf02d82f312a5d73666ed332fa795bae96 --- /dev/null +++ b/src/opticalattackdetector/tests/test_unitary.py @@ -0,0 +1,275 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import os +from unittest.mock import patch + +import pytest + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.proto import dbscanserving_pb2 as dbscan +from common.proto.optical_attack_detector_pb2 import DetectionRequest +from opticalattackdetector.client.OpticalAttackDetectorClient import \ + OpticalAttackDetectorClient +from opticalattackdetector.Config import GRPC_SERVICE_PORT +from opticalattackdetector.service.OpticalAttackDetectorService import \ + OpticalAttackDetectorService + +# from .example_objects import CONTEXT_ID, CONTEXT_ID_2, SERVICE_DEV1_DEV2 + +port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +@pytest.fixture(scope="session") +def optical_attack_detector_service(): + with patch.dict( + os.environ, + { + "OPTICALATTACKDETECTORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC": str(port), + "DBSCANSERVINGSERVICE_SERVICE_HOST": "127.0.0.1", + "DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC": str(port), + }, + clear=True, + ): + _service = OpticalAttackDetectorService( + port=port, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + ) + # mocker_context_client = mock.patch('opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client') + # mocker_context_client.start() + + # mocker_influx_db = mock.patch('opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client') + # mocker_influx_db.start() + + _service.start() + yield _service + _service.stop() + # mocker_context_client.stop() + # mocker_influx_db.stop() + + +@pytest.fixture(scope="session") +def optical_attack_detector_client(optical_attack_detector_service): + with patch.dict( + os.environ, + { + "OPTICALATTACKDETECTORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC": str(port), + "DBSCANSERVINGSERVICE_SERVICE_HOST": "127.0.0.1", + "DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC": str(port), + }, + clear=True, + ): + _client = OpticalAttackDetectorClient() + yield _client + _client.close() + + +def test_detect_attack( + optical_attack_detector_client: OpticalAttackDetectorClient, +): + message = dbscan.DetectionResponse() + message.cluster_indices.extend([0, 1, -1, -1, -1]) + with patch( + "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.attack_mitigator_client" + ) as mitigator, patch( + "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.monitoring_client" + ) as monitoring, patch( + "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.dbscanserving_client.Detect", + # TODO: return dumb object with "cluster_indices" attribute + # idea: create new response object + return_value=message, + ) as dbscanserving: + request: DetectionRequest = DetectionRequest() + request.service_id.context_id.context_uuid.uuid = "" + request.service_id.service_uuid.uuid = str("") + request.kpi_id.kpi_id.uuid = "" + optical_attack_detector_client.DetectAttack(request) + mitigator.NotifyAttack.assert_called_once() + monitoring.IncludeKpi.assert_called_once() + dbscanserving.assert_called_once() + + +# def test_detect_attack_with_context( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# with patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client" +# ) as context, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client" +# ) as influxdb: +# # setting up the mock +# cid_list = ContextIdList() +# cid_list.context_ids.append(ContextId(**CONTEXT_ID)) +# context.ListContextIds.return_value = cid_list + +# # making the test +# request = Empty() +# optical_attack_detector_client.DetectAttack(request) + +# # checking behavior +# context.ListContextIds.assert_called_once() +# context.ListServices.assert_called_with(cid_list.context_ids[0]) +# influxdb.query.assert_called_once() + + +# def test_detect_attack_with_contexts( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# with patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client" +# ) as context, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client" +# ) as influxdb: +# # setting up the mock +# cid_list = ContextIdList() +# cid_list.context_ids.append(ContextId(**CONTEXT_ID)) +# cid_list.context_ids.append(ContextId(**CONTEXT_ID_2)) +# context.ListContextIds.return_value = cid_list + +# # making the test +# request = Empty() +# optical_attack_detector_client.DetectAttack(request) + +# # checking behavior +# context.ListContextIds.assert_called_once() +# context.ListServices.assert_any_call(cid_list.context_ids[0]) +# context.ListServices.assert_any_call(cid_list.context_ids[1]) +# influxdb.query.assert_called_once() + + +# def test_detect_attack_with_service( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# with patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client" +# ) as context, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client" +# ) as influxdb, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.dbscanserving_client" +# ) as dbscan: + +# # setting up the mock +# cid_list = ContextIdList() +# cid_list.context_ids.append(ContextId(**CONTEXT_ID)) +# context.ListContextIds.return_value = cid_list + +# service_list = ServiceList() +# service_list.services.append(Service(**SERVICE_DEV1_DEV2)) +# context.ListServices.return_value = service_list + +# influxdb.query.return_value.get_points.return_value = [(1, 2), (3, 4)] + +# # making the test +# request = Empty() +# optical_attack_detector_client.DetectAttack(request) + +# # checking behavior +# context.ListContextIds.assert_called_once() +# context.ListServices.assert_called_with(cid_list.context_ids[0]) +# influxdb.query.assert_called_once() +# dbscan.Detect.assert_called() + + +# def test_detect_attack_no_attack( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# with patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client" +# ) as context, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client" +# ) as influxdb, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.dbscanserving_client" +# ) as dbscan, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.attack_mitigator_client" +# ) as mitigator: + +# # setting up the mock +# cid_list = ContextIdList() +# cid_list.context_ids.append(ContextId(**CONTEXT_ID)) +# context.ListContextIds.return_value = cid_list + +# service_list = ServiceList() +# service_list.services.append(Service(**SERVICE_DEV1_DEV2)) +# context.ListServices.return_value = service_list + +# # dbscan.Detect.return_value = object() +# dbscan.Detect.return_value.cluster_indices = [0, 1, 2, 3, 4, 5] + +# # making the test +# request = Empty() +# optical_attack_detector_client.DetectAttack(request) + +# # checking behavior +# context.ListContextIds.assert_called_once() +# context.ListServices.assert_called_with(cid_list.context_ids[0]) +# influxdb.query.assert_called_once() +# dbscan.Detect.assert_called() +# mitigator.NotifyAttack.assert_not_called() + + +# def test_detect_attack_with_attack( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# with patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client" +# ) as context, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client" +# ) as influxdb, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.dbscanserving_client" +# ) as dbscan, patch( +# "opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.attack_mitigator_client" +# ) as mitigator: + +# # setting up the mock +# cid_list = ContextIdList() +# cid_list.context_ids.append(ContextId(**CONTEXT_ID)) +# context.ListContextIds.return_value = cid_list + +# service_list = ServiceList() +# service_list.services.append(Service(**SERVICE_DEV1_DEV2)) +# context.ListServices.return_value = service_list + +# # dbscan.Detect.return_value = object() +# dbscan.Detect.return_value.cluster_indices = [0, 1, 2, 3, 4, -1] + +# # making the test +# request = Empty() +# optical_attack_detector_client.DetectAttack(request) + +# # checking behavior +# context.ListContextIds.assert_called_once() +# context.ListServices.assert_called_with(cid_list.context_ids[0]) +# influxdb.query.assert_called_once() +# dbscan.Detect.assert_called() +# mitigator.NotifyAttack.assert_called() + + +# def test_report_summarized_kpi( +# optical_attack_detector_client: OpticalAttackDetectorClient, +# ): +# kpi_list = KpiList() +# optical_attack_detector_client.ReportSummarizedKpi(kpi_list) + + +# def test_report_kpi(optical_attack_detector_client: OpticalAttackDetectorClient): +# kpi_list = KpiList() +# optical_attack_detector_client.ReportKpi(kpi_list) diff --git a/src/opticalattackmanager/.gitlab-ci.yml b/src/opticalattackmanager/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..06aa9eb92defa77c46a92f339b6a07fff2d7b984 --- /dev/null +++ b/src/opticalattackmanager/.gitlab-ci.yml @@ -0,0 +1,105 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +# Build, tag, and push the Docker image to the GitLab Docker registry +build opticalattackmanager: + variables: + IMAGE_NAME: 'opticalattackmanager' # 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 . + - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + after_script: + - docker images --filter="dangling=true" --quiet | xargs -r docker rmi + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + - changes: + - src/common/**/*.py + - proto/*.proto + - src/$IMAGE_NAME/**/*.{py,in,yml} + - src/$IMAGE_NAME/Dockerfile + - src/$IMAGE_NAME/tests/*.py + - manifests/${IMAGE_NAME}service.yaml + - .gitlab-ci.yml + +# Apply unit test to the component +unit test opticalattackmanager: + variables: + IMAGE_NAME: 'opticalattackmanager' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: unit_test + needs: + - build opticalattackmanager + 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 + - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi + script: + - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - docker run --name $IMAGE_NAME -d -p 10005:10005 -v "$PWD/src/$IMAGE_NAME/tests:/home/teraflow/$IMAGE_NAME/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG + - docker ps -a + - docker logs $IMAGE_NAME + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/home/teraflow/$IMAGE_NAME/results/${IMAGE_NAME}_report.xml" + - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" + coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' + after_script: + - docker rm -f $IMAGE_NAME + - docker network rm teraflowbridge + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + - changes: + - src/common/**/*.py + - proto/*.proto + - src/$IMAGE_NAME/**/*.{py,in,yml} + - src/$IMAGE_NAME/Dockerfile + - src/$IMAGE_NAME/tests/*.py + - src/$IMAGE_NAME/tests/Dockerfile + - manifests/${IMAGE_NAME}service.yaml + - .gitlab-ci.yml + artifacts: + when: always + reports: + junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml + +# Deployment of the service in Kubernetes Cluster +deploy opticalattackmanager: + variables: + IMAGE_NAME: 'opticalattackmanager' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: deploy + needs: + - unit test opticalattackmanager + # - integ_test execute + script: + - 'sed -i "s/$IMAGE_NAME:.*/$IMAGE_NAME:$IMAGE_TAG/" manifests/${IMAGE_NAME}service.yaml' + - kubectl version + - kubectl get all + - kubectl apply -f "manifests/${IMAGE_NAME}service.yaml" + - kubectl get all + # environment: + # name: test + # url: https://example.com + # kubernetes: + # namespace: test + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + when: manual + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + when: manual diff --git a/src/opticalattackmanager/Config.py b/src/opticalattackmanager/Config.py new file mode 100644 index 0000000000000000000000000000000000000000..a3222dc475732687849962784d25deedb0d75544 --- /dev/null +++ b/src/opticalattackmanager/Config.py @@ -0,0 +1,24 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging + +# General settings +LOG_LEVEL = logging.DEBUG + +# service settings +MONITORING_INTERVAL = 10 # monitoring interval in seconds + +# Prometheus settings +METRICS_PORT = 9192 diff --git a/src/opticalattackmanager/Dockerfile b/src/opticalattackmanager/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc9a12f0a54a66d25774a65702e1dce1cd00efba --- /dev/null +++ b/src/opticalattackmanager/Dockerfile @@ -0,0 +1,93 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +FROM python:3.9-slim + +# Install dependencies +RUN apt-get --yes --quiet --quiet update && \ + apt-get --yes --quiet --quiet install wget g++ nano && \ + rm -rf /var/lib/apt/lists/* + +# TODO: remove nano from installation + +# Set Python to show logs as they occur +ENV PYTHONUNBUFFERED=0 +ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python + +# 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 + +# Creating a user for security reasons +RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow +USER teraflow + +# set working directory +RUN mkdir -p /home/teraflow/controller/common/proto +WORKDIR /home/teraflow/controller + +# Get Python packages per module +ENV VIRTUAL_ENV=/home/teraflow/venv +RUN python3 -m venv ${VIRTUAL_ENV} +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" + +# Get generic Python packages +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade setuptools wheel +RUN python3 -m pip install --upgrade pip-tools + +# Get common Python packages +# Note: this step enables sharing the previous Docker build steps among all the Python components +COPY --chown=teraflow:teraflow common_requirements.in common_requirements.in +COPY --chown=teraflow:teraflow src/opticalattackmanager/requirements.in opticalattackmanager/requirements.in +RUN sed -i '/protobuf/d' common_requirements.in && sed -i '/grpc/d' common_requirements.in +RUN pip-compile --output-file=common_requirements.txt common_requirements.in opticalattackmanager/requirements.in +RUN python3 -m pip install -r common_requirements.txt + +# Get Python packages per module +# COPY --chown=opticalattackmanager:opticalattackmanager src/opticalattackmanager/requirements.in opticalattackmanager/requirements.in +# RUN pip-compile --quiet --output-file=opticalattackmanager/requirements.txt opticalattackmanager/requirements.in +# RUN python3 -m pip install -r opticalattackmanager/requirements.txt + +# Add common files into working directory +WORKDIR /home/teraflow/controller/common +COPY --chown=teraflow:teraflow src/common/. ./ + +# Create proto sub-folder, copy .proto files, and generate Python code +RUN mkdir -p /home/teraflow/controller/common/proto/asyncio +WORKDIR /home/teraflow/controller/common/proto +RUN touch __init__.py +RUN touch asyncio/__init__.py +COPY --chown=teraflow:teraflow proto/*.proto ./ +RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto +# new line added to generate protobuf for the `grpclib` library +RUN python3 -m grpc_tools.protoc -I=./ --python_out=./asyncio --grpclib_python_out=./asyncio *.proto +RUN rm *.proto +RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; + +# Create module sub-folders +RUN mkdir -p /home/teraflow/controller/opticalattackmanager +WORKDIR /home/teraflow/controller + +# Add files into working directory +COPY --chown=teraflow:teraflow src/context/. context +COPY --chown=teraflow:teraflow src/monitoring/. monitoring +COPY --chown=teraflow:teraflow src/dbscanserving/. dbscanserving +COPY --chown=teraflow:teraflow src/opticalattackdetector/. opticalattackdetector +COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator +COPY --chown=teraflow:teraflow src/opticalattackmanager/. opticalattackmanager + +# Start opticalattackmanager service +ENTRYPOINT ["python", "-m", "opticalattackmanager.service"] diff --git a/src/opticalattackmanager/__init__.py b/src/opticalattackmanager/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9953c820575d42fa88351cc8de022d880ba96e6a --- /dev/null +++ b/src/opticalattackmanager/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. diff --git a/src/opticalattackmanager/requirements.in b/src/opticalattackmanager/requirements.in new file mode 100644 index 0000000000000000000000000000000000000000..df571bf0e94cde29e9f2499d9c5f2bec05822e93 --- /dev/null +++ b/src/opticalattackmanager/requirements.in @@ -0,0 +1,5 @@ +grpcio==1.49.* +grpcio-health-checking==1.49.* +grpcio-tools==1.49.* +grpclib[protobuf] +redis-py \ No newline at end of file diff --git a/src/opticalattackmanager/service/__init__.py b/src/opticalattackmanager/service/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9953c820575d42fa88351cc8de022d880ba96e6a --- /dev/null +++ b/src/opticalattackmanager/service/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. diff --git a/src/opticalattackmanager/service/__main__.py b/src/opticalattackmanager/service/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..8a05ca51798531108edebf32d0c1487713926fea --- /dev/null +++ b/src/opticalattackmanager/service/__main__.py @@ -0,0 +1,404 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import asyncio +import logging +import pickle +import signal +import sys +import threading +import time +from multiprocessing import Manager, Process +from typing import Dict, List + +import redis +from grpclib.client import Channel +from prometheus_client import Counter, Gauge, Histogram, start_http_server + +from common.Constants import ServiceNameEnum +from common.proto.context_pb2 import (ContextIdList, Empty, EventTypeEnum, + Service, ServiceIdList, ServiceTypeEnum) +from common.proto.kpi_sample_types_pb2 import KpiSampleType +from common.proto.monitoring_pb2 import KpiDescriptor +from common.Settings import (ENVVAR_SUFIX_SERVICE_HOST, + ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, + get_log_level, get_metrics_port, get_service_host, + get_setting, wait_for_environment_variables) +from common.tools.grpc.Tools import grpc_message_to_json_string +from context.client.ContextClient import ContextClient +from monitoring.client.MonitoringClient import MonitoringClient +from opticalattackmanager.Config import MONITORING_INTERVAL +from opticalattackmanager.utils.EventsCollector import EventsCollector +from opticalattackmanager.utils.monitor import detect_attack + +terminate = threading.Event() +LOGGER = None + +# SERVICE_LIST_MODE: +# 1 => use Redis +LIST_REDIS_MODE = 1 +# 2 => use shared list +LIST_SHARED_MODE = 2 +SERVICE_LIST_MODE = int( + get_setting("OPTICALATTACKMANAGER_SERVICE_LIST_MODE", default=1) +) +SERVICE_LIST_KEY = get_setting( + "OPTICALATTACKMANAGER_SERVICE_LIST_KEY", default="opt-sec:active-services" +) + +# Create a metric to track time spent and requests made. +# TODO: adjust histogram buckets to more realistic values +LOOP_TIME = Histogram( + "optical_security_loop_seconds", "Time taken by each security loop" +) + +CURRENT_SERVICES = Gauge( + "optical_security_active_services", + "Active optical services currently in the network", +) + +global service_list +global cache + + +def append_service( + info: Dict[str, str], service_list: List = None, cache: redis.Redis = None +) -> None: + if SERVICE_LIST_MODE == LIST_REDIS_MODE: + cache.lpush(SERVICE_LIST_KEY, pickle.dumps(info)) + elif SERVICE_LIST_MODE == LIST_SHARED_MODE: + service_list.append(info) + + +def delete_service( + info: Dict[str, str], service_list: List = None, cache: redis.Redis = None +) -> None: + # here we need to test if the service exists in the list because it has been + # already deleted and there is not way of knowing if it is optical or not + if SERVICE_LIST_MODE == LIST_REDIS_MODE: + service_list = cache.lrange(SERVICE_LIST_KEY, 0, -1) + for encoded in service_list: + service = pickle.loads(encoded) + if ( + service["service"] == info["service"] + and service["context"] == info["context"] + ): + cache.lrem(SERVICE_LIST_KEY, 1, encoded) + break + elif SERVICE_LIST_MODE == LIST_SHARED_MODE: + # find service and remove it from the list of currently monitored + for service in service_list: + if ( + service["service"] == info["service"] + and service["context"] == info["context"] + ): + service_list.remove(service) + break + + +def signal_handler(signal, frame): # pylint: disable=redefined-outer-name + LOGGER.warning("Terminate signal received") + terminate.set() + + +def create_kpi(client: MonitoringClient, service_id): + # create kpi + kpi_description: KpiDescriptor = KpiDescriptor() + kpi_description.kpi_description = "Security status of service {}".format(service_id) + kpi_description.service_id.service_uuid.uuid = service_id + kpi_description.kpi_sample_type = KpiSampleType.KPISAMPLETYPE_UNKNOWN + new_kpi = client.SetKpi(kpi_description) + LOGGER.debug("Created KPI {}: ".format(grpc_message_to_json_string(new_kpi))) + return new_kpi + + +def get_context_updates(terminate, service_list, cache): + # to make sure we are thread safe... + LOGGER.info("Connecting with context and monitoring components...") + context_client: ContextClient = ContextClient() + monitoring_client: MonitoringClient = MonitoringClient() + + events_collector: EventsCollector = EventsCollector(context_client) + events_collector.start() + + LOGGER.info("Connected with components successfully... Waiting for events...") + + time.sleep(20) + + while not terminate.wait(timeout=1): + event = events_collector.get_event(block=True, timeout=1) + if event is None: + LOGGER.debug("No event received") + continue # no event received + LOGGER.debug("Event received: {}".format(grpc_message_to_json_string(event))) + if event.event.event_type == EventTypeEnum.EVENTTYPE_CREATE: + service: Service = context_client.GetService(event.service_id) + # only add if service is of type TAPI + if ( + service.service_type + == ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE + ): + LOGGER.info( + "Service created: {}".format( + grpc_message_to_json_string(event.service_id) + ) + ) + kpi_id = create_kpi( + monitoring_client, event.service_id.service_uuid.uuid + ) + + append_service( + { + "context": event.service_id.context_id.context_uuid.uuid, + "service": event.service_id.service_uuid.uuid, + "kpi": kpi_id.kpi_id.uuid, + }, + service_list=service_list, + cache=cache, + ) + + elif event.event.event_type == EventTypeEnum.EVENTTYPE_REMOVE: + # cannot fetch service details because it does not exist anymore + LOGGER.info( + "Service removed: {}".format( + grpc_message_to_json_string(event.service_id) + ) + ) + delete_service( + { + "service": event.service_id.service_uuid.uuid, + "context": event.service_id.context_id.context_uuid.uuid, + }, + service_list=service_list, + cache=cache, + ) + + events_collector.stop() + + +async def monitor_services(terminate, service_list=None, cache=None): + + monitoring_interval = int( + get_setting("MONITORING_INTERVAL", default=MONITORING_INTERVAL) + ) + + host = get_setting("OPTICALATTACKDETECTORSERVICE_SERVICE_HOST") + port = int(get_setting("OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC")) + + LOGGER.info("Starting execution of the async loop") + + while not terminate.is_set(): + + current_list = [] + if SERVICE_LIST_MODE == LIST_REDIS_MODE: + current_list.extend( + [ + pickle.loads(service) + for service in cache.lrange(SERVICE_LIST_KEY, 0, -1) + ] + ) + elif SERVICE_LIST_MODE == LIST_SHARED_MODE: + current_list.extend(service_list) + + CURRENT_SERVICES.set(len(current_list)) + + if len(current_list) == 0: + LOGGER.info("No services to monitor...") + time.sleep(monitoring_interval) + continue + + LOGGER.info("Starting new monitoring cycle...") + + start_time = time.time() + + tasks = [] + for service in current_list: + aw = detect_attack( + host, + port, + service["context"], + service["service"], + service["kpi"], + # allow at most 90% of the monitoring interval to succeed + monitoring_interval * 0.9, + ) + tasks.append(aw) + [await aw for aw in tasks] + + end_time = time.time() + + time_taken = end_time - start_time + LOOP_TIME.observe(time_taken) + LOGGER.info( + "Monitoring loop with {} services took {:.3f} seconds ({:.2f}%)... " + "Waiting for {:.2f} seconds...".format( + len(current_list), + time_taken, + (time_taken / monitoring_interval) * 100, + monitoring_interval - time_taken, + ) + ) + + if time_taken / monitoring_interval > 0.9: + LOGGER.warning( + "Monitoring loop is taking {} % of the desired time " + "({} seconds)".format( + (time_taken / monitoring_interval) * 100, monitoring_interval + ) + ) + if monitoring_interval - time_taken > 0: + time.sleep(monitoring_interval - time_taken) + + +def main(): + global LOGGER # pylint: disable=global-statement + + log_level = get_log_level() + logging.basicConfig(level=log_level) + LOGGER = logging.getLogger(__name__) + + logging.getLogger("hpack").setLevel(logging.CRITICAL) + + wait_for_environment_variables( + [ + get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name( + ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + ] + ) + + wait_for_environment_variables( + [ + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + ] + ) + + wait_for_environment_variables( + [ + get_env_var_name( + ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_HOST + ), + get_env_var_name( + ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + ] + ) + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) + + LOGGER.info("Starting...") + + # Start metrics server + metrics_port = get_metrics_port() + start_http_server(metrics_port) + + if SERVICE_LIST_MODE not in [1, 2]: + LOGGER.critical( + "Service mode has wrong configuration. Value: {}.".format(SERVICE_LIST_MODE) + ) + + redis_host = get_service_host(ServiceNameEnum.CACHING) + r = None + if redis_host is not None: + redis_port = int(get_setting("CACHINGSERVICE_SERVICE_PORT_REDIS")) + redis_password = get_setting("REDIS_PASSWORD") + + service_list = None + cache = None + if SERVICE_LIST_MODE == LIST_REDIS_MODE: + cache = redis.Redis(host=redis_host, port=redis_port, password=redis_password) + + # clean the existing list that will be populated later on in this function + cache.delete(SERVICE_LIST_KEY) + elif SERVICE_LIST_MODE == LIST_SHARED_MODE: + # creating a thread-safe list to be shared among threads + service_list = Manager().list() + + LOGGER.info("Connecting with context component...") + context_client: ContextClient = ContextClient() + monitoring_client: MonitoringClient = MonitoringClient() + LOGGER.info("Connected successfully...") + + if get_setting("TESTING", default=False): + # if testing, create dummy services + kpi_id = create_kpi(monitoring_client, "1213") + append_service( + {"context": "admin", "service": "1213", "kpi": kpi_id.kpi_id.uuid}, + service_list=service_list, + cache=cache, + ) + kpi_id = create_kpi(monitoring_client, "1456") + append_service( + {"context": "admin", "service": "1456", "kpi": kpi_id.kpi_id.uuid}, + service_list=service_list, + cache=cache, + ) + + context_ids: ContextIdList = context_client.ListContextIds(Empty()) + + # populate with initial services + for context_id in context_ids.context_ids: + context_services: ServiceIdList = context_client.ListServiceIds(context_id) + for service_id in context_services.service_ids: + service: Service = context_client.GetService(service_id) + if ( + service.service_type + == ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE + ): + # in case of a service restart, monitoring component will not duplicate KPIs + # but rather return the existing KPI if that's the case + kpi_id = create_kpi(monitoring_client, service_id.service_uuid.uuid) + append_service( + { + "context": context_id.context_uuid.uuid, + "service": service_id.service_uuid.uuid, + "kpi": kpi_id.kpi_id.uuid, + }, + service_list=service_list, + cache=cache, + ) + + context_client.close() + monitoring_client.close() + + # starting background process to monitor service addition/removal + process_context = Process( + target=get_context_updates, args=(terminate, service_list, cache) + ) + process_context.start() + + time.sleep(5) # wait for the context updates to startup + + # runs the async loop in the background + loop = asyncio.get_event_loop() + loop.run_until_complete(monitor_services(terminate, service_list, cache)) + # asyncio.create_task(monitor_services(service_list)) + + # Wait for Ctrl+C or termination signal + while not terminate.wait(timeout=0.1): + pass + + LOGGER.info("Terminating...") + process_context.kill() + # process_security_loop.kill() + + LOGGER.info("Bye") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/src/opticalattackmanager/tests/__init__.py b/src/opticalattackmanager/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/opticalattackmanager/tests/test_unitary.py b/src/opticalattackmanager/tests/test_unitary.py new file mode 100644 index 0000000000000000000000000000000000000000..7fa13960a2d1df09b89249ffbf7954d5e1ec5841 --- /dev/null +++ b/src/opticalattackmanager/tests/test_unitary.py @@ -0,0 +1,120 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import os +from unittest.mock import patch + +import pytest + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS, + DEFAULT_SERVICE_GRPC_PORTS, ServiceNameEnum) +from common.proto import dbscanserving_pb2 as dbscan +from common.proto.optical_attack_detector_pb2 import DetectionRequest +from opticalattackdetector.client.OpticalAttackDetectorClient import \ + OpticalAttackDetectorClient +from opticalattackdetector.Config import GRPC_SERVICE_PORT +from opticalattackdetector.service.OpticalAttackDetectorService import \ + OpticalAttackDetectorService + +# from .example_objects import CONTEXT_ID, CONTEXT_ID_2, SERVICE_DEV1_DEV2 + +port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +@pytest.fixture(scope="session") +def optical_attack_detector_service(): + with patch.dict( + os.environ, + { + "OPTICALATTACKDETECTORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get( + ServiceNameEnum.OPTICALATTACKDETECTOR.value + ) + ), + "OPTICALATTACKMITIGATORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get( + ServiceNameEnum.OPTICALATTACKMITIGATOR.value + ) + ), + "DBSCANSERVINGSERVICE_SERVICE_HOST": "127.0.0.1", + "DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get(ServiceNameEnum.DBSCANSERVING.value) + ), + }, + clear=True, + ): + _service = OpticalAttackDetectorService( + port=port, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + ) + # mocker_context_client = mock.patch('opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.context_client') + # mocker_context_client.start() + + # mocker_influx_db = mock.patch('opticalattackdetector.service.OpticalAttackDetectorServiceServicerImpl.influxdb_client') + # mocker_influx_db.start() + + _service.start() + yield _service + _service.stop() + # mocker_context_client.stop() + # mocker_influx_db.stop() + + +@pytest.fixture(scope="session") +def optical_attack_detector_client(optical_attack_detector_service): + with patch.dict( + os.environ, + { + "OPTICALATTACKDETECTORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKDETECTORSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get( + ServiceNameEnum.OPTICALATTACKDETECTOR.value + ) + ), + "OPTICALATTACKMITIGATORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get( + ServiceNameEnum.OPTICALATTACKMITIGATOR.value + ) + ), + "DBSCANSERVINGSERVICE_SERVICE_HOST": "127.0.0.1", + "DBSCANSERVINGSERVICE_SERVICE_PORT_GRPC": str( + 1000 + + DEFAULT_SERVICE_GRPC_PORTS.get(ServiceNameEnum.DBSCANSERVING.value) + ), + }, + clear=True, + ): + _client = OpticalAttackDetectorClient() + yield _client + _client.close() + + +def test_detect_attack( + optical_attack_detector_client: OpticalAttackDetectorClient, +): + LOGGER.info("placeholder") diff --git a/src/opticalattackmanager/utils/EventsCollector.py b/src/opticalattackmanager/utils/EventsCollector.py new file mode 100644 index 0000000000000000000000000000000000000000..2515ed82d7b30914047a091f9370ebfc50a167b7 --- /dev/null +++ b/src/opticalattackmanager/utils/EventsCollector.py @@ -0,0 +1,84 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import queue +import threading + +import grpc + +from common.proto.context_pb2 import Empty +from common.tools.grpc.Tools import grpc_message_to_json_string +from context.client.ContextClient import ContextClient + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + + +class EventsCollector: + def __init__( + self, context_client_grpc: ContextClient, log_events_received=False + ) -> None: + self._events_queue = queue.Queue() + self._log_events_received = log_events_received + + self._service_stream = context_client_grpc.GetServiceEvents(Empty()) + + self._service_thread = threading.Thread( + target=self._collect, args=(self._service_stream,), daemon=False + ) + + def _collect(self, events_stream) -> None: + try: + for event in events_stream: + if self._log_events_received: + LOGGER.info( + "[_collect] event: {:s}".format( + grpc_message_to_json_string(event) + ) + ) + self._events_queue.put_nowait(event) + except grpc.RpcError as e: + if e.code() != grpc.StatusCode.CANCELLED: # pylint: disable=no-member + raise # pragma: no cover + + def start(self): + self._service_thread.start() + + def get_event(self, block: bool = True, timeout: float = 0.1): + try: + return self._events_queue.get(block=block, timeout=timeout) + except queue.Empty: # pylint: disable=catching-non-exception + return None + + def get_events(self, block: bool = True, timeout: float = 0.1, count: int = None): + events = [] + if count is None: + while True: + event = self.get_event(block=block, timeout=timeout) + if event is None: + break + events.append(event) + else: + for _ in range(count): + event = self.get_event(block=block, timeout=timeout) + if event is None: + continue + events.append(event) + return sorted(events, key=lambda e: e.event.timestamp.timestamp) + + def stop(self): + self._service_stream.cancel() + + self._service_thread.join() diff --git a/src/opticalattackmanager/utils/__init__.py b/src/opticalattackmanager/utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9953c820575d42fa88351cc8de022d880ba96e6a --- /dev/null +++ b/src/opticalattackmanager/utils/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. diff --git a/src/opticalattackmanager/utils/monitor.py b/src/opticalattackmanager/utils/monitor.py new file mode 100644 index 0000000000000000000000000000000000000000..79c37a3191d774da44e385ecefc6d72d6b4018f1 --- /dev/null +++ b/src/opticalattackmanager/utils/monitor.py @@ -0,0 +1,64 @@ +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +import logging +import time +from typing import List + +from grpclib.client import Channel +from prometheus_client import Counter + +from common.proto.asyncio.optical_attack_detector_grpc import \ + OpticalAttackDetectorServiceStub +from common.proto.asyncio.optical_attack_detector_pb2 import DetectionRequest +from common.Settings import get_log_level, get_setting + +DROP_COUNTER = Counter( + "optical_security_dropped_assessments", + "Dropped assessments due to detector timeout", +) + + +log_level = get_log_level() +logging.basicConfig(level=log_level) +LOGGER = logging.getLogger(__name__) + + +async def detect_attack( + host: str, + port: int, + context_id: str, + service_id: str, + kpi_id: str, + timeout: float = 20.0, +) -> None: + try: + LOGGER.debug("Sending request for {}...".format(service_id)) + async with Channel(host, port) as channel: + stub = OpticalAttackDetectorServiceStub(channel) + + request: DetectionRequest = DetectionRequest() + request.service_id.context_id.context_uuid.uuid = context_id + request.service_id.service_uuid.uuid = str(service_id) + + request.kpi_id.kpi_id.uuid = kpi_id + + await stub.DetectAttack(request, timeout=timeout) + LOGGER.debug("Monitoring finished for {}/{}".format(service_id, kpi_id)) + except Exception as e: + LOGGER.warning( + "Exception while processing service_id {}/{}".format(service_id, kpi_id) + ) + LOGGER.exception(e) + DROP_COUNTER.inc() diff --git a/src/opticalattackmitigator/.gitlab-ci.yml b/src/opticalattackmitigator/.gitlab-ci.yml index 5b9a133bd0cbf4b7dc4a4b6cf290a3be9adf663e..ccb358a2f51feda8d362c7823e1ff8e666c0983a 100644 --- a/src/opticalattackmitigator/.gitlab-ci.yml +++ b/src/opticalattackmitigator/.gitlab-ci.yml @@ -21,7 +21,7 @@ build opticalattackmitigator: 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 build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile . - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" after_script: @@ -51,11 +51,10 @@ unit test opticalattackmitigator: - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi script: - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" - - docker run --name $IMAGE_NAME -d -p 10007:10007 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG + - docker run --name $IMAGE_NAME -d -p 10007:10007 -v "$PWD/src/$IMAGE_NAME/tests:/home/${IMAGE_NAME}/results" --network=teraflowbridge --rm $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG - sleep 5 - docker ps -a - - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml" - - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" + - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/home/${IMAGE_NAME}/results/${IMAGE_NAME}_report.xml; coverage xml -o /home/${IMAGE_NAME}/results/${IMAGE_NAME}_coverage.xml; coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: - docker rm -f $IMAGE_NAME diff --git a/src/opticalattackmitigator/Config.py b/src/opticalattackmitigator/Config.py index 130381d8bd1db49803aefa992435808bed3a87d3..8e01631bbcd95e6d29bff75449b6e06bd71828ce 100644 --- a/src/opticalattackmitigator/Config.py +++ b/src/opticalattackmitigator/Config.py @@ -19,8 +19,6 @@ LOG_LEVEL = logging.DEBUG # gRPC settings GRPC_SERVICE_PORT = 10007 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 # Prometheus settings METRICS_PORT = 9192 diff --git a/src/opticalattackmitigator/Dockerfile b/src/opticalattackmitigator/Dockerfile index 40469805410e26b145d8a84beda8247fb7c7a56d..c736ed5d9d594fd7dff27ee2f4e2647927e363e1 100644 --- a/src/opticalattackmitigator/Dockerfile +++ b/src/opticalattackmitigator/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3-slim +FROM python:3.9-slim # Install dependencies RUN apt-get --yes --quiet --quiet update && \ @@ -27,23 +27,54 @@ 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 +# Creating a user for security reasons +RUN groupadd -r teraflow && useradd -u 1001 --no-log-init -r -m -g teraflow teraflow +USER teraflow + +# set working directory +RUN mkdir -p /home/teraflow/controller/common/proto +WORKDIR /home/teraflow/controller + +# Get Python packages per module +ENV VIRTUAL_ENV=/home/teraflow/venv +RUN python3 -m venv ${VIRTUAL_ENV} +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" + # Get generic Python packages -RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade setuptools wheel +RUN python3 -m pip install --upgrade pip-tools + +# Get common Python packages +# Note: this step enables sharing the previous Docker build steps among all the Python components +COPY --chown=teraflow:teraflow common_requirements.in common_requirements.in +RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in +RUN python3 -m pip install -r common_requirements.txt + +# Add common files into working directory +WORKDIR /home/teraflow/controller/common +COPY --chown=teraflow:teraflow src/common/. ./ -# Set working directory -WORKDIR /var/teraflow +# Create proto sub-folder, copy .proto files, and generate Python code +WORKDIR /home/teraflow/controller/common/proto +RUN touch __init__.py +COPY --chown=teraflow:teraflow proto/*.proto ./ +RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto +RUN rm *.proto +RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; # Create module sub-folders -RUN mkdir -p /var/teraflow/opticalattackmitigator +RUN mkdir -p /home/teraflow/controller/opticalattackmitigator +WORKDIR /home/teraflow/controller # Get Python packages per module -COPY opticalattackmitigator/requirements.in opticalattackmitigator/requirements.in -RUN pip-compile --output-file=opticalattackmitigator/requirements.txt opticalattackmitigator/requirements.in +COPY --chown=teraflow:teraflow src/opticalattackmitigator/requirements.in opticalattackmitigator/requirements.in +# consider common and specific requirements to avoid inconsistencies with dependencies +RUN pip-compile --quiet --output-file=opticalattackmitigator/requirements.txt opticalattackmitigator/requirements.in common_requirements.in RUN python3 -m pip install -r opticalattackmitigator/requirements.txt # Add files into working directory -COPY common/. common -COPY opticalattackmitigator/. opticalattackmitigator +COPY --chown=teraflow:teraflow src/opticalattackmitigator/. opticalattackmitigator # Start opticalattackmitigator service ENTRYPOINT ["python", "-m", "opticalattackmitigator.service"] diff --git a/src/opticalattackmitigator/__init__.py b/src/opticalattackmitigator/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalattackmitigator/__init__.py +++ b/src/opticalattackmitigator/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py b/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py index d0c53e57ee54a42955210308492e27d0bb332729..32f0cfdd5fd34c4fa08a8b16461c98842eb5554d 100644 --- a/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py +++ b/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py @@ -12,37 +12,61 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc, logging -from common.tools.client.RetryDecorator import retry, delay_exponential -from opticalattackmitigator.proto.optical_attack_mitigator_pb2 import AttackDescription, AttackResponse -from opticalattackmitigator.proto.optical_attack_mitigator_pb2_grpc import AttackMitigatorStub +import logging + +import grpc + +from common.proto.optical_attack_mitigator_pb2 import (AttackDescription, + AttackResponse) +from common.proto.optical_attack_mitigator_pb2_grpc import AttackMitigatorStub +from common.Settings import get_setting +from common.tools.client.RetryDecorator import delay_exponential, retry +from common.tools.grpc.Tools import grpc_message_to_json LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) -RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') +RETRY_DECORATOR = retry( + max_retries=MAX_RETRIES, + delay_function=DELAY_FUNCTION, + prepare_method_name="connect", +) + class OpticalAttackMitigatorClient: - def __init__(self, address, port): - self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) - LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) + def __init__(self, host=None, port=None): + if not host: + host = get_setting( + "OPTICALATTACKMITIGATORSERVICE_SERVICE_HOST", default="DBSCANSERVING" + ) + if not port: + port = get_setting( + "OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC", default=10007 + ) + self.endpoint = "{:s}:{:s}".format(str(host), str(port)) + LOGGER.debug("Creating channel to {:s}...".format(str(self.endpoint))) self.channel = None self.stub = None self.connect() - LOGGER.debug('Channel created') + LOGGER.debug("Channel created") def connect(self): self.channel = grpc.insecure_channel(self.endpoint) self.stub = AttackMitigatorStub(self.channel) def close(self): - if(self.channel is not None): self.channel.close() + if self.channel is not None: + self.channel.close() self.channel = None self.stub = None @RETRY_DECORATOR - def NotifyAttack(self, request : AttackDescription) -> AttackResponse: - LOGGER.debug('NotifyAttack request: {:s}'.format(str(request))) + def NotifyAttack(self, request: AttackDescription) -> AttackResponse: + LOGGER.debug( + "NotifyAttack request: {:s}".format(str(grpc_message_to_json(request))) + ) response = self.stub.NotifyAttack(request) - LOGGER.debug('NotifyAttack result: {:s}'.format(str(response))) + LOGGER.debug( + "NotifyAttack result: {:s}".format(str(grpc_message_to_json(response))) + ) return response diff --git a/src/opticalattackmitigator/client/__init__.py b/src/opticalattackmitigator/client/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalattackmitigator/client/__init__.py +++ b/src/opticalattackmitigator/client/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackmitigator/proto/context_pb2.py b/src/opticalattackmitigator/proto/context_pb2.py deleted file mode 100644 index 50d501d3ac053ad644554331af26e3c40cd426a1..0000000000000000000000000000000000000000 --- a/src/opticalattackmitigator/proto/context_pb2.py +++ /dev/null @@ -1,3071 +0,0 @@ -# -*- 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() - - -from . import kpi_sample_types_pb2 as kpi__sample__types__pb2 - - -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\x1a\x16kpi_sample_types.proto\"\x07\n\x05\x45mpty\"\x14\n\x04Uuid\x12\x0c\n\x04uuid\x18\x01 \x01(\t\"F\n\x05\x45vent\x12\x11\n\ttimestamp\x18\x01 \x01(\x01\x12*\n\nevent_type\x18\x02 \x01(\x0e\x32\x16.context.EventTypeEnum\"0\n\tContextId\x12#\n\x0c\x63ontext_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\xb6\x01\n\x07\x43ontext\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12)\n\x0ctopology_ids\x18\x02 \x03(\x0b\x32\x13.context.TopologyId\x12\'\n\x0bservice_ids\x18\x03 \x03(\x0b\x32\x12.context.ServiceId\x12/\n\ncontroller\x18\x04 \x01(\x0b\x32\x1b.context.TeraFlowController\"8\n\rContextIdList\x12\'\n\x0b\x63ontext_ids\x18\x01 \x03(\x0b\x32\x12.context.ContextId\"1\n\x0b\x43ontextList\x12\"\n\x08\x63ontexts\x18\x01 \x03(\x0b\x32\x10.context.Context\"U\n\x0c\x43ontextEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12&\n\ncontext_id\x18\x02 \x01(\x0b\x32\x12.context.ContextId\"Z\n\nTopologyId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12$\n\rtopology_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"~\n\x08Topology\x12(\n\x0btopology_id\x18\x01 \x01(\x0b\x32\x13.context.TopologyId\x12%\n\ndevice_ids\x18\x02 \x03(\x0b\x32\x11.context.DeviceId\x12!\n\x08link_ids\x18\x03 \x03(\x0b\x32\x0f.context.LinkId\";\n\x0eTopologyIdList\x12)\n\x0ctopology_ids\x18\x01 \x03(\x0b\x32\x13.context.TopologyId\"5\n\x0cTopologyList\x12%\n\ntopologies\x18\x01 \x03(\x0b\x32\x11.context.Topology\"X\n\rTopologyEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12(\n\x0btopology_id\x18\x02 \x01(\x0b\x32\x13.context.TopologyId\".\n\x08\x44\x65viceId\x12\"\n\x0b\x64\x65vice_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\x9a\x02\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\x12G\n\x19\x64\x65vice_operational_status\x18\x04 \x01(\x0e\x32$.context.DeviceOperationalStatusEnum\x12\x31\n\x0e\x64\x65vice_drivers\x18\x05 \x03(\x0e\x32\x19.context.DeviceDriverEnum\x12+\n\x10\x64\x65vice_endpoints\x18\x06 \x03(\x0b\x32\x11.context.EndPoint\"9\n\x0c\x44\x65viceConfig\x12)\n\x0c\x63onfig_rules\x18\x01 \x03(\x0b\x32\x13.context.ConfigRule\"5\n\x0c\x44\x65viceIdList\x12%\n\ndevice_ids\x18\x01 \x03(\x0b\x32\x11.context.DeviceId\".\n\nDeviceList\x12 \n\x07\x64\x65vices\x18\x01 \x03(\x0b\x32\x0f.context.Device\"R\n\x0b\x44\x65viceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12$\n\tdevice_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\"*\n\x06LinkId\x12 \n\tlink_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"X\n\x04Link\x12 \n\x07link_id\x18\x01 \x01(\x0b\x32\x0f.context.LinkId\x12.\n\x11link_endpoint_ids\x18\x02 \x03(\x0b\x32\x13.context.EndPointId\"/\n\nLinkIdList\x12!\n\x08link_ids\x18\x01 \x03(\x0b\x32\x0f.context.LinkId\"(\n\x08LinkList\x12\x1c\n\x05links\x18\x01 \x03(\x0b\x32\r.context.Link\"L\n\tLinkEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12 \n\x07link_id\x18\x02 \x01(\x0b\x32\x0f.context.LinkId\"X\n\tServiceId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12#\n\x0cservice_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"\xa6\x02\n\x07Service\x12&\n\nservice_id\x18\x01 \x01(\x0b\x32\x12.context.ServiceId\x12.\n\x0cservice_type\x18\x02 \x01(\x0e\x32\x18.context.ServiceTypeEnum\x12\x31\n\x14service_endpoint_ids\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\x12\x30\n\x13service_constraints\x18\x04 \x03(\x0b\x32\x13.context.Constraint\x12.\n\x0eservice_status\x18\x05 \x01(\x0b\x32\x16.context.ServiceStatus\x12.\n\x0eservice_config\x18\x06 \x01(\x0b\x32\x16.context.ServiceConfig\"C\n\rServiceStatus\x12\x32\n\x0eservice_status\x18\x01 \x01(\x0e\x32\x1a.context.ServiceStatusEnum\":\n\rServiceConfig\x12)\n\x0c\x63onfig_rules\x18\x01 \x03(\x0b\x32\x13.context.ConfigRule\"8\n\rServiceIdList\x12\'\n\x0bservice_ids\x18\x01 \x03(\x0b\x32\x12.context.ServiceId\"1\n\x0bServiceList\x12\"\n\x08services\x18\x01 \x03(\x0b\x32\x10.context.Service\"U\n\x0cServiceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12&\n\nservice_id\x18\x02 \x01(\x0b\x32\x12.context.ServiceId\"T\n\x07SliceId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12!\n\nslice_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"\x95\x02\n\x05Slice\x12\"\n\x08slice_id\x18\x01 \x01(\x0b\x32\x10.context.SliceId\x12/\n\x12slice_endpoint_ids\x18\x02 \x03(\x0b\x32\x13.context.EndPointId\x12.\n\x11slice_constraints\x18\x03 \x03(\x0b\x32\x13.context.Constraint\x12-\n\x11slice_service_ids\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\x12,\n\x12slice_subslice_ids\x18\x05 \x03(\x0b\x32\x10.context.SliceId\x12*\n\x0cslice_status\x18\x06 \x01(\x0b\x32\x14.context.SliceStatus\"=\n\x0bSliceStatus\x12.\n\x0cslice_status\x18\x01 \x01(\x0e\x32\x18.context.SliceStatusEnum\"2\n\x0bSliceIdList\x12#\n\tslice_ids\x18\x01 \x03(\x0b\x32\x10.context.SliceId\"+\n\tSliceList\x12\x1e\n\x06slices\x18\x01 \x03(\x0b\x32\x0e.context.Slice\"O\n\nSliceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12\"\n\x08slice_id\x18\x02 \x01(\x0b\x32\x10.context.SliceId\"6\n\x0c\x43onnectionId\x12&\n\x0f\x63onnection_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\xc4\x01\n\nConnection\x12,\n\rconnection_id\x18\x01 \x01(\x0b\x32\x15.context.ConnectionId\x12&\n\nservice_id\x18\x02 \x01(\x0b\x32\x12.context.ServiceId\x12\x33\n\x16path_hops_endpoint_ids\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\x12+\n\x0fsub_service_ids\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\"A\n\x10\x43onnectionIdList\x12-\n\x0e\x63onnection_ids\x18\x01 \x03(\x0b\x32\x15.context.ConnectionId\":\n\x0e\x43onnectionList\x12(\n\x0b\x63onnections\x18\x01 \x03(\x0b\x32\x13.context.Connection\"^\n\x0f\x43onnectionEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12,\n\rconnection_id\x18\x02 \x01(\x0b\x32\x15.context.ConnectionId\"\x82\x01\n\nEndPointId\x12(\n\x0btopology_id\x18\x01 \x01(\x0b\x32\x13.context.TopologyId\x12$\n\tdevice_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\x12$\n\rendpoint_uuid\x18\x03 \x01(\x0b\x32\r.context.Uuid\"\x86\x01\n\x08\x45ndPoint\x12(\n\x0b\x65ndpoint_id\x18\x01 \x01(\x0b\x32\x13.context.EndPointId\x12\x15\n\rendpoint_type\x18\x02 \x01(\t\x12\x39\n\x10kpi_sample_types\x18\x03 \x03(\x0e\x32\x1f.kpi_sample_types.KpiSampleType\"e\n\nConfigRule\x12)\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32\x19.context.ConfigActionEnum\x12\x14\n\x0cresource_key\x18\x02 \x01(\t\x12\x16\n\x0eresource_value\x18\x03 \x01(\t\"?\n\nConstraint\x12\x17\n\x0f\x63onstraint_type\x18\x01 \x01(\t\x12\x18\n\x10\x63onstraint_value\x18\x02 \x01(\t\"^\n\x12TeraFlowController\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x12\n\nip_address\x18\x02 \x01(\t\x12\x0c\n\x04port\x18\x03 \x01(\r\"U\n\x14\x41uthenticationResult\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x15\n\rauthenticated\x18\x02 \x01(\x08*j\n\rEventTypeEnum\x12\x17\n\x13\x45VENTTYPE_UNDEFINED\x10\x00\x12\x14\n\x10\x45VENTTYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENTTYPE_UPDATE\x10\x02\x12\x14\n\x10\x45VENTTYPE_REMOVE\x10\x03*\xc5\x01\n\x10\x44\x65viceDriverEnum\x12\x1a\n\x16\x44\x45VICEDRIVER_UNDEFINED\x10\x00\x12\x1b\n\x17\x44\x45VICEDRIVER_OPENCONFIG\x10\x01\x12\x1e\n\x1a\x44\x45VICEDRIVER_TRANSPORT_API\x10\x02\x12\x13\n\x0f\x44\x45VICEDRIVER_P4\x10\x03\x12&\n\"DEVICEDRIVER_IETF_NETWORK_TOPOLOGY\x10\x04\x12\x1b\n\x17\x44\x45VICEDRIVER_ONF_TR_352\x10\x05*\x8f\x01\n\x1b\x44\x65viceOperationalStatusEnum\x12%\n!DEVICEOPERATIONALSTATUS_UNDEFINED\x10\x00\x12$\n DEVICEOPERATIONALSTATUS_DISABLED\x10\x01\x12#\n\x1f\x44\x45VICEOPERATIONALSTATUS_ENABLED\x10\x02*\x81\x01\n\x0fServiceTypeEnum\x12\x17\n\x13SERVICETYPE_UNKNOWN\x10\x00\x12\x14\n\x10SERVICETYPE_L3NM\x10\x01\x12\x14\n\x10SERVICETYPE_L2NM\x10\x02\x12)\n%SERVICETYPE_TAPI_CONNECTIVITY_SERVICE\x10\x03*\x88\x01\n\x11ServiceStatusEnum\x12\x1b\n\x17SERVICESTATUS_UNDEFINED\x10\x00\x12\x19\n\x15SERVICESTATUS_PLANNED\x10\x01\x12\x18\n\x14SERVICESTATUS_ACTIVE\x10\x02\x12!\n\x1dSERVICESTATUS_PENDING_REMOVAL\x10\x03*\x8b\x01\n\x0fSliceStatusEnum\x12\x19\n\x15SLICESTATUS_UNDEFINED\x10\x00\x12\x17\n\x13SLICESTATUS_PLANNED\x10\x01\x12\x14\n\x10SLICESTATUS_INIT\x10\x02\x12\x16\n\x12SLICESTATUS_ACTIVE\x10\x03\x12\x16\n\x12SLICESTATUS_DEINIT\x10\x04*]\n\x10\x43onfigActionEnum\x12\x1a\n\x16\x43ONFIGACTION_UNDEFINED\x10\x00\x12\x14\n\x10\x43ONFIGACTION_SET\x10\x01\x12\x17\n\x13\x43ONFIGACTION_DELETE\x10\x02\x32\xef\x12\n\x0e\x43ontextService\x12:\n\x0eListContextIds\x12\x0e.context.Empty\x1a\x16.context.ContextIdList\"\x00\x12\x36\n\x0cListContexts\x12\x0e.context.Empty\x1a\x14.context.ContextList\"\x00\x12\x34\n\nGetContext\x12\x12.context.ContextId\x1a\x10.context.Context\"\x00\x12\x34\n\nSetContext\x12\x10.context.Context\x1a\x12.context.ContextId\"\x00\x12\x35\n\rRemoveContext\x12\x12.context.ContextId\x1a\x0e.context.Empty\"\x00\x12=\n\x10GetContextEvents\x12\x0e.context.Empty\x1a\x15.context.ContextEvent\"\x00\x30\x01\x12@\n\x0fListTopologyIds\x12\x12.context.ContextId\x1a\x17.context.TopologyIdList\"\x00\x12=\n\x0eListTopologies\x12\x12.context.ContextId\x1a\x15.context.TopologyList\"\x00\x12\x37\n\x0bGetTopology\x12\x13.context.TopologyId\x1a\x11.context.Topology\"\x00\x12\x37\n\x0bSetTopology\x12\x11.context.Topology\x1a\x13.context.TopologyId\"\x00\x12\x37\n\x0eRemoveTopology\x12\x13.context.TopologyId\x1a\x0e.context.Empty\"\x00\x12?\n\x11GetTopologyEvents\x12\x0e.context.Empty\x1a\x16.context.TopologyEvent\"\x00\x30\x01\x12\x38\n\rListDeviceIds\x12\x0e.context.Empty\x1a\x15.context.DeviceIdList\"\x00\x12\x34\n\x0bListDevices\x12\x0e.context.Empty\x1a\x13.context.DeviceList\"\x00\x12\x31\n\tGetDevice\x12\x11.context.DeviceId\x1a\x0f.context.Device\"\x00\x12\x31\n\tSetDevice\x12\x0f.context.Device\x1a\x11.context.DeviceId\"\x00\x12\x33\n\x0cRemoveDevice\x12\x11.context.DeviceId\x1a\x0e.context.Empty\"\x00\x12;\n\x0fGetDeviceEvents\x12\x0e.context.Empty\x1a\x14.context.DeviceEvent\"\x00\x30\x01\x12\x34\n\x0bListLinkIds\x12\x0e.context.Empty\x1a\x13.context.LinkIdList\"\x00\x12\x30\n\tListLinks\x12\x0e.context.Empty\x1a\x11.context.LinkList\"\x00\x12+\n\x07GetLink\x12\x0f.context.LinkId\x1a\r.context.Link\"\x00\x12+\n\x07SetLink\x12\r.context.Link\x1a\x0f.context.LinkId\"\x00\x12/\n\nRemoveLink\x12\x0f.context.LinkId\x1a\x0e.context.Empty\"\x00\x12\x37\n\rGetLinkEvents\x12\x0e.context.Empty\x1a\x12.context.LinkEvent\"\x00\x30\x01\x12>\n\x0eListServiceIds\x12\x12.context.ContextId\x1a\x16.context.ServiceIdList\"\x00\x12:\n\x0cListServices\x12\x12.context.ContextId\x1a\x14.context.ServiceList\"\x00\x12\x34\n\nGetService\x12\x12.context.ServiceId\x1a\x10.context.Service\"\x00\x12\x34\n\nSetService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x35\n\rRemoveService\x12\x12.context.ServiceId\x1a\x0e.context.Empty\"\x00\x12=\n\x10GetServiceEvents\x12\x0e.context.Empty\x1a\x15.context.ServiceEvent\"\x00\x30\x01\x12:\n\x0cListSliceIds\x12\x12.context.ContextId\x1a\x14.context.SliceIdList\"\x00\x12\x36\n\nListSlices\x12\x12.context.ContextId\x1a\x12.context.SliceList\"\x00\x12.\n\x08GetSlice\x12\x10.context.SliceId\x1a\x0e.context.Slice\"\x00\x12.\n\x08SetSlice\x12\x0e.context.Slice\x1a\x10.context.SliceId\"\x00\x12\x31\n\x0bRemoveSlice\x12\x10.context.SliceId\x1a\x0e.context.Empty\"\x00\x12\x39\n\x0eGetSliceEvents\x12\x0e.context.Empty\x1a\x13.context.SliceEvent\"\x00\x30\x01\x12\x44\n\x11ListConnectionIds\x12\x12.context.ServiceId\x1a\x19.context.ConnectionIdList\"\x00\x12@\n\x0fListConnections\x12\x12.context.ServiceId\x1a\x17.context.ConnectionList\"\x00\x12=\n\rGetConnection\x12\x15.context.ConnectionId\x1a\x13.context.Connection\"\x00\x12=\n\rSetConnection\x12\x13.context.Connection\x1a\x15.context.ConnectionId\"\x00\x12;\n\x10RemoveConnection\x12\x15.context.ConnectionId\x1a\x0e.context.Empty\"\x00\x12\x43\n\x13GetConnectionEvents\x12\x0e.context.Empty\x1a\x18.context.ConnectionEvent\"\x00\x30\x01\x62\x06proto3' - , - dependencies=[kpi__sample__types__pb2.DESCRIPTOR,]) - -_EVENTTYPEENUM = _descriptor.EnumDescriptor( - name='EventTypeEnum', - full_name='context.EventTypeEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_CREATE', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_UPDATE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_REMOVE', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4310, - serialized_end=4416, -) -_sym_db.RegisterEnumDescriptor(_EVENTTYPEENUM) - -EventTypeEnum = enum_type_wrapper.EnumTypeWrapper(_EVENTTYPEENUM) -_DEVICEDRIVERENUM = _descriptor.EnumDescriptor( - name='DeviceDriverEnum', - full_name='context.DeviceDriverEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_OPENCONFIG', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_TRANSPORT_API', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_P4', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_IETF_NETWORK_TOPOLOGY', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_ONF_TR_352', index=5, number=5, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4419, - serialized_end=4616, -) -_sym_db.RegisterEnumDescriptor(_DEVICEDRIVERENUM) - -DeviceDriverEnum = enum_type_wrapper.EnumTypeWrapper(_DEVICEDRIVERENUM) -_DEVICEOPERATIONALSTATUSENUM = _descriptor.EnumDescriptor( - name='DeviceOperationalStatusEnum', - full_name='context.DeviceOperationalStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_DISABLED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_ENABLED', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4619, - serialized_end=4762, -) -_sym_db.RegisterEnumDescriptor(_DEVICEOPERATIONALSTATUSENUM) - -DeviceOperationalStatusEnum = enum_type_wrapper.EnumTypeWrapper(_DEVICEOPERATIONALSTATUSENUM) -_SERVICETYPEENUM = _descriptor.EnumDescriptor( - name='ServiceTypeEnum', - full_name='context.ServiceTypeEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_UNKNOWN', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_L3NM', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_L2NM', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_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=4765, - serialized_end=4894, -) -_sym_db.RegisterEnumDescriptor(_SERVICETYPEENUM) - -ServiceTypeEnum = enum_type_wrapper.EnumTypeWrapper(_SERVICETYPEENUM) -_SERVICESTATUSENUM = _descriptor.EnumDescriptor( - name='ServiceStatusEnum', - full_name='context.ServiceStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_PLANNED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_ACTIVE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_PENDING_REMOVAL', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4897, - serialized_end=5033, -) -_sym_db.RegisterEnumDescriptor(_SERVICESTATUSENUM) - -ServiceStatusEnum = enum_type_wrapper.EnumTypeWrapper(_SERVICESTATUSENUM) -_SLICESTATUSENUM = _descriptor.EnumDescriptor( - name='SliceStatusEnum', - full_name='context.SliceStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_PLANNED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_INIT', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_ACTIVE', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_DEINIT', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=5036, - serialized_end=5175, -) -_sym_db.RegisterEnumDescriptor(_SLICESTATUSENUM) - -SliceStatusEnum = enum_type_wrapper.EnumTypeWrapper(_SLICESTATUSENUM) -_CONFIGACTIONENUM = _descriptor.EnumDescriptor( - name='ConfigActionEnum', - full_name='context.ConfigActionEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_SET', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_DELETE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=5177, - serialized_end=5270, -) -_sym_db.RegisterEnumDescriptor(_CONFIGACTIONENUM) - -ConfigActionEnum = enum_type_wrapper.EnumTypeWrapper(_CONFIGACTIONENUM) -EVENTTYPE_UNDEFINED = 0 -EVENTTYPE_CREATE = 1 -EVENTTYPE_UPDATE = 2 -EVENTTYPE_REMOVE = 3 -DEVICEDRIVER_UNDEFINED = 0 -DEVICEDRIVER_OPENCONFIG = 1 -DEVICEDRIVER_TRANSPORT_API = 2 -DEVICEDRIVER_P4 = 3 -DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4 -DEVICEDRIVER_ONF_TR_352 = 5 -DEVICEOPERATIONALSTATUS_UNDEFINED = 0 -DEVICEOPERATIONALSTATUS_DISABLED = 1 -DEVICEOPERATIONALSTATUS_ENABLED = 2 -SERVICETYPE_UNKNOWN = 0 -SERVICETYPE_L3NM = 1 -SERVICETYPE_L2NM = 2 -SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3 -SERVICESTATUS_UNDEFINED = 0 -SERVICESTATUS_PLANNED = 1 -SERVICESTATUS_ACTIVE = 2 -SERVICESTATUS_PENDING_REMOVAL = 3 -SLICESTATUS_UNDEFINED = 0 -SLICESTATUS_PLANNED = 1 -SLICESTATUS_INIT = 2 -SLICESTATUS_ACTIVE = 3 -SLICESTATUS_DEINIT = 4 -CONFIGACTION_UNDEFINED = 0 -CONFIGACTION_SET = 1 -CONFIGACTION_DELETE = 2 - - - -_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=50, - serialized_end=57, -) - - -_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=59, - serialized_end=79, -) - - -_EVENT = _descriptor.Descriptor( - name='Event', - full_name='context.Event', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='timestamp', full_name='context.Event.timestamp', index=0, - number=1, type=1, cpp_type=5, label=1, - has_default_value=False, default_value=float(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='event_type', full_name='context.Event.event_type', 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), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=81, - serialized_end=151, -) - - -_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='context_uuid', full_name='context.ContextId.context_uuid', 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=153, - serialized_end=201, -) - - -_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='context_id', full_name='context.Context.context_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='topology_ids', full_name='context.Context.topology_ids', 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), - _descriptor.FieldDescriptor( - name='service_ids', full_name='context.Context.service_ids', 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='controller', full_name='context.Context.controller', index=3, - number=4, 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=204, - serialized_end=386, -) - - -_CONTEXTIDLIST = _descriptor.Descriptor( - name='ContextIdList', - full_name='context.ContextIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_ids', full_name='context.ContextIdList.context_ids', 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=388, - serialized_end=444, -) - - -_CONTEXTLIST = _descriptor.Descriptor( - name='ContextList', - full_name='context.ContextList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='contexts', full_name='context.ContextList.contexts', 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=446, - serialized_end=495, -) - - -_CONTEXTEVENT = _descriptor.Descriptor( - name='ContextEvent', - full_name='context.ContextEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ContextEvent.event', 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='context_id', full_name='context.ContextEvent.context_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=497, - serialized_end=582, -) - - -_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='context_id', full_name='context.TopologyId.context_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='topology_uuid', full_name='context.TopologyId.topology_uuid', 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=584, - serialized_end=674, -) - - -_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='topology_id', full_name='context.Topology.topology_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_ids', full_name='context.Topology.device_ids', 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), - _descriptor.FieldDescriptor( - name='link_ids', full_name='context.Topology.link_ids', 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=676, - serialized_end=802, -) - - -_TOPOLOGYIDLIST = _descriptor.Descriptor( - name='TopologyIdList', - full_name='context.TopologyIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='topology_ids', full_name='context.TopologyIdList.topology_ids', 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=804, - serialized_end=863, -) - - -_TOPOLOGYLIST = _descriptor.Descriptor( - name='TopologyList', - full_name='context.TopologyList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='topologies', full_name='context.TopologyList.topologies', 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=865, - serialized_end=918, -) - - -_TOPOLOGYEVENT = _descriptor.Descriptor( - name='TopologyEvent', - full_name='context.TopologyEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.TopologyEvent.event', 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='topology_id', full_name='context.TopologyEvent.topology_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=920, - serialized_end=1008, -) - - -_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_uuid', full_name='context.DeviceId.device_uuid', 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=1010, - serialized_end=1056, -) - - -_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='device_operational_status', full_name='context.Device.device_operational_status', 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='device_drivers', full_name='context.Device.device_drivers', index=4, - number=5, type=14, cpp_type=8, 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='device_endpoints', full_name='context.Device.device_endpoints', index=5, - number=6, 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=1059, - serialized_end=1341, -) - - -_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='config_rules', full_name='context.DeviceConfig.config_rules', 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=1343, - serialized_end=1400, -) - - -_DEVICEIDLIST = _descriptor.Descriptor( - name='DeviceIdList', - full_name='context.DeviceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='device_ids', full_name='context.DeviceIdList.device_ids', 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=1402, - serialized_end=1455, -) - - -_DEVICELIST = _descriptor.Descriptor( - name='DeviceList', - full_name='context.DeviceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='devices', full_name='context.DeviceList.devices', 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=1457, - serialized_end=1503, -) - - -_DEVICEEVENT = _descriptor.Descriptor( - name='DeviceEvent', - full_name='context.DeviceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.DeviceEvent.event', 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_id', full_name='context.DeviceEvent.device_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=1505, - serialized_end=1587, -) - - -_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_uuid', full_name='context.LinkId.link_uuid', 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=1589, - serialized_end=1631, -) - - -_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='link_endpoint_ids', full_name='context.Link.link_endpoint_ids', 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=1633, - serialized_end=1721, -) - - -_LINKIDLIST = _descriptor.Descriptor( - name='LinkIdList', - full_name='context.LinkIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='link_ids', full_name='context.LinkIdList.link_ids', 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=1723, - serialized_end=1770, -) - - -_LINKLIST = _descriptor.Descriptor( - name='LinkList', - full_name='context.LinkList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='links', full_name='context.LinkList.links', 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=1772, - serialized_end=1812, -) - - -_LINKEVENT = _descriptor.Descriptor( - name='LinkEvent', - full_name='context.LinkEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.LinkEvent.event', 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='link_id', full_name='context.LinkEvent.link_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=1814, - serialized_end=1890, -) - - -_SERVICEID = _descriptor.Descriptor( - name='ServiceId', - full_name='context.ServiceId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_id', full_name='context.ServiceId.context_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='service_uuid', full_name='context.ServiceId.service_uuid', 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=1892, - serialized_end=1980, -) - - -_SERVICE = _descriptor.Descriptor( - name='Service', - full_name='context.Service', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_id', full_name='context.Service.service_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='service_type', full_name='context.Service.service_type', 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='service_endpoint_ids', full_name='context.Service.service_endpoint_ids', 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='service_constraints', full_name='context.Service.service_constraints', 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='service_status', full_name='context.Service.service_status', 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='service_config', full_name='context.Service.service_config', 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=1983, - serialized_end=2277, -) - - -_SERVICESTATUS = _descriptor.Descriptor( - name='ServiceStatus', - full_name='context.ServiceStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_status', full_name='context.ServiceStatus.service_status', 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=2279, - serialized_end=2346, -) - - -_SERVICECONFIG = _descriptor.Descriptor( - name='ServiceConfig', - full_name='context.ServiceConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='config_rules', full_name='context.ServiceConfig.config_rules', 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=2348, - serialized_end=2406, -) - - -_SERVICEIDLIST = _descriptor.Descriptor( - name='ServiceIdList', - full_name='context.ServiceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_ids', full_name='context.ServiceIdList.service_ids', 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=2408, - serialized_end=2464, -) - - -_SERVICELIST = _descriptor.Descriptor( - name='ServiceList', - full_name='context.ServiceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='services', full_name='context.ServiceList.services', 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=2466, - serialized_end=2515, -) - - -_SERVICEEVENT = _descriptor.Descriptor( - name='ServiceEvent', - full_name='context.ServiceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ServiceEvent.event', 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='service_id', full_name='context.ServiceEvent.service_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=2517, - serialized_end=2602, -) - - -_SLICEID = _descriptor.Descriptor( - name='SliceId', - full_name='context.SliceId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_id', full_name='context.SliceId.context_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='slice_uuid', full_name='context.SliceId.slice_uuid', 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=2604, - serialized_end=2688, -) - - -_SLICE = _descriptor.Descriptor( - name='Slice', - full_name='context.Slice', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_id', full_name='context.Slice.slice_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='slice_endpoint_ids', full_name='context.Slice.slice_endpoint_ids', 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), - _descriptor.FieldDescriptor( - name='slice_constraints', full_name='context.Slice.slice_constraints', 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='slice_service_ids', full_name='context.Slice.slice_service_ids', 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='slice_subslice_ids', full_name='context.Slice.slice_subslice_ids', 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), - _descriptor.FieldDescriptor( - name='slice_status', full_name='context.Slice.slice_status', 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=2691, - serialized_end=2968, -) - - -_SLICESTATUS = _descriptor.Descriptor( - name='SliceStatus', - full_name='context.SliceStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_status', full_name='context.SliceStatus.slice_status', 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=2970, - serialized_end=3031, -) - - -_SLICEIDLIST = _descriptor.Descriptor( - name='SliceIdList', - full_name='context.SliceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_ids', full_name='context.SliceIdList.slice_ids', 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=3033, - serialized_end=3083, -) - - -_SLICELIST = _descriptor.Descriptor( - name='SliceList', - full_name='context.SliceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slices', full_name='context.SliceList.slices', 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=3085, - serialized_end=3128, -) - - -_SLICEEVENT = _descriptor.Descriptor( - name='SliceEvent', - full_name='context.SliceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.SliceEvent.event', 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='slice_id', full_name='context.SliceEvent.slice_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=3130, - serialized_end=3209, -) - - -_CONNECTIONID = _descriptor.Descriptor( - name='ConnectionId', - full_name='context.ConnectionId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_uuid', full_name='context.ConnectionId.connection_uuid', 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=3211, - serialized_end=3265, -) - - -_CONNECTION = _descriptor.Descriptor( - name='Connection', - full_name='context.Connection', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_id', full_name='context.Connection.connection_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='service_id', full_name='context.Connection.service_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='path_hops_endpoint_ids', full_name='context.Connection.path_hops_endpoint_ids', 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='sub_service_ids', full_name='context.Connection.sub_service_ids', 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), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3268, - serialized_end=3464, -) - - -_CONNECTIONIDLIST = _descriptor.Descriptor( - name='ConnectionIdList', - full_name='context.ConnectionIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_ids', full_name='context.ConnectionIdList.connection_ids', 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=3466, - serialized_end=3531, -) - - -_CONNECTIONLIST = _descriptor.Descriptor( - name='ConnectionList', - full_name='context.ConnectionList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connections', full_name='context.ConnectionList.connections', 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=3533, - serialized_end=3591, -) - - -_CONNECTIONEVENT = _descriptor.Descriptor( - name='ConnectionEvent', - full_name='context.ConnectionEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ConnectionEvent.event', 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='connection_id', full_name='context.ConnectionEvent.connection_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=3593, - serialized_end=3687, -) - - -_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='topology_id', full_name='context.EndPointId.topology_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_id', full_name='context.EndPointId.device_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='endpoint_uuid', full_name='context.EndPointId.endpoint_uuid', 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=3690, - serialized_end=3820, -) - - -_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='endpoint_id', full_name='context.EndPoint.endpoint_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='endpoint_type', full_name='context.EndPoint.endpoint_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='kpi_sample_types', full_name='context.EndPoint.kpi_sample_types', index=2, - number=3, type=14, cpp_type=8, 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=3823, - serialized_end=3957, -) - - -_CONFIGRULE = _descriptor.Descriptor( - name='ConfigRule', - full_name='context.ConfigRule', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='action', full_name='context.ConfigRule.action', 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), - _descriptor.FieldDescriptor( - name='resource_key', full_name='context.ConfigRule.resource_key', 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='resource_value', full_name='context.ConfigRule.resource_value', index=2, - number=3, 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=3959, - serialized_end=4060, -) - - -_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=4062, - serialized_end=4125, -) - - -_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='context_id', full_name='context.TeraFlowController.context_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='ip_address', full_name='context.TeraFlowController.ip_address', 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='port', full_name='context.TeraFlowController.port', index=2, - number=3, type=13, cpp_type=3, 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=4127, - serialized_end=4221, -) - - -_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='context_id', full_name='context.AuthenticationResult.context_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=4223, - serialized_end=4308, -) - -_EVENT.fields_by_name['event_type'].enum_type = _EVENTTYPEENUM -_CONTEXTID.fields_by_name['context_uuid'].message_type = _UUID -_CONTEXT.fields_by_name['context_id'].message_type = _CONTEXTID -_CONTEXT.fields_by_name['topology_ids'].message_type = _TOPOLOGYID -_CONTEXT.fields_by_name['service_ids'].message_type = _SERVICEID -_CONTEXT.fields_by_name['controller'].message_type = _TERAFLOWCONTROLLER -_CONTEXTIDLIST.fields_by_name['context_ids'].message_type = _CONTEXTID -_CONTEXTLIST.fields_by_name['contexts'].message_type = _CONTEXT -_CONTEXTEVENT.fields_by_name['event'].message_type = _EVENT -_CONTEXTEVENT.fields_by_name['context_id'].message_type = _CONTEXTID -_TOPOLOGYID.fields_by_name['context_id'].message_type = _CONTEXTID -_TOPOLOGYID.fields_by_name['topology_uuid'].message_type = _UUID -_TOPOLOGY.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_TOPOLOGY.fields_by_name['device_ids'].message_type = _DEVICEID -_TOPOLOGY.fields_by_name['link_ids'].message_type = _LINKID -_TOPOLOGYIDLIST.fields_by_name['topology_ids'].message_type = _TOPOLOGYID -_TOPOLOGYLIST.fields_by_name['topologies'].message_type = _TOPOLOGY -_TOPOLOGYEVENT.fields_by_name['event'].message_type = _EVENT -_TOPOLOGYEVENT.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_DEVICEID.fields_by_name['device_uuid'].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['device_operational_status'].enum_type = _DEVICEOPERATIONALSTATUSENUM -_DEVICE.fields_by_name['device_drivers'].enum_type = _DEVICEDRIVERENUM -_DEVICE.fields_by_name['device_endpoints'].message_type = _ENDPOINT -_DEVICECONFIG.fields_by_name['config_rules'].message_type = _CONFIGRULE -_DEVICEIDLIST.fields_by_name['device_ids'].message_type = _DEVICEID -_DEVICELIST.fields_by_name['devices'].message_type = _DEVICE -_DEVICEEVENT.fields_by_name['event'].message_type = _EVENT -_DEVICEEVENT.fields_by_name['device_id'].message_type = _DEVICEID -_LINKID.fields_by_name['link_uuid'].message_type = _UUID -_LINK.fields_by_name['link_id'].message_type = _LINKID -_LINK.fields_by_name['link_endpoint_ids'].message_type = _ENDPOINTID -_LINKIDLIST.fields_by_name['link_ids'].message_type = _LINKID -_LINKLIST.fields_by_name['links'].message_type = _LINK -_LINKEVENT.fields_by_name['event'].message_type = _EVENT -_LINKEVENT.fields_by_name['link_id'].message_type = _LINKID -_SERVICEID.fields_by_name['context_id'].message_type = _CONTEXTID -_SERVICEID.fields_by_name['service_uuid'].message_type = _UUID -_SERVICE.fields_by_name['service_id'].message_type = _SERVICEID -_SERVICE.fields_by_name['service_type'].enum_type = _SERVICETYPEENUM -_SERVICE.fields_by_name['service_endpoint_ids'].message_type = _ENDPOINTID -_SERVICE.fields_by_name['service_constraints'].message_type = _CONSTRAINT -_SERVICE.fields_by_name['service_status'].message_type = _SERVICESTATUS -_SERVICE.fields_by_name['service_config'].message_type = _SERVICECONFIG -_SERVICESTATUS.fields_by_name['service_status'].enum_type = _SERVICESTATUSENUM -_SERVICECONFIG.fields_by_name['config_rules'].message_type = _CONFIGRULE -_SERVICEIDLIST.fields_by_name['service_ids'].message_type = _SERVICEID -_SERVICELIST.fields_by_name['services'].message_type = _SERVICE -_SERVICEEVENT.fields_by_name['event'].message_type = _EVENT -_SERVICEEVENT.fields_by_name['service_id'].message_type = _SERVICEID -_SLICEID.fields_by_name['context_id'].message_type = _CONTEXTID -_SLICEID.fields_by_name['slice_uuid'].message_type = _UUID -_SLICE.fields_by_name['slice_id'].message_type = _SLICEID -_SLICE.fields_by_name['slice_endpoint_ids'].message_type = _ENDPOINTID -_SLICE.fields_by_name['slice_constraints'].message_type = _CONSTRAINT -_SLICE.fields_by_name['slice_service_ids'].message_type = _SERVICEID -_SLICE.fields_by_name['slice_subslice_ids'].message_type = _SLICEID -_SLICE.fields_by_name['slice_status'].message_type = _SLICESTATUS -_SLICESTATUS.fields_by_name['slice_status'].enum_type = _SLICESTATUSENUM -_SLICEIDLIST.fields_by_name['slice_ids'].message_type = _SLICEID -_SLICELIST.fields_by_name['slices'].message_type = _SLICE -_SLICEEVENT.fields_by_name['event'].message_type = _EVENT -_SLICEEVENT.fields_by_name['slice_id'].message_type = _SLICEID -_CONNECTIONID.fields_by_name['connection_uuid'].message_type = _UUID -_CONNECTION.fields_by_name['connection_id'].message_type = _CONNECTIONID -_CONNECTION.fields_by_name['service_id'].message_type = _SERVICEID -_CONNECTION.fields_by_name['path_hops_endpoint_ids'].message_type = _ENDPOINTID -_CONNECTION.fields_by_name['sub_service_ids'].message_type = _SERVICEID -_CONNECTIONIDLIST.fields_by_name['connection_ids'].message_type = _CONNECTIONID -_CONNECTIONLIST.fields_by_name['connections'].message_type = _CONNECTION -_CONNECTIONEVENT.fields_by_name['event'].message_type = _EVENT -_CONNECTIONEVENT.fields_by_name['connection_id'].message_type = _CONNECTIONID -_ENDPOINTID.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_ENDPOINTID.fields_by_name['device_id'].message_type = _DEVICEID -_ENDPOINTID.fields_by_name['endpoint_uuid'].message_type = _UUID -_ENDPOINT.fields_by_name['endpoint_id'].message_type = _ENDPOINTID -_ENDPOINT.fields_by_name['kpi_sample_types'].enum_type = kpi__sample__types__pb2._KPISAMPLETYPE -_CONFIGRULE.fields_by_name['action'].enum_type = _CONFIGACTIONENUM -_TERAFLOWCONTROLLER.fields_by_name['context_id'].message_type = _CONTEXTID -_AUTHENTICATIONRESULT.fields_by_name['context_id'].message_type = _CONTEXTID -DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY -DESCRIPTOR.message_types_by_name['Uuid'] = _UUID -DESCRIPTOR.message_types_by_name['Event'] = _EVENT -DESCRIPTOR.message_types_by_name['ContextId'] = _CONTEXTID -DESCRIPTOR.message_types_by_name['Context'] = _CONTEXT -DESCRIPTOR.message_types_by_name['ContextIdList'] = _CONTEXTIDLIST -DESCRIPTOR.message_types_by_name['ContextList'] = _CONTEXTLIST -DESCRIPTOR.message_types_by_name['ContextEvent'] = _CONTEXTEVENT -DESCRIPTOR.message_types_by_name['TopologyId'] = _TOPOLOGYID -DESCRIPTOR.message_types_by_name['Topology'] = _TOPOLOGY -DESCRIPTOR.message_types_by_name['TopologyIdList'] = _TOPOLOGYIDLIST -DESCRIPTOR.message_types_by_name['TopologyList'] = _TOPOLOGYLIST -DESCRIPTOR.message_types_by_name['TopologyEvent'] = _TOPOLOGYEVENT -DESCRIPTOR.message_types_by_name['DeviceId'] = _DEVICEID -DESCRIPTOR.message_types_by_name['Device'] = _DEVICE -DESCRIPTOR.message_types_by_name['DeviceConfig'] = _DEVICECONFIG -DESCRIPTOR.message_types_by_name['DeviceIdList'] = _DEVICEIDLIST -DESCRIPTOR.message_types_by_name['DeviceList'] = _DEVICELIST -DESCRIPTOR.message_types_by_name['DeviceEvent'] = _DEVICEEVENT -DESCRIPTOR.message_types_by_name['LinkId'] = _LINKID -DESCRIPTOR.message_types_by_name['Link'] = _LINK -DESCRIPTOR.message_types_by_name['LinkIdList'] = _LINKIDLIST -DESCRIPTOR.message_types_by_name['LinkList'] = _LINKLIST -DESCRIPTOR.message_types_by_name['LinkEvent'] = _LINKEVENT -DESCRIPTOR.message_types_by_name['ServiceId'] = _SERVICEID -DESCRIPTOR.message_types_by_name['Service'] = _SERVICE -DESCRIPTOR.message_types_by_name['ServiceStatus'] = _SERVICESTATUS -DESCRIPTOR.message_types_by_name['ServiceConfig'] = _SERVICECONFIG -DESCRIPTOR.message_types_by_name['ServiceIdList'] = _SERVICEIDLIST -DESCRIPTOR.message_types_by_name['ServiceList'] = _SERVICELIST -DESCRIPTOR.message_types_by_name['ServiceEvent'] = _SERVICEEVENT -DESCRIPTOR.message_types_by_name['SliceId'] = _SLICEID -DESCRIPTOR.message_types_by_name['Slice'] = _SLICE -DESCRIPTOR.message_types_by_name['SliceStatus'] = _SLICESTATUS -DESCRIPTOR.message_types_by_name['SliceIdList'] = _SLICEIDLIST -DESCRIPTOR.message_types_by_name['SliceList'] = _SLICELIST -DESCRIPTOR.message_types_by_name['SliceEvent'] = _SLICEEVENT -DESCRIPTOR.message_types_by_name['ConnectionId'] = _CONNECTIONID -DESCRIPTOR.message_types_by_name['Connection'] = _CONNECTION -DESCRIPTOR.message_types_by_name['ConnectionIdList'] = _CONNECTIONIDLIST -DESCRIPTOR.message_types_by_name['ConnectionList'] = _CONNECTIONLIST -DESCRIPTOR.message_types_by_name['ConnectionEvent'] = _CONNECTIONEVENT -DESCRIPTOR.message_types_by_name['EndPointId'] = _ENDPOINTID -DESCRIPTOR.message_types_by_name['EndPoint'] = _ENDPOINT -DESCRIPTOR.message_types_by_name['ConfigRule'] = _CONFIGRULE -DESCRIPTOR.message_types_by_name['Constraint'] = _CONSTRAINT -DESCRIPTOR.message_types_by_name['TeraFlowController'] = _TERAFLOWCONTROLLER -DESCRIPTOR.message_types_by_name['AuthenticationResult'] = _AUTHENTICATIONRESULT -DESCRIPTOR.enum_types_by_name['EventTypeEnum'] = _EVENTTYPEENUM -DESCRIPTOR.enum_types_by_name['DeviceDriverEnum'] = _DEVICEDRIVERENUM -DESCRIPTOR.enum_types_by_name['DeviceOperationalStatusEnum'] = _DEVICEOPERATIONALSTATUSENUM -DESCRIPTOR.enum_types_by_name['ServiceTypeEnum'] = _SERVICETYPEENUM -DESCRIPTOR.enum_types_by_name['ServiceStatusEnum'] = _SERVICESTATUSENUM -DESCRIPTOR.enum_types_by_name['SliceStatusEnum'] = _SLICESTATUSENUM -DESCRIPTOR.enum_types_by_name['ConfigActionEnum'] = _CONFIGACTIONENUM -_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) - -Uuid = _reflection.GeneratedProtocolMessageType('Uuid', (_message.Message,), { - 'DESCRIPTOR' : _UUID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Uuid) - }) -_sym_db.RegisterMessage(Uuid) - -Event = _reflection.GeneratedProtocolMessageType('Event', (_message.Message,), { - 'DESCRIPTOR' : _EVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Event) - }) -_sym_db.RegisterMessage(Event) - -ContextId = _reflection.GeneratedProtocolMessageType('ContextId', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextId) - }) -_sym_db.RegisterMessage(ContextId) - -Context = _reflection.GeneratedProtocolMessageType('Context', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Context) - }) -_sym_db.RegisterMessage(Context) - -ContextIdList = _reflection.GeneratedProtocolMessageType('ContextIdList', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextIdList) - }) -_sym_db.RegisterMessage(ContextIdList) - -ContextList = _reflection.GeneratedProtocolMessageType('ContextList', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextList) - }) -_sym_db.RegisterMessage(ContextList) - -ContextEvent = _reflection.GeneratedProtocolMessageType('ContextEvent', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextEvent) - }) -_sym_db.RegisterMessage(ContextEvent) - -TopologyId = _reflection.GeneratedProtocolMessageType('TopologyId', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyId) - }) -_sym_db.RegisterMessage(TopologyId) - -Topology = _reflection.GeneratedProtocolMessageType('Topology', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGY, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Topology) - }) -_sym_db.RegisterMessage(Topology) - -TopologyIdList = _reflection.GeneratedProtocolMessageType('TopologyIdList', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyIdList) - }) -_sym_db.RegisterMessage(TopologyIdList) - -TopologyList = _reflection.GeneratedProtocolMessageType('TopologyList', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyList) - }) -_sym_db.RegisterMessage(TopologyList) - -TopologyEvent = _reflection.GeneratedProtocolMessageType('TopologyEvent', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyEvent) - }) -_sym_db.RegisterMessage(TopologyEvent) - -DeviceId = _reflection.GeneratedProtocolMessageType('DeviceId', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceId) - }) -_sym_db.RegisterMessage(DeviceId) - -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) - -DeviceIdList = _reflection.GeneratedProtocolMessageType('DeviceIdList', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceIdList) - }) -_sym_db.RegisterMessage(DeviceIdList) - -DeviceList = _reflection.GeneratedProtocolMessageType('DeviceList', (_message.Message,), { - 'DESCRIPTOR' : _DEVICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceList) - }) -_sym_db.RegisterMessage(DeviceList) - -DeviceEvent = _reflection.GeneratedProtocolMessageType('DeviceEvent', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceEvent) - }) -_sym_db.RegisterMessage(DeviceEvent) - -LinkId = _reflection.GeneratedProtocolMessageType('LinkId', (_message.Message,), { - 'DESCRIPTOR' : _LINKID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkId) - }) -_sym_db.RegisterMessage(LinkId) - -Link = _reflection.GeneratedProtocolMessageType('Link', (_message.Message,), { - 'DESCRIPTOR' : _LINK, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Link) - }) -_sym_db.RegisterMessage(Link) - -LinkIdList = _reflection.GeneratedProtocolMessageType('LinkIdList', (_message.Message,), { - 'DESCRIPTOR' : _LINKIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkIdList) - }) -_sym_db.RegisterMessage(LinkIdList) - -LinkList = _reflection.GeneratedProtocolMessageType('LinkList', (_message.Message,), { - 'DESCRIPTOR' : _LINKLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkList) - }) -_sym_db.RegisterMessage(LinkList) - -LinkEvent = _reflection.GeneratedProtocolMessageType('LinkEvent', (_message.Message,), { - 'DESCRIPTOR' : _LINKEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkEvent) - }) -_sym_db.RegisterMessage(LinkEvent) - -ServiceId = _reflection.GeneratedProtocolMessageType('ServiceId', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceId) - }) -_sym_db.RegisterMessage(ServiceId) - -Service = _reflection.GeneratedProtocolMessageType('Service', (_message.Message,), { - 'DESCRIPTOR' : _SERVICE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Service) - }) -_sym_db.RegisterMessage(Service) - -ServiceStatus = _reflection.GeneratedProtocolMessageType('ServiceStatus', (_message.Message,), { - 'DESCRIPTOR' : _SERVICESTATUS, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceStatus) - }) -_sym_db.RegisterMessage(ServiceStatus) - -ServiceConfig = _reflection.GeneratedProtocolMessageType('ServiceConfig', (_message.Message,), { - 'DESCRIPTOR' : _SERVICECONFIG, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceConfig) - }) -_sym_db.RegisterMessage(ServiceConfig) - -ServiceIdList = _reflection.GeneratedProtocolMessageType('ServiceIdList', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceIdList) - }) -_sym_db.RegisterMessage(ServiceIdList) - -ServiceList = _reflection.GeneratedProtocolMessageType('ServiceList', (_message.Message,), { - 'DESCRIPTOR' : _SERVICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceList) - }) -_sym_db.RegisterMessage(ServiceList) - -ServiceEvent = _reflection.GeneratedProtocolMessageType('ServiceEvent', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceEvent) - }) -_sym_db.RegisterMessage(ServiceEvent) - -SliceId = _reflection.GeneratedProtocolMessageType('SliceId', (_message.Message,), { - 'DESCRIPTOR' : _SLICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceId) - }) -_sym_db.RegisterMessage(SliceId) - -Slice = _reflection.GeneratedProtocolMessageType('Slice', (_message.Message,), { - 'DESCRIPTOR' : _SLICE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Slice) - }) -_sym_db.RegisterMessage(Slice) - -SliceStatus = _reflection.GeneratedProtocolMessageType('SliceStatus', (_message.Message,), { - 'DESCRIPTOR' : _SLICESTATUS, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceStatus) - }) -_sym_db.RegisterMessage(SliceStatus) - -SliceIdList = _reflection.GeneratedProtocolMessageType('SliceIdList', (_message.Message,), { - 'DESCRIPTOR' : _SLICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceIdList) - }) -_sym_db.RegisterMessage(SliceIdList) - -SliceList = _reflection.GeneratedProtocolMessageType('SliceList', (_message.Message,), { - 'DESCRIPTOR' : _SLICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceList) - }) -_sym_db.RegisterMessage(SliceList) - -SliceEvent = _reflection.GeneratedProtocolMessageType('SliceEvent', (_message.Message,), { - 'DESCRIPTOR' : _SLICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceEvent) - }) -_sym_db.RegisterMessage(SliceEvent) - -ConnectionId = _reflection.GeneratedProtocolMessageType('ConnectionId', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionId) - }) -_sym_db.RegisterMessage(ConnectionId) - -Connection = _reflection.GeneratedProtocolMessageType('Connection', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTION, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Connection) - }) -_sym_db.RegisterMessage(Connection) - -ConnectionIdList = _reflection.GeneratedProtocolMessageType('ConnectionIdList', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionIdList) - }) -_sym_db.RegisterMessage(ConnectionIdList) - -ConnectionList = _reflection.GeneratedProtocolMessageType('ConnectionList', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionList) - }) -_sym_db.RegisterMessage(ConnectionList) - -ConnectionEvent = _reflection.GeneratedProtocolMessageType('ConnectionEvent', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionEvent) - }) -_sym_db.RegisterMessage(ConnectionEvent) - -EndPointId = _reflection.GeneratedProtocolMessageType('EndPointId', (_message.Message,), { - 'DESCRIPTOR' : _ENDPOINTID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.EndPointId) - }) -_sym_db.RegisterMessage(EndPointId) - -EndPoint = _reflection.GeneratedProtocolMessageType('EndPoint', (_message.Message,), { - 'DESCRIPTOR' : _ENDPOINT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.EndPoint) - }) -_sym_db.RegisterMessage(EndPoint) - -ConfigRule = _reflection.GeneratedProtocolMessageType('ConfigRule', (_message.Message,), { - 'DESCRIPTOR' : _CONFIGRULE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConfigRule) - }) -_sym_db.RegisterMessage(ConfigRule) - -Constraint = _reflection.GeneratedProtocolMessageType('Constraint', (_message.Message,), { - 'DESCRIPTOR' : _CONSTRAINT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Constraint) - }) -_sym_db.RegisterMessage(Constraint) - -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=5273, - serialized_end=7688, - methods=[ - _descriptor.MethodDescriptor( - name='ListContextIds', - full_name='context.ContextService.ListContextIds', - index=0, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListContexts', - full_name='context.ContextService.ListContexts', - index=1, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetContext', - full_name='context.ContextService.GetContext', - index=2, - containing_service=None, - input_type=_CONTEXTID, - output_type=_CONTEXT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetContext', - full_name='context.ContextService.SetContext', - index=3, - containing_service=None, - input_type=_CONTEXT, - output_type=_CONTEXTID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveContext', - full_name='context.ContextService.RemoveContext', - index=4, - containing_service=None, - input_type=_CONTEXTID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetContextEvents', - full_name='context.ContextService.GetContextEvents', - index=5, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListTopologyIds', - full_name='context.ContextService.ListTopologyIds', - index=6, - containing_service=None, - input_type=_CONTEXTID, - output_type=_TOPOLOGYIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListTopologies', - full_name='context.ContextService.ListTopologies', - index=7, - containing_service=None, - input_type=_CONTEXTID, - output_type=_TOPOLOGYLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetTopology', - full_name='context.ContextService.GetTopology', - index=8, - containing_service=None, - input_type=_TOPOLOGYID, - output_type=_TOPOLOGY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetTopology', - full_name='context.ContextService.SetTopology', - index=9, - containing_service=None, - input_type=_TOPOLOGY, - output_type=_TOPOLOGYID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveTopology', - full_name='context.ContextService.RemoveTopology', - index=10, - containing_service=None, - input_type=_TOPOLOGYID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetTopologyEvents', - full_name='context.ContextService.GetTopologyEvents', - index=11, - containing_service=None, - input_type=_EMPTY, - output_type=_TOPOLOGYEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListDeviceIds', - full_name='context.ContextService.ListDeviceIds', - index=12, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListDevices', - full_name='context.ContextService.ListDevices', - index=13, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetDevice', - full_name='context.ContextService.GetDevice', - index=14, - containing_service=None, - input_type=_DEVICEID, - output_type=_DEVICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetDevice', - full_name='context.ContextService.SetDevice', - index=15, - containing_service=None, - input_type=_DEVICE, - output_type=_DEVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveDevice', - full_name='context.ContextService.RemoveDevice', - index=16, - containing_service=None, - input_type=_DEVICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetDeviceEvents', - full_name='context.ContextService.GetDeviceEvents', - index=17, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListLinkIds', - full_name='context.ContextService.ListLinkIds', - index=18, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListLinks', - full_name='context.ContextService.ListLinks', - index=19, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetLink', - full_name='context.ContextService.GetLink', - index=20, - containing_service=None, - input_type=_LINKID, - output_type=_LINK, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetLink', - full_name='context.ContextService.SetLink', - index=21, - containing_service=None, - input_type=_LINK, - output_type=_LINKID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveLink', - full_name='context.ContextService.RemoveLink', - index=22, - containing_service=None, - input_type=_LINKID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetLinkEvents', - full_name='context.ContextService.GetLinkEvents', - index=23, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListServiceIds', - full_name='context.ContextService.ListServiceIds', - index=24, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SERVICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListServices', - full_name='context.ContextService.ListServices', - index=25, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SERVICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetService', - full_name='context.ContextService.GetService', - index=26, - containing_service=None, - input_type=_SERVICEID, - output_type=_SERVICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetService', - full_name='context.ContextService.SetService', - index=27, - containing_service=None, - input_type=_SERVICE, - output_type=_SERVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveService', - full_name='context.ContextService.RemoveService', - index=28, - containing_service=None, - input_type=_SERVICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetServiceEvents', - full_name='context.ContextService.GetServiceEvents', - index=29, - containing_service=None, - input_type=_EMPTY, - output_type=_SERVICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListSliceIds', - full_name='context.ContextService.ListSliceIds', - index=30, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SLICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListSlices', - full_name='context.ContextService.ListSlices', - index=31, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SLICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetSlice', - full_name='context.ContextService.GetSlice', - index=32, - containing_service=None, - input_type=_SLICEID, - output_type=_SLICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetSlice', - full_name='context.ContextService.SetSlice', - index=33, - containing_service=None, - input_type=_SLICE, - output_type=_SLICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveSlice', - full_name='context.ContextService.RemoveSlice', - index=34, - containing_service=None, - input_type=_SLICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetSliceEvents', - full_name='context.ContextService.GetSliceEvents', - index=35, - containing_service=None, - input_type=_EMPTY, - output_type=_SLICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListConnectionIds', - full_name='context.ContextService.ListConnectionIds', - index=36, - containing_service=None, - input_type=_SERVICEID, - output_type=_CONNECTIONIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListConnections', - full_name='context.ContextService.ListConnections', - index=37, - containing_service=None, - input_type=_SERVICEID, - output_type=_CONNECTIONLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetConnection', - full_name='context.ContextService.GetConnection', - index=38, - containing_service=None, - input_type=_CONNECTIONID, - output_type=_CONNECTION, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetConnection', - full_name='context.ContextService.SetConnection', - index=39, - containing_service=None, - input_type=_CONNECTION, - output_type=_CONNECTIONID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveConnection', - full_name='context.ContextService.RemoveConnection', - index=40, - containing_service=None, - input_type=_CONNECTIONID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetConnectionEvents', - full_name='context.ContextService.GetConnectionEvents', - index=41, - containing_service=None, - input_type=_EMPTY, - output_type=_CONNECTIONEVENT, - 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/opticalattackmitigator/proto/kpi_sample_types_pb2.py b/src/opticalattackmitigator/proto/kpi_sample_types_pb2.py deleted file mode 100644 index ea7fd2f82757d4c3db02d7e2c7817e2787b0b490..0000000000000000000000000000000000000000 --- a/src/opticalattackmitigator/proto/kpi_sample_types_pb2.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: kpi_sample_types.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='kpi_sample_types.proto', - package='kpi_sample_types', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x16kpi_sample_types.proto\x12\x10kpi_sample_types*\xbe\x01\n\rKpiSampleType\x12\x19\n\x15KPISAMPLETYPE_UNKNOWN\x10\x00\x12%\n!KPISAMPLETYPE_PACKETS_TRANSMITTED\x10\x65\x12\"\n\x1eKPISAMPLETYPE_PACKETS_RECEIVED\x10\x66\x12$\n\x1fKPISAMPLETYPE_BYTES_TRANSMITTED\x10\xc9\x01\x12!\n\x1cKPISAMPLETYPE_BYTES_RECEIVED\x10\xca\x01\x62\x06proto3' -) - -_KPISAMPLETYPE = _descriptor.EnumDescriptor( - name='KpiSampleType', - full_name='kpi_sample_types.KpiSampleType', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_UNKNOWN', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_PACKETS_TRANSMITTED', index=1, number=101, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_PACKETS_RECEIVED', index=2, number=102, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_BYTES_TRANSMITTED', index=3, number=201, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_BYTES_RECEIVED', index=4, number=202, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=45, - serialized_end=235, -) -_sym_db.RegisterEnumDescriptor(_KPISAMPLETYPE) - -KpiSampleType = enum_type_wrapper.EnumTypeWrapper(_KPISAMPLETYPE) -KPISAMPLETYPE_UNKNOWN = 0 -KPISAMPLETYPE_PACKETS_TRANSMITTED = 101 -KPISAMPLETYPE_PACKETS_RECEIVED = 102 -KPISAMPLETYPE_BYTES_TRANSMITTED = 201 -KPISAMPLETYPE_BYTES_RECEIVED = 202 - - -DESCRIPTOR.enum_types_by_name['KpiSampleType'] = _KPISAMPLETYPE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - -# @@protoc_insertion_point(module_scope) diff --git a/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2.py b/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2.py deleted file mode 100644 index 651c1b8e9cff9db06021a4b45934f3676a9f9f5e..0000000000000000000000000000000000000000 --- a/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2.py +++ /dev/null @@ -1,189 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: optical_attack_mitigator.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 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='optical_attack_mitigator.proto', - package='optical_attack_mitigator', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x1eoptical_attack_mitigator.proto\x12\x18optical_attack_mitigator\x1a\rcontext.proto\"t\n\x11\x41ttackDescription\x12\x1c\n\x05\x63s_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\x12\x11\n\tattack_id\x18\x02 \x01(\x05\x12\x12\n\nconfidence\x18\x03 \x01(\x02\x12\x1a\n\x12\x61ttack_description\x18\x04 \x01(\t\"\xa2\x01\n\x0e\x41ttackResponse\x12\x1c\n\x05\x63s_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\x12\x11\n\tattack_id\x18\x02 \x01(\x05\x12\x1a\n\x12\x61ttack_description\x18\x03 \x01(\t\x12\x1c\n\x14response_strategy_id\x18\x04 \x01(\x05\x12%\n\x1dresponse_strategy_description\x18\x05 \x01(\t2z\n\x0f\x41ttackMitigator\x12g\n\x0cNotifyAttack\x12+.optical_attack_mitigator.AttackDescription\x1a(.optical_attack_mitigator.AttackResponse\"\x00\x62\x06proto3' - , - dependencies=[context__pb2.DESCRIPTOR,]) - - - - -_ATTACKDESCRIPTION = _descriptor.Descriptor( - name='AttackDescription', - full_name='optical_attack_mitigator.AttackDescription', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='cs_id', full_name='optical_attack_mitigator.AttackDescription.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='attack_id', full_name='optical_attack_mitigator.AttackDescription.attack_id', index=1, - number=2, type=5, cpp_type=1, 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='confidence', full_name='optical_attack_mitigator.AttackDescription.confidence', index=2, - number=3, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(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='attack_description', full_name='optical_attack_mitigator.AttackDescription.attack_description', index=3, - number=4, 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=75, - serialized_end=191, -) - - -_ATTACKRESPONSE = _descriptor.Descriptor( - name='AttackResponse', - full_name='optical_attack_mitigator.AttackResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='cs_id', full_name='optical_attack_mitigator.AttackResponse.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='attack_id', full_name='optical_attack_mitigator.AttackResponse.attack_id', index=1, - number=2, type=5, cpp_type=1, 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='attack_description', full_name='optical_attack_mitigator.AttackResponse.attack_description', index=2, - number=3, 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='response_strategy_id', full_name='optical_attack_mitigator.AttackResponse.response_strategy_id', index=3, - number=4, type=5, cpp_type=1, 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='response_strategy_description', full_name='optical_attack_mitigator.AttackResponse.response_strategy_description', index=4, - number=5, 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=194, - serialized_end=356, -) - -_ATTACKDESCRIPTION.fields_by_name['cs_id'].message_type = context__pb2._UUID -_ATTACKRESPONSE.fields_by_name['cs_id'].message_type = context__pb2._UUID -DESCRIPTOR.message_types_by_name['AttackDescription'] = _ATTACKDESCRIPTION -DESCRIPTOR.message_types_by_name['AttackResponse'] = _ATTACKRESPONSE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -AttackDescription = _reflection.GeneratedProtocolMessageType('AttackDescription', (_message.Message,), { - 'DESCRIPTOR' : _ATTACKDESCRIPTION, - '__module__' : 'optical_attack_mitigator_pb2' - # @@protoc_insertion_point(class_scope:optical_attack_mitigator.AttackDescription) - }) -_sym_db.RegisterMessage(AttackDescription) - -AttackResponse = _reflection.GeneratedProtocolMessageType('AttackResponse', (_message.Message,), { - 'DESCRIPTOR' : _ATTACKRESPONSE, - '__module__' : 'optical_attack_mitigator_pb2' - # @@protoc_insertion_point(class_scope:optical_attack_mitigator.AttackResponse) - }) -_sym_db.RegisterMessage(AttackResponse) - - - -_ATTACKMITIGATOR = _descriptor.ServiceDescriptor( - name='AttackMitigator', - full_name='optical_attack_mitigator.AttackMitigator', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=358, - serialized_end=480, - methods=[ - _descriptor.MethodDescriptor( - name='NotifyAttack', - full_name='optical_attack_mitigator.AttackMitigator.NotifyAttack', - index=0, - containing_service=None, - input_type=_ATTACKDESCRIPTION, - output_type=_ATTACKRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), -]) -_sym_db.RegisterServiceDescriptor(_ATTACKMITIGATOR) - -DESCRIPTOR.services_by_name['AttackMitigator'] = _ATTACKMITIGATOR - -# @@protoc_insertion_point(module_scope) diff --git a/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2_grpc.py b/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2_grpc.py deleted file mode 100644 index 2f12816a1f909e073ece0ad5a4b3d8fda4235d89..0000000000000000000000000000000000000000 --- a/src/opticalattackmitigator/proto/optical_attack_mitigator_pb2_grpc.py +++ /dev/null @@ -1,66 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from . import optical_attack_mitigator_pb2 as optical__attack__mitigator__pb2 - - -class AttackMitigatorStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.NotifyAttack = channel.unary_unary( - '/optical_attack_mitigator.AttackMitigator/NotifyAttack', - request_serializer=optical__attack__mitigator__pb2.AttackDescription.SerializeToString, - response_deserializer=optical__attack__mitigator__pb2.AttackResponse.FromString, - ) - - -class AttackMitigatorServicer(object): - """Missing associated documentation comment in .proto file.""" - - def NotifyAttack(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_AttackMitigatorServicer_to_server(servicer, server): - rpc_method_handlers = { - 'NotifyAttack': grpc.unary_unary_rpc_method_handler( - servicer.NotifyAttack, - request_deserializer=optical__attack__mitigator__pb2.AttackDescription.FromString, - response_serializer=optical__attack__mitigator__pb2.AttackResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'optical_attack_mitigator.AttackMitigator', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class AttackMitigator(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def NotifyAttack(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, '/optical_attack_mitigator.AttackMitigator/NotifyAttack', - optical__attack__mitigator__pb2.AttackDescription.SerializeToString, - optical__attack__mitigator__pb2.AttackResponse.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/src/opticalattackmitigator/requirements.in b/src/opticalattackmitigator/requirements.in index ea6b450c9c240c76b9f54ce4f3c0c6c25ec62289..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/src/opticalattackmitigator/requirements.in +++ b/src/opticalattackmitigator/requirements.in @@ -1,10 +0,0 @@ -grpcio-health-checking -grpcio -prometheus-client -pytest -pytest-benchmark -redis -# from the monitoring component -influxdb -python-json-logger -coverage diff --git a/src/opticalattackmitigator/service/OpticalAttackMitigatorService.py b/src/opticalattackmitigator/service/OpticalAttackMitigatorService.py index 875276b4ce80335b9eb0081a05d38bfa2c378e43..e1861e940c5ee9ce759a86cb74939592e4e74f3a 100644 --- a/src/opticalattackmitigator/service/OpticalAttackMitigatorService.py +++ b/src/opticalattackmitigator/service/OpticalAttackMitigatorService.py @@ -12,25 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc import logging from concurrent import futures -from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH + +import grpc +from grpc_health.v1.health import OVERALL_HEALTH, HealthServicer from grpc_health.v1.health_pb2 import HealthCheckResponse from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server -from opticalattackmitigator.proto.optical_attack_mitigator_pb2_grpc import ( - add_AttackMitigatorServicer_to_server) -from opticalattackmitigator.service.OpticalAttackMitigatorServiceServicerImpl import ( - OpticalAttackMitigatorServiceServicerImpl) -from opticalattackmitigator.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -BIND_ADDRESS = '0.0.0.0' +from common.Constants import (DEFAULT_GRPC_BIND_ADDRESS, + DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.proto.optical_attack_mitigator_pb2_grpc import \ + add_AttackMitigatorServicer_to_server +from opticalattackmitigator.Config import GRPC_SERVICE_PORT +from opticalattackmitigator.service.OpticalAttackMitigatorServiceServicerImpl import \ + OpticalAttackMitigatorServiceServicerImpl + +BIND_ADDRESS = "0.0.0.0" LOGGER = logging.getLogger(__name__) + class OpticalAttackMitigatorService: def __init__( - self, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, - grace_period=GRPC_GRACE_PERIOD): + self, + address=DEFAULT_GRPC_BIND_ADDRESS, + port=GRPC_SERVICE_PORT, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + ): self.address = address self.port = port @@ -43,30 +53,43 @@ class OpticalAttackMitigatorService: self.server = None def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.debug('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) + self.endpoint = "{:s}:{:s}".format(str(self.address), str(self.port)) + LOGGER.debug( + "Starting Service (tentative endpoint: {:s}, max_workers: {:s})...".format( + str(self.endpoint), str(self.max_workers) + ) + ) self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) + self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.attack_mitigator_servicer = OpticalAttackMitigatorServiceServicerImpl() - add_AttackMitigatorServicer_to_server(self.attack_mitigator_servicer, self.server) + add_AttackMitigatorServicer_to_server( + self.attack_mitigator_servicer, self.server + ) self.health_servicer = HealthServicer( - experimental_non_blocking=True, experimental_thread_pool=futures.ThreadPoolExecutor(max_workers=1)) + 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 = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.format(self.endpoint)) + self.endpoint = "{:s}:{:s}".format(str(self.address), str(port)) + LOGGER.info("Listening on {:s}...".format(self.endpoint)) self.server.start() - self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member + self.health_servicer.set( + OVERALL_HEALTH, HealthCheckResponse.SERVING + ) # pylint: disable=maybe-no-member - LOGGER.debug('Service started') + LOGGER.debug("Service started") def stop(self): - LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) + LOGGER.debug( + "Stopping service (grace period {:s} seconds)...".format( + str(self.grace_period) + ) + ) self.health_servicer.enter_graceful_shutdown() self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') + LOGGER.debug("Service stopped") diff --git a/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py b/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py index 4a2dd041b52eaf89bda65acb7ae1e46beed8c48a..bdf00a6c268aea94319a1a1f23952b552bd0283a 100644 --- a/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py +++ b/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py @@ -12,29 +12,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, grpc, logging, random -from influxdb import InfluxDBClient -from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method -from opticalattackmitigator.proto.optical_attack_mitigator_pb2_grpc import ( - AttackMitigatorServicer) -from opticalattackmitigator.proto.optical_attack_mitigator_pb2 import AttackDescription, AttackResponse +import logging + +import grpc + +from common.proto.optical_attack_mitigator_pb2 import (AttackDescription, + AttackResponse) +from common.proto.optical_attack_mitigator_pb2_grpc import \ + AttackMitigatorServicer +from common.rpc_method_wrapper.Decorator import (create_metrics, + safe_and_metered_rpc_method) LOGGER = logging.getLogger(__name__) -SERVICE_NAME = 'OpticalAttackMitigator' -METHOD_NAMES = ['NotifyAttack'] +SERVICE_NAME = "OpticalAttackMitigator" +METHOD_NAMES = ["NotifyAttack"] METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) class OpticalAttackMitigatorServiceServicerImpl(AttackMitigatorServicer): - def __init__(self): - LOGGER.debug('Creating Servicer...') - LOGGER.debug('Servicer Created') + LOGGER.debug("Creating Servicer...") + LOGGER.debug("Servicer Created") @safe_and_metered_rpc_method(METRICS, LOGGER) - def NotifyAttack(self, request : AttackDescription, context : grpc.ServicerContext) -> AttackResponse: + def NotifyAttack( + self, request: AttackDescription, context: grpc.ServicerContext + ) -> AttackResponse: LOGGER.debug(f"NotifyAttack: {request}") response: AttackResponse = AttackResponse() - response.response_strategy_description = 'The AttackMitigator has received the attack description.' + response.response_strategy_description = ( + "The AttackMitigator has received the attack description." + ) return response diff --git a/src/opticalattackmitigator/service/__init__.py b/src/opticalattackmitigator/service/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalattackmitigator/service/__init__.py +++ b/src/opticalattackmitigator/service/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackmitigator/service/__main__.py b/src/opticalattackmitigator/service/__main__.py index 10b50ac8ba5f5c7a11c5963eb8533bf6d05dfee2..1c37521a52d3357dbf204ecfb9d975c9df12f93c 100644 --- a/src/opticalattackmitigator/service/__main__.py +++ b/src/opticalattackmitigator/service/__main__.py @@ -12,53 +12,77 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, logging, signal, sys, time, threading, multiprocessing +import logging +import signal +import sys +import threading + from prometheus_client import start_http_server -from common.Settings import get_setting -from opticalattackmitigator.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT) -from opticalattackmitigator.service.OpticalAttackMitigatorService import OpticalAttackMitigatorService + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS, ServiceNameEnum) +from common.Settings import (ENVVAR_SUFIX_SERVICE_HOST, + ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, + get_log_level, get_metrics_port, get_setting, + wait_for_environment_variables) +from opticalattackmitigator.Config import GRPC_SERVICE_PORT +from opticalattackmitigator.service.OpticalAttackMitigatorService import \ + OpticalAttackMitigatorService terminate = threading.Event() LOGGER = None -def signal_handler(signal, frame): # pylint: disable=redefined-outer-name - LOGGER.warning('Terminate signal received') + +def signal_handler(signal, frame): # pylint: disable=redefined-outer-name + LOGGER.warning("Terminate signal received") terminate.set() -def main(): - global LOGGER # pylint: disable=global-statement - service_port = get_setting('OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) +def main(): + global LOGGER # pylint: disable=global-statement + log_level = get_log_level() logging.basicConfig(level=log_level) LOGGER = logging.getLogger(__name__) - signal.signal(signal.SIGINT, signal_handler) + wait_for_environment_variables( + [ + get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + ] + ) + + service_port = get_setting( + "OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC", default=GRPC_SERVICE_PORT + ) + max_workers = get_setting("MAX_WORKERS", default=DEFAULT_GRPC_MAX_WORKERS) + grace_period = get_setting("GRACE_PERIOD", default=DEFAULT_GRPC_GRACE_PERIOD) + + signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) - LOGGER.info('Starting...') + LOGGER.info("Starting...") # Start metrics server + metrics_port = get_metrics_port() start_http_server(metrics_port) # Starting CentralizedCybersecurity service grpc_service = OpticalAttackMitigatorService( - port=service_port, max_workers=max_workers, grace_period=grace_period) + port=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 + while not terminate.wait(timeout=0.1): + pass - LOGGER.info('Terminating...') + LOGGER.info("Terminating...") grpc_service.stop() - LOGGER.info('Bye') + LOGGER.info("Bye") return 0 -if __name__ == '__main__': + +if __name__ == "__main__": sys.exit(main()) diff --git a/src/opticalattackmitigator/tests/__init__.py b/src/opticalattackmitigator/tests/__init__.py index 70a33251242c51f49140e596b8208a19dd5245f7..9953c820575d42fa88351cc8de022d880ba96e6a 100644 --- a/src/opticalattackmitigator/tests/__init__.py +++ b/src/opticalattackmitigator/tests/__init__.py @@ -11,4 +11,3 @@ # 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. - diff --git a/src/opticalattackmitigator/tests/test_unitary.py b/src/opticalattackmitigator/tests/test_unitary.py index 74f91a837bf0c83026c88b28ae45f21493a2599d..1369982362f2370aa18852eda3ab9ff01377ad85 100644 --- a/src/opticalattackmitigator/tests/test_unitary.py +++ b/src/opticalattackmitigator/tests/test_unitary.py @@ -12,31 +12,54 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging, pytest -from opticalattackmitigator.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -from opticalattackmitigator.client.OpticalAttackMitigatorClient import OpticalAttackMitigatorClient -from opticalattackmitigator.service.OpticalAttackMitigatorService import OpticalAttackMitigatorService -from opticalattackmitigator.proto.optical_attack_mitigator_pb2 import AttackDescription, AttackResponse +import logging +import os +from unittest.mock import patch -port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports +import pytest + +from common.Constants import (DEFAULT_GRPC_GRACE_PERIOD, + DEFAULT_GRPC_MAX_WORKERS) +from common.proto.optical_attack_mitigator_pb2 import AttackDescription +from opticalattackmitigator.client.OpticalAttackMitigatorClient import \ + OpticalAttackMitigatorClient +from opticalattackmitigator.Config import GRPC_SERVICE_PORT +from opticalattackmitigator.service.OpticalAttackMitigatorService import \ + OpticalAttackMitigatorService + +port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -@pytest.fixture(scope='session') + +@pytest.fixture(scope="session") def optical_attack_mitigator_service(): _service = OpticalAttackMitigatorService( - port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) + port=port, + max_workers=DEFAULT_GRPC_MAX_WORKERS, + grace_period=DEFAULT_GRPC_GRACE_PERIOD, + ) _service.start() yield _service _service.stop() -@pytest.fixture(scope='session') + +@pytest.fixture(scope="session") def optical_attack_mitigator_client(optical_attack_mitigator_service): - _client = OpticalAttackMitigatorClient(address='127.0.0.1', port=port) - yield _client + with patch.dict( + os.environ, + { + "OPTICALATTACKMITIGATORSERVICE_SERVICE_HOST": "127.0.0.1", + "OPTICALATTACKMITIGATORSERVICE_SERVICE_PORT_GRPC": str(port), + }, + clear=True, + ): + _client = OpticalAttackMitigatorClient() + yield _client _client.close() + def test_call_service(optical_attack_mitigator_client: OpticalAttackMitigatorClient): request = AttackDescription() optical_attack_mitigator_client.NotifyAttack(request) diff --git a/src/opticalcentralizedattackdetector/Config.py b/src/opticalcentralizedattackdetector/Config.py deleted file mode 100644 index 5fd3e97e9f590bea9cdfc6ebf8e93e90fb0a4fea..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/Config.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import logging - -# General settings -LOG_LEVEL = logging.DEBUG - -# gRPC settings -GRPC_SERVICE_PORT = 10005 -GRPC_MAX_WORKERS = 10 -GRPC_GRACE_PERIOD = 60 - -# service settings -MONITORING_INTERVAL = 2 # monitoring interval in seconds -#TODO: adjust the addresses below for the specific case -MONITORING_SERVICE_ADDRESS = 'monitoringservice' # address/name of the monitoring service -# MONITORING_SERVICE_ADDRESS = '10.99.41.20' # address/name of the monitoring service -CONTEXT_SERVICE_ADDRESS = 'contextservice' # address/name of the monitoring service -# CONTEXT_SERVICE_ADDRESS = '10.107.199.65' # address/name of the monitoring service -SERVICE_SERVICE_ADDRESS = 'serviceservice' # address/name of the service service -# SERVICE_SERVICE_ADDRESS = '10.99.234.88' # address/name of the service service -# INFERENCE_SERVICE_ADDRESS = '10.108.113.78' # address/name of the inference service -INFERENCE_SERVICE_ADDRESS = 'dbscanservingservice' # address/name of the inference service -# ATTACK_MITIGATOR_SERVICE_ADDRESS = '10.96.248.167' -ATTACK_MITIGATOR_SERVICE_ADDRESS = 'opticalattackmitigatorservice' - -# Prometheus settings -METRICS_PORT = 9192 diff --git a/src/opticalcentralizedattackdetector/Dockerfile b/src/opticalcentralizedattackdetector/Dockerfile deleted file mode 100644 index 190df9beae66e82900a8ab78a12d062e4d319fda..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -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/opticalcentralizedattackdetector - -# Get Python packages per module -COPY opticalcentralizedattackdetector/requirements.in opticalcentralizedattackdetector/requirements.in -RUN pip-compile --output-file=opticalcentralizedattackdetector/requirements.txt opticalcentralizedattackdetector/requirements.in -RUN python3 -m pip install -r opticalcentralizedattackdetector/requirements.txt - -# Add files into working directory -COPY common/. common -COPY context/. context -COPY monitoring/. monitoring -COPY service/. service -COPY dbscanserving/. dbscanserving -COPY opticalattackmitigator/. opticalattackmitigator -COPY opticalcentralizedattackdetector/. opticalcentralizedattackdetector - -ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python - -# Start opticalcentralizedattackdetector service -ENTRYPOINT ["python", "-m", "opticalcentralizedattackdetector.service"] diff --git a/src/opticalcentralizedattackdetector/client/OpticalCentralizedAttackDetectorClient.py b/src/opticalcentralizedattackdetector/client/OpticalCentralizedAttackDetectorClient.py deleted file mode 100644 index cfb78b41ec6a6d5385692813e1a839566d1c90e7..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/client/OpticalCentralizedAttackDetectorClient.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import grpc, logging -from common.tools.client.RetryDecorator import retry, delay_exponential -from opticalcentralizedattackdetector.proto.context_pb2 import Empty, Service -from opticalcentralizedattackdetector.proto.monitoring_pb2 import KpiList -from opticalcentralizedattackdetector.proto.optical_centralized_attack_detector_pb2_grpc import OpticalCentralizedAttackDetectorServiceStub - -LOGGER = logging.getLogger(__name__) -MAX_RETRIES = 15 -DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) -RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') - -class OpticalCentralizedAttackDetectorClient: - def __init__(self, address, port): - 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() - LOGGER.debug('Channel created') - - def connect(self): - self.channel = grpc.insecure_channel(self.endpoint) - self.stub = OpticalCentralizedAttackDetectorServiceStub(self.channel) - - def close(self): - if(self.channel is not None): self.channel.close() - self.channel = None - self.stub = None - - @RETRY_DECORATOR - def NotifyServiceUpdate(self, request : Service) -> Empty: - LOGGER.debug('NotifyServiceUpdate request: {:s}'.format(str(request))) - response = self.stub.NotifyServiceUpdate(request) - LOGGER.debug('NotifyServiceUpdate result: {:s}'.format(str(response))) - return response - - @RETRY_DECORATOR - def DetectAttack(self, request : Empty) -> Empty: - LOGGER.debug('DetectAttack request: {:s}'.format(str(request))) - response = self.stub.DetectAttack(request) - LOGGER.debug('DetectAttack result: {:s}'.format(str(response))) - return response - - @RETRY_DECORATOR - def ReportSummarizedKpi(self, request : KpiList) -> Empty: - LOGGER.debug('ReportSummarizedKpi request: {:s}'.format(str(request))) - response = self.stub.ReportSummarizedKpi(request) - LOGGER.debug('ReportSummarizedKpi result: {:s}'.format(str(response))) - return response - - @RETRY_DECORATOR - def ReportKpi(self, request : KpiList) -> Empty: - LOGGER.debug('ReportKpi request: {:s}'.format(str(request))) - response = self.stub.ReportKpi(request) - LOGGER.debug('ReportKpi result: {:s}'.format(str(response))) - return response diff --git a/src/opticalcentralizedattackdetector/genproto.sh b/src/opticalcentralizedattackdetector/genproto.sh deleted file mode 100755 index 855231cce17081a359cc510423f877d58833430d..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/genproto.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -eu -# -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -# Make folder containing the script the root folder for its execution -cd $(dirname $0) - -rm -rf proto/*.py -rm -rf proto/__pycache__ -tee proto/__init__.py << EOF > /dev/null -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -EOF - -# building protos of services used -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 monitoring.proto -python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto kpi_sample_types.proto - -rm proto/context_pb2_grpc.py -rm proto/service_pb2_grpc.py -rm proto/monitoring_pb2_grpc.py -rm proto/kpi_sample_types_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/monitoring_pb2.py -sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/kpi_sample_types_pb2.py - -# building current service protos -python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto optical_centralized_attack_detector.proto - -sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/optical_centralized_attack_detector_pb2.py -sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/optical_centralized_attack_detector_pb2_grpc.py diff --git a/src/opticalcentralizedattackdetector/proto/__init__.py b/src/opticalcentralizedattackdetector/proto/__init__.py deleted file mode 100644 index 70a33251242c51f49140e596b8208a19dd5245f7..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - diff --git a/src/opticalcentralizedattackdetector/proto/context_pb2.py b/src/opticalcentralizedattackdetector/proto/context_pb2.py deleted file mode 100644 index 50d501d3ac053ad644554331af26e3c40cd426a1..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/context_pb2.py +++ /dev/null @@ -1,3071 +0,0 @@ -# -*- 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() - - -from . import kpi_sample_types_pb2 as kpi__sample__types__pb2 - - -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\x1a\x16kpi_sample_types.proto\"\x07\n\x05\x45mpty\"\x14\n\x04Uuid\x12\x0c\n\x04uuid\x18\x01 \x01(\t\"F\n\x05\x45vent\x12\x11\n\ttimestamp\x18\x01 \x01(\x01\x12*\n\nevent_type\x18\x02 \x01(\x0e\x32\x16.context.EventTypeEnum\"0\n\tContextId\x12#\n\x0c\x63ontext_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\xb6\x01\n\x07\x43ontext\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12)\n\x0ctopology_ids\x18\x02 \x03(\x0b\x32\x13.context.TopologyId\x12\'\n\x0bservice_ids\x18\x03 \x03(\x0b\x32\x12.context.ServiceId\x12/\n\ncontroller\x18\x04 \x01(\x0b\x32\x1b.context.TeraFlowController\"8\n\rContextIdList\x12\'\n\x0b\x63ontext_ids\x18\x01 \x03(\x0b\x32\x12.context.ContextId\"1\n\x0b\x43ontextList\x12\"\n\x08\x63ontexts\x18\x01 \x03(\x0b\x32\x10.context.Context\"U\n\x0c\x43ontextEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12&\n\ncontext_id\x18\x02 \x01(\x0b\x32\x12.context.ContextId\"Z\n\nTopologyId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12$\n\rtopology_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"~\n\x08Topology\x12(\n\x0btopology_id\x18\x01 \x01(\x0b\x32\x13.context.TopologyId\x12%\n\ndevice_ids\x18\x02 \x03(\x0b\x32\x11.context.DeviceId\x12!\n\x08link_ids\x18\x03 \x03(\x0b\x32\x0f.context.LinkId\";\n\x0eTopologyIdList\x12)\n\x0ctopology_ids\x18\x01 \x03(\x0b\x32\x13.context.TopologyId\"5\n\x0cTopologyList\x12%\n\ntopologies\x18\x01 \x03(\x0b\x32\x11.context.Topology\"X\n\rTopologyEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12(\n\x0btopology_id\x18\x02 \x01(\x0b\x32\x13.context.TopologyId\".\n\x08\x44\x65viceId\x12\"\n\x0b\x64\x65vice_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\x9a\x02\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\x12G\n\x19\x64\x65vice_operational_status\x18\x04 \x01(\x0e\x32$.context.DeviceOperationalStatusEnum\x12\x31\n\x0e\x64\x65vice_drivers\x18\x05 \x03(\x0e\x32\x19.context.DeviceDriverEnum\x12+\n\x10\x64\x65vice_endpoints\x18\x06 \x03(\x0b\x32\x11.context.EndPoint\"9\n\x0c\x44\x65viceConfig\x12)\n\x0c\x63onfig_rules\x18\x01 \x03(\x0b\x32\x13.context.ConfigRule\"5\n\x0c\x44\x65viceIdList\x12%\n\ndevice_ids\x18\x01 \x03(\x0b\x32\x11.context.DeviceId\".\n\nDeviceList\x12 \n\x07\x64\x65vices\x18\x01 \x03(\x0b\x32\x0f.context.Device\"R\n\x0b\x44\x65viceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12$\n\tdevice_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\"*\n\x06LinkId\x12 \n\tlink_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"X\n\x04Link\x12 \n\x07link_id\x18\x01 \x01(\x0b\x32\x0f.context.LinkId\x12.\n\x11link_endpoint_ids\x18\x02 \x03(\x0b\x32\x13.context.EndPointId\"/\n\nLinkIdList\x12!\n\x08link_ids\x18\x01 \x03(\x0b\x32\x0f.context.LinkId\"(\n\x08LinkList\x12\x1c\n\x05links\x18\x01 \x03(\x0b\x32\r.context.Link\"L\n\tLinkEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12 \n\x07link_id\x18\x02 \x01(\x0b\x32\x0f.context.LinkId\"X\n\tServiceId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12#\n\x0cservice_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"\xa6\x02\n\x07Service\x12&\n\nservice_id\x18\x01 \x01(\x0b\x32\x12.context.ServiceId\x12.\n\x0cservice_type\x18\x02 \x01(\x0e\x32\x18.context.ServiceTypeEnum\x12\x31\n\x14service_endpoint_ids\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\x12\x30\n\x13service_constraints\x18\x04 \x03(\x0b\x32\x13.context.Constraint\x12.\n\x0eservice_status\x18\x05 \x01(\x0b\x32\x16.context.ServiceStatus\x12.\n\x0eservice_config\x18\x06 \x01(\x0b\x32\x16.context.ServiceConfig\"C\n\rServiceStatus\x12\x32\n\x0eservice_status\x18\x01 \x01(\x0e\x32\x1a.context.ServiceStatusEnum\":\n\rServiceConfig\x12)\n\x0c\x63onfig_rules\x18\x01 \x03(\x0b\x32\x13.context.ConfigRule\"8\n\rServiceIdList\x12\'\n\x0bservice_ids\x18\x01 \x03(\x0b\x32\x12.context.ServiceId\"1\n\x0bServiceList\x12\"\n\x08services\x18\x01 \x03(\x0b\x32\x10.context.Service\"U\n\x0cServiceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12&\n\nservice_id\x18\x02 \x01(\x0b\x32\x12.context.ServiceId\"T\n\x07SliceId\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12!\n\nslice_uuid\x18\x02 \x01(\x0b\x32\r.context.Uuid\"\x95\x02\n\x05Slice\x12\"\n\x08slice_id\x18\x01 \x01(\x0b\x32\x10.context.SliceId\x12/\n\x12slice_endpoint_ids\x18\x02 \x03(\x0b\x32\x13.context.EndPointId\x12.\n\x11slice_constraints\x18\x03 \x03(\x0b\x32\x13.context.Constraint\x12-\n\x11slice_service_ids\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\x12,\n\x12slice_subslice_ids\x18\x05 \x03(\x0b\x32\x10.context.SliceId\x12*\n\x0cslice_status\x18\x06 \x01(\x0b\x32\x14.context.SliceStatus\"=\n\x0bSliceStatus\x12.\n\x0cslice_status\x18\x01 \x01(\x0e\x32\x18.context.SliceStatusEnum\"2\n\x0bSliceIdList\x12#\n\tslice_ids\x18\x01 \x03(\x0b\x32\x10.context.SliceId\"+\n\tSliceList\x12\x1e\n\x06slices\x18\x01 \x03(\x0b\x32\x0e.context.Slice\"O\n\nSliceEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12\"\n\x08slice_id\x18\x02 \x01(\x0b\x32\x10.context.SliceId\"6\n\x0c\x43onnectionId\x12&\n\x0f\x63onnection_uuid\x18\x01 \x01(\x0b\x32\r.context.Uuid\"\xc4\x01\n\nConnection\x12,\n\rconnection_id\x18\x01 \x01(\x0b\x32\x15.context.ConnectionId\x12&\n\nservice_id\x18\x02 \x01(\x0b\x32\x12.context.ServiceId\x12\x33\n\x16path_hops_endpoint_ids\x18\x03 \x03(\x0b\x32\x13.context.EndPointId\x12+\n\x0fsub_service_ids\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\"A\n\x10\x43onnectionIdList\x12-\n\x0e\x63onnection_ids\x18\x01 \x03(\x0b\x32\x15.context.ConnectionId\":\n\x0e\x43onnectionList\x12(\n\x0b\x63onnections\x18\x01 \x03(\x0b\x32\x13.context.Connection\"^\n\x0f\x43onnectionEvent\x12\x1d\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x0e.context.Event\x12,\n\rconnection_id\x18\x02 \x01(\x0b\x32\x15.context.ConnectionId\"\x82\x01\n\nEndPointId\x12(\n\x0btopology_id\x18\x01 \x01(\x0b\x32\x13.context.TopologyId\x12$\n\tdevice_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\x12$\n\rendpoint_uuid\x18\x03 \x01(\x0b\x32\r.context.Uuid\"\x86\x01\n\x08\x45ndPoint\x12(\n\x0b\x65ndpoint_id\x18\x01 \x01(\x0b\x32\x13.context.EndPointId\x12\x15\n\rendpoint_type\x18\x02 \x01(\t\x12\x39\n\x10kpi_sample_types\x18\x03 \x03(\x0e\x32\x1f.kpi_sample_types.KpiSampleType\"e\n\nConfigRule\x12)\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32\x19.context.ConfigActionEnum\x12\x14\n\x0cresource_key\x18\x02 \x01(\t\x12\x16\n\x0eresource_value\x18\x03 \x01(\t\"?\n\nConstraint\x12\x17\n\x0f\x63onstraint_type\x18\x01 \x01(\t\x12\x18\n\x10\x63onstraint_value\x18\x02 \x01(\t\"^\n\x12TeraFlowController\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x12\n\nip_address\x18\x02 \x01(\t\x12\x0c\n\x04port\x18\x03 \x01(\r\"U\n\x14\x41uthenticationResult\x12&\n\ncontext_id\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x15\n\rauthenticated\x18\x02 \x01(\x08*j\n\rEventTypeEnum\x12\x17\n\x13\x45VENTTYPE_UNDEFINED\x10\x00\x12\x14\n\x10\x45VENTTYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENTTYPE_UPDATE\x10\x02\x12\x14\n\x10\x45VENTTYPE_REMOVE\x10\x03*\xc5\x01\n\x10\x44\x65viceDriverEnum\x12\x1a\n\x16\x44\x45VICEDRIVER_UNDEFINED\x10\x00\x12\x1b\n\x17\x44\x45VICEDRIVER_OPENCONFIG\x10\x01\x12\x1e\n\x1a\x44\x45VICEDRIVER_TRANSPORT_API\x10\x02\x12\x13\n\x0f\x44\x45VICEDRIVER_P4\x10\x03\x12&\n\"DEVICEDRIVER_IETF_NETWORK_TOPOLOGY\x10\x04\x12\x1b\n\x17\x44\x45VICEDRIVER_ONF_TR_352\x10\x05*\x8f\x01\n\x1b\x44\x65viceOperationalStatusEnum\x12%\n!DEVICEOPERATIONALSTATUS_UNDEFINED\x10\x00\x12$\n DEVICEOPERATIONALSTATUS_DISABLED\x10\x01\x12#\n\x1f\x44\x45VICEOPERATIONALSTATUS_ENABLED\x10\x02*\x81\x01\n\x0fServiceTypeEnum\x12\x17\n\x13SERVICETYPE_UNKNOWN\x10\x00\x12\x14\n\x10SERVICETYPE_L3NM\x10\x01\x12\x14\n\x10SERVICETYPE_L2NM\x10\x02\x12)\n%SERVICETYPE_TAPI_CONNECTIVITY_SERVICE\x10\x03*\x88\x01\n\x11ServiceStatusEnum\x12\x1b\n\x17SERVICESTATUS_UNDEFINED\x10\x00\x12\x19\n\x15SERVICESTATUS_PLANNED\x10\x01\x12\x18\n\x14SERVICESTATUS_ACTIVE\x10\x02\x12!\n\x1dSERVICESTATUS_PENDING_REMOVAL\x10\x03*\x8b\x01\n\x0fSliceStatusEnum\x12\x19\n\x15SLICESTATUS_UNDEFINED\x10\x00\x12\x17\n\x13SLICESTATUS_PLANNED\x10\x01\x12\x14\n\x10SLICESTATUS_INIT\x10\x02\x12\x16\n\x12SLICESTATUS_ACTIVE\x10\x03\x12\x16\n\x12SLICESTATUS_DEINIT\x10\x04*]\n\x10\x43onfigActionEnum\x12\x1a\n\x16\x43ONFIGACTION_UNDEFINED\x10\x00\x12\x14\n\x10\x43ONFIGACTION_SET\x10\x01\x12\x17\n\x13\x43ONFIGACTION_DELETE\x10\x02\x32\xef\x12\n\x0e\x43ontextService\x12:\n\x0eListContextIds\x12\x0e.context.Empty\x1a\x16.context.ContextIdList\"\x00\x12\x36\n\x0cListContexts\x12\x0e.context.Empty\x1a\x14.context.ContextList\"\x00\x12\x34\n\nGetContext\x12\x12.context.ContextId\x1a\x10.context.Context\"\x00\x12\x34\n\nSetContext\x12\x10.context.Context\x1a\x12.context.ContextId\"\x00\x12\x35\n\rRemoveContext\x12\x12.context.ContextId\x1a\x0e.context.Empty\"\x00\x12=\n\x10GetContextEvents\x12\x0e.context.Empty\x1a\x15.context.ContextEvent\"\x00\x30\x01\x12@\n\x0fListTopologyIds\x12\x12.context.ContextId\x1a\x17.context.TopologyIdList\"\x00\x12=\n\x0eListTopologies\x12\x12.context.ContextId\x1a\x15.context.TopologyList\"\x00\x12\x37\n\x0bGetTopology\x12\x13.context.TopologyId\x1a\x11.context.Topology\"\x00\x12\x37\n\x0bSetTopology\x12\x11.context.Topology\x1a\x13.context.TopologyId\"\x00\x12\x37\n\x0eRemoveTopology\x12\x13.context.TopologyId\x1a\x0e.context.Empty\"\x00\x12?\n\x11GetTopologyEvents\x12\x0e.context.Empty\x1a\x16.context.TopologyEvent\"\x00\x30\x01\x12\x38\n\rListDeviceIds\x12\x0e.context.Empty\x1a\x15.context.DeviceIdList\"\x00\x12\x34\n\x0bListDevices\x12\x0e.context.Empty\x1a\x13.context.DeviceList\"\x00\x12\x31\n\tGetDevice\x12\x11.context.DeviceId\x1a\x0f.context.Device\"\x00\x12\x31\n\tSetDevice\x12\x0f.context.Device\x1a\x11.context.DeviceId\"\x00\x12\x33\n\x0cRemoveDevice\x12\x11.context.DeviceId\x1a\x0e.context.Empty\"\x00\x12;\n\x0fGetDeviceEvents\x12\x0e.context.Empty\x1a\x14.context.DeviceEvent\"\x00\x30\x01\x12\x34\n\x0bListLinkIds\x12\x0e.context.Empty\x1a\x13.context.LinkIdList\"\x00\x12\x30\n\tListLinks\x12\x0e.context.Empty\x1a\x11.context.LinkList\"\x00\x12+\n\x07GetLink\x12\x0f.context.LinkId\x1a\r.context.Link\"\x00\x12+\n\x07SetLink\x12\r.context.Link\x1a\x0f.context.LinkId\"\x00\x12/\n\nRemoveLink\x12\x0f.context.LinkId\x1a\x0e.context.Empty\"\x00\x12\x37\n\rGetLinkEvents\x12\x0e.context.Empty\x1a\x12.context.LinkEvent\"\x00\x30\x01\x12>\n\x0eListServiceIds\x12\x12.context.ContextId\x1a\x16.context.ServiceIdList\"\x00\x12:\n\x0cListServices\x12\x12.context.ContextId\x1a\x14.context.ServiceList\"\x00\x12\x34\n\nGetService\x12\x12.context.ServiceId\x1a\x10.context.Service\"\x00\x12\x34\n\nSetService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x35\n\rRemoveService\x12\x12.context.ServiceId\x1a\x0e.context.Empty\"\x00\x12=\n\x10GetServiceEvents\x12\x0e.context.Empty\x1a\x15.context.ServiceEvent\"\x00\x30\x01\x12:\n\x0cListSliceIds\x12\x12.context.ContextId\x1a\x14.context.SliceIdList\"\x00\x12\x36\n\nListSlices\x12\x12.context.ContextId\x1a\x12.context.SliceList\"\x00\x12.\n\x08GetSlice\x12\x10.context.SliceId\x1a\x0e.context.Slice\"\x00\x12.\n\x08SetSlice\x12\x0e.context.Slice\x1a\x10.context.SliceId\"\x00\x12\x31\n\x0bRemoveSlice\x12\x10.context.SliceId\x1a\x0e.context.Empty\"\x00\x12\x39\n\x0eGetSliceEvents\x12\x0e.context.Empty\x1a\x13.context.SliceEvent\"\x00\x30\x01\x12\x44\n\x11ListConnectionIds\x12\x12.context.ServiceId\x1a\x19.context.ConnectionIdList\"\x00\x12@\n\x0fListConnections\x12\x12.context.ServiceId\x1a\x17.context.ConnectionList\"\x00\x12=\n\rGetConnection\x12\x15.context.ConnectionId\x1a\x13.context.Connection\"\x00\x12=\n\rSetConnection\x12\x13.context.Connection\x1a\x15.context.ConnectionId\"\x00\x12;\n\x10RemoveConnection\x12\x15.context.ConnectionId\x1a\x0e.context.Empty\"\x00\x12\x43\n\x13GetConnectionEvents\x12\x0e.context.Empty\x1a\x18.context.ConnectionEvent\"\x00\x30\x01\x62\x06proto3' - , - dependencies=[kpi__sample__types__pb2.DESCRIPTOR,]) - -_EVENTTYPEENUM = _descriptor.EnumDescriptor( - name='EventTypeEnum', - full_name='context.EventTypeEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_CREATE', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_UPDATE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='EVENTTYPE_REMOVE', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4310, - serialized_end=4416, -) -_sym_db.RegisterEnumDescriptor(_EVENTTYPEENUM) - -EventTypeEnum = enum_type_wrapper.EnumTypeWrapper(_EVENTTYPEENUM) -_DEVICEDRIVERENUM = _descriptor.EnumDescriptor( - name='DeviceDriverEnum', - full_name='context.DeviceDriverEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_OPENCONFIG', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_TRANSPORT_API', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_P4', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_IETF_NETWORK_TOPOLOGY', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEDRIVER_ONF_TR_352', index=5, number=5, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4419, - serialized_end=4616, -) -_sym_db.RegisterEnumDescriptor(_DEVICEDRIVERENUM) - -DeviceDriverEnum = enum_type_wrapper.EnumTypeWrapper(_DEVICEDRIVERENUM) -_DEVICEOPERATIONALSTATUSENUM = _descriptor.EnumDescriptor( - name='DeviceOperationalStatusEnum', - full_name='context.DeviceOperationalStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_DISABLED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='DEVICEOPERATIONALSTATUS_ENABLED', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4619, - serialized_end=4762, -) -_sym_db.RegisterEnumDescriptor(_DEVICEOPERATIONALSTATUSENUM) - -DeviceOperationalStatusEnum = enum_type_wrapper.EnumTypeWrapper(_DEVICEOPERATIONALSTATUSENUM) -_SERVICETYPEENUM = _descriptor.EnumDescriptor( - name='ServiceTypeEnum', - full_name='context.ServiceTypeEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_UNKNOWN', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_L3NM', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_L2NM', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICETYPE_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=4765, - serialized_end=4894, -) -_sym_db.RegisterEnumDescriptor(_SERVICETYPEENUM) - -ServiceTypeEnum = enum_type_wrapper.EnumTypeWrapper(_SERVICETYPEENUM) -_SERVICESTATUSENUM = _descriptor.EnumDescriptor( - name='ServiceStatusEnum', - full_name='context.ServiceStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_PLANNED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_ACTIVE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SERVICESTATUS_PENDING_REMOVAL', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=4897, - serialized_end=5033, -) -_sym_db.RegisterEnumDescriptor(_SERVICESTATUSENUM) - -ServiceStatusEnum = enum_type_wrapper.EnumTypeWrapper(_SERVICESTATUSENUM) -_SLICESTATUSENUM = _descriptor.EnumDescriptor( - name='SliceStatusEnum', - full_name='context.SliceStatusEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_PLANNED', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_INIT', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_ACTIVE', index=3, number=3, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='SLICESTATUS_DEINIT', index=4, number=4, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=5036, - serialized_end=5175, -) -_sym_db.RegisterEnumDescriptor(_SLICESTATUSENUM) - -SliceStatusEnum = enum_type_wrapper.EnumTypeWrapper(_SLICESTATUSENUM) -_CONFIGACTIONENUM = _descriptor.EnumDescriptor( - name='ConfigActionEnum', - full_name='context.ConfigActionEnum', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_UNDEFINED', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_SET', index=1, number=1, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='CONFIGACTION_DELETE', index=2, number=2, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=5177, - serialized_end=5270, -) -_sym_db.RegisterEnumDescriptor(_CONFIGACTIONENUM) - -ConfigActionEnum = enum_type_wrapper.EnumTypeWrapper(_CONFIGACTIONENUM) -EVENTTYPE_UNDEFINED = 0 -EVENTTYPE_CREATE = 1 -EVENTTYPE_UPDATE = 2 -EVENTTYPE_REMOVE = 3 -DEVICEDRIVER_UNDEFINED = 0 -DEVICEDRIVER_OPENCONFIG = 1 -DEVICEDRIVER_TRANSPORT_API = 2 -DEVICEDRIVER_P4 = 3 -DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4 -DEVICEDRIVER_ONF_TR_352 = 5 -DEVICEOPERATIONALSTATUS_UNDEFINED = 0 -DEVICEOPERATIONALSTATUS_DISABLED = 1 -DEVICEOPERATIONALSTATUS_ENABLED = 2 -SERVICETYPE_UNKNOWN = 0 -SERVICETYPE_L3NM = 1 -SERVICETYPE_L2NM = 2 -SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3 -SERVICESTATUS_UNDEFINED = 0 -SERVICESTATUS_PLANNED = 1 -SERVICESTATUS_ACTIVE = 2 -SERVICESTATUS_PENDING_REMOVAL = 3 -SLICESTATUS_UNDEFINED = 0 -SLICESTATUS_PLANNED = 1 -SLICESTATUS_INIT = 2 -SLICESTATUS_ACTIVE = 3 -SLICESTATUS_DEINIT = 4 -CONFIGACTION_UNDEFINED = 0 -CONFIGACTION_SET = 1 -CONFIGACTION_DELETE = 2 - - - -_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=50, - serialized_end=57, -) - - -_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=59, - serialized_end=79, -) - - -_EVENT = _descriptor.Descriptor( - name='Event', - full_name='context.Event', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='timestamp', full_name='context.Event.timestamp', index=0, - number=1, type=1, cpp_type=5, label=1, - has_default_value=False, default_value=float(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='event_type', full_name='context.Event.event_type', 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), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=81, - serialized_end=151, -) - - -_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='context_uuid', full_name='context.ContextId.context_uuid', 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=153, - serialized_end=201, -) - - -_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='context_id', full_name='context.Context.context_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='topology_ids', full_name='context.Context.topology_ids', 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), - _descriptor.FieldDescriptor( - name='service_ids', full_name='context.Context.service_ids', 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='controller', full_name='context.Context.controller', index=3, - number=4, 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=204, - serialized_end=386, -) - - -_CONTEXTIDLIST = _descriptor.Descriptor( - name='ContextIdList', - full_name='context.ContextIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_ids', full_name='context.ContextIdList.context_ids', 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=388, - serialized_end=444, -) - - -_CONTEXTLIST = _descriptor.Descriptor( - name='ContextList', - full_name='context.ContextList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='contexts', full_name='context.ContextList.contexts', 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=446, - serialized_end=495, -) - - -_CONTEXTEVENT = _descriptor.Descriptor( - name='ContextEvent', - full_name='context.ContextEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ContextEvent.event', 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='context_id', full_name='context.ContextEvent.context_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=497, - serialized_end=582, -) - - -_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='context_id', full_name='context.TopologyId.context_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='topology_uuid', full_name='context.TopologyId.topology_uuid', 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=584, - serialized_end=674, -) - - -_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='topology_id', full_name='context.Topology.topology_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_ids', full_name='context.Topology.device_ids', 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), - _descriptor.FieldDescriptor( - name='link_ids', full_name='context.Topology.link_ids', 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=676, - serialized_end=802, -) - - -_TOPOLOGYIDLIST = _descriptor.Descriptor( - name='TopologyIdList', - full_name='context.TopologyIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='topology_ids', full_name='context.TopologyIdList.topology_ids', 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=804, - serialized_end=863, -) - - -_TOPOLOGYLIST = _descriptor.Descriptor( - name='TopologyList', - full_name='context.TopologyList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='topologies', full_name='context.TopologyList.topologies', 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=865, - serialized_end=918, -) - - -_TOPOLOGYEVENT = _descriptor.Descriptor( - name='TopologyEvent', - full_name='context.TopologyEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.TopologyEvent.event', 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='topology_id', full_name='context.TopologyEvent.topology_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=920, - serialized_end=1008, -) - - -_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_uuid', full_name='context.DeviceId.device_uuid', 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=1010, - serialized_end=1056, -) - - -_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='device_operational_status', full_name='context.Device.device_operational_status', 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='device_drivers', full_name='context.Device.device_drivers', index=4, - number=5, type=14, cpp_type=8, 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='device_endpoints', full_name='context.Device.device_endpoints', index=5, - number=6, 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=1059, - serialized_end=1341, -) - - -_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='config_rules', full_name='context.DeviceConfig.config_rules', 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=1343, - serialized_end=1400, -) - - -_DEVICEIDLIST = _descriptor.Descriptor( - name='DeviceIdList', - full_name='context.DeviceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='device_ids', full_name='context.DeviceIdList.device_ids', 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=1402, - serialized_end=1455, -) - - -_DEVICELIST = _descriptor.Descriptor( - name='DeviceList', - full_name='context.DeviceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='devices', full_name='context.DeviceList.devices', 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=1457, - serialized_end=1503, -) - - -_DEVICEEVENT = _descriptor.Descriptor( - name='DeviceEvent', - full_name='context.DeviceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.DeviceEvent.event', 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_id', full_name='context.DeviceEvent.device_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=1505, - serialized_end=1587, -) - - -_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_uuid', full_name='context.LinkId.link_uuid', 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=1589, - serialized_end=1631, -) - - -_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='link_endpoint_ids', full_name='context.Link.link_endpoint_ids', 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=1633, - serialized_end=1721, -) - - -_LINKIDLIST = _descriptor.Descriptor( - name='LinkIdList', - full_name='context.LinkIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='link_ids', full_name='context.LinkIdList.link_ids', 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=1723, - serialized_end=1770, -) - - -_LINKLIST = _descriptor.Descriptor( - name='LinkList', - full_name='context.LinkList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='links', full_name='context.LinkList.links', 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=1772, - serialized_end=1812, -) - - -_LINKEVENT = _descriptor.Descriptor( - name='LinkEvent', - full_name='context.LinkEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.LinkEvent.event', 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='link_id', full_name='context.LinkEvent.link_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=1814, - serialized_end=1890, -) - - -_SERVICEID = _descriptor.Descriptor( - name='ServiceId', - full_name='context.ServiceId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_id', full_name='context.ServiceId.context_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='service_uuid', full_name='context.ServiceId.service_uuid', 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=1892, - serialized_end=1980, -) - - -_SERVICE = _descriptor.Descriptor( - name='Service', - full_name='context.Service', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_id', full_name='context.Service.service_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='service_type', full_name='context.Service.service_type', 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='service_endpoint_ids', full_name='context.Service.service_endpoint_ids', 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='service_constraints', full_name='context.Service.service_constraints', 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='service_status', full_name='context.Service.service_status', 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='service_config', full_name='context.Service.service_config', 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=1983, - serialized_end=2277, -) - - -_SERVICESTATUS = _descriptor.Descriptor( - name='ServiceStatus', - full_name='context.ServiceStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_status', full_name='context.ServiceStatus.service_status', 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=2279, - serialized_end=2346, -) - - -_SERVICECONFIG = _descriptor.Descriptor( - name='ServiceConfig', - full_name='context.ServiceConfig', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='config_rules', full_name='context.ServiceConfig.config_rules', 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=2348, - serialized_end=2406, -) - - -_SERVICEIDLIST = _descriptor.Descriptor( - name='ServiceIdList', - full_name='context.ServiceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='service_ids', full_name='context.ServiceIdList.service_ids', 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=2408, - serialized_end=2464, -) - - -_SERVICELIST = _descriptor.Descriptor( - name='ServiceList', - full_name='context.ServiceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='services', full_name='context.ServiceList.services', 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=2466, - serialized_end=2515, -) - - -_SERVICEEVENT = _descriptor.Descriptor( - name='ServiceEvent', - full_name='context.ServiceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ServiceEvent.event', 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='service_id', full_name='context.ServiceEvent.service_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=2517, - serialized_end=2602, -) - - -_SLICEID = _descriptor.Descriptor( - name='SliceId', - full_name='context.SliceId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='context_id', full_name='context.SliceId.context_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='slice_uuid', full_name='context.SliceId.slice_uuid', 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=2604, - serialized_end=2688, -) - - -_SLICE = _descriptor.Descriptor( - name='Slice', - full_name='context.Slice', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_id', full_name='context.Slice.slice_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='slice_endpoint_ids', full_name='context.Slice.slice_endpoint_ids', 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), - _descriptor.FieldDescriptor( - name='slice_constraints', full_name='context.Slice.slice_constraints', 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='slice_service_ids', full_name='context.Slice.slice_service_ids', 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='slice_subslice_ids', full_name='context.Slice.slice_subslice_ids', 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), - _descriptor.FieldDescriptor( - name='slice_status', full_name='context.Slice.slice_status', 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=2691, - serialized_end=2968, -) - - -_SLICESTATUS = _descriptor.Descriptor( - name='SliceStatus', - full_name='context.SliceStatus', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_status', full_name='context.SliceStatus.slice_status', 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=2970, - serialized_end=3031, -) - - -_SLICEIDLIST = _descriptor.Descriptor( - name='SliceIdList', - full_name='context.SliceIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slice_ids', full_name='context.SliceIdList.slice_ids', 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=3033, - serialized_end=3083, -) - - -_SLICELIST = _descriptor.Descriptor( - name='SliceList', - full_name='context.SliceList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='slices', full_name='context.SliceList.slices', 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=3085, - serialized_end=3128, -) - - -_SLICEEVENT = _descriptor.Descriptor( - name='SliceEvent', - full_name='context.SliceEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.SliceEvent.event', 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='slice_id', full_name='context.SliceEvent.slice_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=3130, - serialized_end=3209, -) - - -_CONNECTIONID = _descriptor.Descriptor( - name='ConnectionId', - full_name='context.ConnectionId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_uuid', full_name='context.ConnectionId.connection_uuid', 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=3211, - serialized_end=3265, -) - - -_CONNECTION = _descriptor.Descriptor( - name='Connection', - full_name='context.Connection', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_id', full_name='context.Connection.connection_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='service_id', full_name='context.Connection.service_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='path_hops_endpoint_ids', full_name='context.Connection.path_hops_endpoint_ids', 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='sub_service_ids', full_name='context.Connection.sub_service_ids', 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), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3268, - serialized_end=3464, -) - - -_CONNECTIONIDLIST = _descriptor.Descriptor( - name='ConnectionIdList', - full_name='context.ConnectionIdList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connection_ids', full_name='context.ConnectionIdList.connection_ids', 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=3466, - serialized_end=3531, -) - - -_CONNECTIONLIST = _descriptor.Descriptor( - name='ConnectionList', - full_name='context.ConnectionList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='connections', full_name='context.ConnectionList.connections', 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=3533, - serialized_end=3591, -) - - -_CONNECTIONEVENT = _descriptor.Descriptor( - name='ConnectionEvent', - full_name='context.ConnectionEvent', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='event', full_name='context.ConnectionEvent.event', 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='connection_id', full_name='context.ConnectionEvent.connection_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=3593, - serialized_end=3687, -) - - -_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='topology_id', full_name='context.EndPointId.topology_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_id', full_name='context.EndPointId.device_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='endpoint_uuid', full_name='context.EndPointId.endpoint_uuid', 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=3690, - serialized_end=3820, -) - - -_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='endpoint_id', full_name='context.EndPoint.endpoint_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='endpoint_type', full_name='context.EndPoint.endpoint_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='kpi_sample_types', full_name='context.EndPoint.kpi_sample_types', index=2, - number=3, type=14, cpp_type=8, 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=3823, - serialized_end=3957, -) - - -_CONFIGRULE = _descriptor.Descriptor( - name='ConfigRule', - full_name='context.ConfigRule', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='action', full_name='context.ConfigRule.action', 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), - _descriptor.FieldDescriptor( - name='resource_key', full_name='context.ConfigRule.resource_key', 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='resource_value', full_name='context.ConfigRule.resource_value', index=2, - number=3, 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=3959, - serialized_end=4060, -) - - -_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=4062, - serialized_end=4125, -) - - -_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='context_id', full_name='context.TeraFlowController.context_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='ip_address', full_name='context.TeraFlowController.ip_address', 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='port', full_name='context.TeraFlowController.port', index=2, - number=3, type=13, cpp_type=3, 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=4127, - serialized_end=4221, -) - - -_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='context_id', full_name='context.AuthenticationResult.context_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=4223, - serialized_end=4308, -) - -_EVENT.fields_by_name['event_type'].enum_type = _EVENTTYPEENUM -_CONTEXTID.fields_by_name['context_uuid'].message_type = _UUID -_CONTEXT.fields_by_name['context_id'].message_type = _CONTEXTID -_CONTEXT.fields_by_name['topology_ids'].message_type = _TOPOLOGYID -_CONTEXT.fields_by_name['service_ids'].message_type = _SERVICEID -_CONTEXT.fields_by_name['controller'].message_type = _TERAFLOWCONTROLLER -_CONTEXTIDLIST.fields_by_name['context_ids'].message_type = _CONTEXTID -_CONTEXTLIST.fields_by_name['contexts'].message_type = _CONTEXT -_CONTEXTEVENT.fields_by_name['event'].message_type = _EVENT -_CONTEXTEVENT.fields_by_name['context_id'].message_type = _CONTEXTID -_TOPOLOGYID.fields_by_name['context_id'].message_type = _CONTEXTID -_TOPOLOGYID.fields_by_name['topology_uuid'].message_type = _UUID -_TOPOLOGY.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_TOPOLOGY.fields_by_name['device_ids'].message_type = _DEVICEID -_TOPOLOGY.fields_by_name['link_ids'].message_type = _LINKID -_TOPOLOGYIDLIST.fields_by_name['topology_ids'].message_type = _TOPOLOGYID -_TOPOLOGYLIST.fields_by_name['topologies'].message_type = _TOPOLOGY -_TOPOLOGYEVENT.fields_by_name['event'].message_type = _EVENT -_TOPOLOGYEVENT.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_DEVICEID.fields_by_name['device_uuid'].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['device_operational_status'].enum_type = _DEVICEOPERATIONALSTATUSENUM -_DEVICE.fields_by_name['device_drivers'].enum_type = _DEVICEDRIVERENUM -_DEVICE.fields_by_name['device_endpoints'].message_type = _ENDPOINT -_DEVICECONFIG.fields_by_name['config_rules'].message_type = _CONFIGRULE -_DEVICEIDLIST.fields_by_name['device_ids'].message_type = _DEVICEID -_DEVICELIST.fields_by_name['devices'].message_type = _DEVICE -_DEVICEEVENT.fields_by_name['event'].message_type = _EVENT -_DEVICEEVENT.fields_by_name['device_id'].message_type = _DEVICEID -_LINKID.fields_by_name['link_uuid'].message_type = _UUID -_LINK.fields_by_name['link_id'].message_type = _LINKID -_LINK.fields_by_name['link_endpoint_ids'].message_type = _ENDPOINTID -_LINKIDLIST.fields_by_name['link_ids'].message_type = _LINKID -_LINKLIST.fields_by_name['links'].message_type = _LINK -_LINKEVENT.fields_by_name['event'].message_type = _EVENT -_LINKEVENT.fields_by_name['link_id'].message_type = _LINKID -_SERVICEID.fields_by_name['context_id'].message_type = _CONTEXTID -_SERVICEID.fields_by_name['service_uuid'].message_type = _UUID -_SERVICE.fields_by_name['service_id'].message_type = _SERVICEID -_SERVICE.fields_by_name['service_type'].enum_type = _SERVICETYPEENUM -_SERVICE.fields_by_name['service_endpoint_ids'].message_type = _ENDPOINTID -_SERVICE.fields_by_name['service_constraints'].message_type = _CONSTRAINT -_SERVICE.fields_by_name['service_status'].message_type = _SERVICESTATUS -_SERVICE.fields_by_name['service_config'].message_type = _SERVICECONFIG -_SERVICESTATUS.fields_by_name['service_status'].enum_type = _SERVICESTATUSENUM -_SERVICECONFIG.fields_by_name['config_rules'].message_type = _CONFIGRULE -_SERVICEIDLIST.fields_by_name['service_ids'].message_type = _SERVICEID -_SERVICELIST.fields_by_name['services'].message_type = _SERVICE -_SERVICEEVENT.fields_by_name['event'].message_type = _EVENT -_SERVICEEVENT.fields_by_name['service_id'].message_type = _SERVICEID -_SLICEID.fields_by_name['context_id'].message_type = _CONTEXTID -_SLICEID.fields_by_name['slice_uuid'].message_type = _UUID -_SLICE.fields_by_name['slice_id'].message_type = _SLICEID -_SLICE.fields_by_name['slice_endpoint_ids'].message_type = _ENDPOINTID -_SLICE.fields_by_name['slice_constraints'].message_type = _CONSTRAINT -_SLICE.fields_by_name['slice_service_ids'].message_type = _SERVICEID -_SLICE.fields_by_name['slice_subslice_ids'].message_type = _SLICEID -_SLICE.fields_by_name['slice_status'].message_type = _SLICESTATUS -_SLICESTATUS.fields_by_name['slice_status'].enum_type = _SLICESTATUSENUM -_SLICEIDLIST.fields_by_name['slice_ids'].message_type = _SLICEID -_SLICELIST.fields_by_name['slices'].message_type = _SLICE -_SLICEEVENT.fields_by_name['event'].message_type = _EVENT -_SLICEEVENT.fields_by_name['slice_id'].message_type = _SLICEID -_CONNECTIONID.fields_by_name['connection_uuid'].message_type = _UUID -_CONNECTION.fields_by_name['connection_id'].message_type = _CONNECTIONID -_CONNECTION.fields_by_name['service_id'].message_type = _SERVICEID -_CONNECTION.fields_by_name['path_hops_endpoint_ids'].message_type = _ENDPOINTID -_CONNECTION.fields_by_name['sub_service_ids'].message_type = _SERVICEID -_CONNECTIONIDLIST.fields_by_name['connection_ids'].message_type = _CONNECTIONID -_CONNECTIONLIST.fields_by_name['connections'].message_type = _CONNECTION -_CONNECTIONEVENT.fields_by_name['event'].message_type = _EVENT -_CONNECTIONEVENT.fields_by_name['connection_id'].message_type = _CONNECTIONID -_ENDPOINTID.fields_by_name['topology_id'].message_type = _TOPOLOGYID -_ENDPOINTID.fields_by_name['device_id'].message_type = _DEVICEID -_ENDPOINTID.fields_by_name['endpoint_uuid'].message_type = _UUID -_ENDPOINT.fields_by_name['endpoint_id'].message_type = _ENDPOINTID -_ENDPOINT.fields_by_name['kpi_sample_types'].enum_type = kpi__sample__types__pb2._KPISAMPLETYPE -_CONFIGRULE.fields_by_name['action'].enum_type = _CONFIGACTIONENUM -_TERAFLOWCONTROLLER.fields_by_name['context_id'].message_type = _CONTEXTID -_AUTHENTICATIONRESULT.fields_by_name['context_id'].message_type = _CONTEXTID -DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY -DESCRIPTOR.message_types_by_name['Uuid'] = _UUID -DESCRIPTOR.message_types_by_name['Event'] = _EVENT -DESCRIPTOR.message_types_by_name['ContextId'] = _CONTEXTID -DESCRIPTOR.message_types_by_name['Context'] = _CONTEXT -DESCRIPTOR.message_types_by_name['ContextIdList'] = _CONTEXTIDLIST -DESCRIPTOR.message_types_by_name['ContextList'] = _CONTEXTLIST -DESCRIPTOR.message_types_by_name['ContextEvent'] = _CONTEXTEVENT -DESCRIPTOR.message_types_by_name['TopologyId'] = _TOPOLOGYID -DESCRIPTOR.message_types_by_name['Topology'] = _TOPOLOGY -DESCRIPTOR.message_types_by_name['TopologyIdList'] = _TOPOLOGYIDLIST -DESCRIPTOR.message_types_by_name['TopologyList'] = _TOPOLOGYLIST -DESCRIPTOR.message_types_by_name['TopologyEvent'] = _TOPOLOGYEVENT -DESCRIPTOR.message_types_by_name['DeviceId'] = _DEVICEID -DESCRIPTOR.message_types_by_name['Device'] = _DEVICE -DESCRIPTOR.message_types_by_name['DeviceConfig'] = _DEVICECONFIG -DESCRIPTOR.message_types_by_name['DeviceIdList'] = _DEVICEIDLIST -DESCRIPTOR.message_types_by_name['DeviceList'] = _DEVICELIST -DESCRIPTOR.message_types_by_name['DeviceEvent'] = _DEVICEEVENT -DESCRIPTOR.message_types_by_name['LinkId'] = _LINKID -DESCRIPTOR.message_types_by_name['Link'] = _LINK -DESCRIPTOR.message_types_by_name['LinkIdList'] = _LINKIDLIST -DESCRIPTOR.message_types_by_name['LinkList'] = _LINKLIST -DESCRIPTOR.message_types_by_name['LinkEvent'] = _LINKEVENT -DESCRIPTOR.message_types_by_name['ServiceId'] = _SERVICEID -DESCRIPTOR.message_types_by_name['Service'] = _SERVICE -DESCRIPTOR.message_types_by_name['ServiceStatus'] = _SERVICESTATUS -DESCRIPTOR.message_types_by_name['ServiceConfig'] = _SERVICECONFIG -DESCRIPTOR.message_types_by_name['ServiceIdList'] = _SERVICEIDLIST -DESCRIPTOR.message_types_by_name['ServiceList'] = _SERVICELIST -DESCRIPTOR.message_types_by_name['ServiceEvent'] = _SERVICEEVENT -DESCRIPTOR.message_types_by_name['SliceId'] = _SLICEID -DESCRIPTOR.message_types_by_name['Slice'] = _SLICE -DESCRIPTOR.message_types_by_name['SliceStatus'] = _SLICESTATUS -DESCRIPTOR.message_types_by_name['SliceIdList'] = _SLICEIDLIST -DESCRIPTOR.message_types_by_name['SliceList'] = _SLICELIST -DESCRIPTOR.message_types_by_name['SliceEvent'] = _SLICEEVENT -DESCRIPTOR.message_types_by_name['ConnectionId'] = _CONNECTIONID -DESCRIPTOR.message_types_by_name['Connection'] = _CONNECTION -DESCRIPTOR.message_types_by_name['ConnectionIdList'] = _CONNECTIONIDLIST -DESCRIPTOR.message_types_by_name['ConnectionList'] = _CONNECTIONLIST -DESCRIPTOR.message_types_by_name['ConnectionEvent'] = _CONNECTIONEVENT -DESCRIPTOR.message_types_by_name['EndPointId'] = _ENDPOINTID -DESCRIPTOR.message_types_by_name['EndPoint'] = _ENDPOINT -DESCRIPTOR.message_types_by_name['ConfigRule'] = _CONFIGRULE -DESCRIPTOR.message_types_by_name['Constraint'] = _CONSTRAINT -DESCRIPTOR.message_types_by_name['TeraFlowController'] = _TERAFLOWCONTROLLER -DESCRIPTOR.message_types_by_name['AuthenticationResult'] = _AUTHENTICATIONRESULT -DESCRIPTOR.enum_types_by_name['EventTypeEnum'] = _EVENTTYPEENUM -DESCRIPTOR.enum_types_by_name['DeviceDriverEnum'] = _DEVICEDRIVERENUM -DESCRIPTOR.enum_types_by_name['DeviceOperationalStatusEnum'] = _DEVICEOPERATIONALSTATUSENUM -DESCRIPTOR.enum_types_by_name['ServiceTypeEnum'] = _SERVICETYPEENUM -DESCRIPTOR.enum_types_by_name['ServiceStatusEnum'] = _SERVICESTATUSENUM -DESCRIPTOR.enum_types_by_name['SliceStatusEnum'] = _SLICESTATUSENUM -DESCRIPTOR.enum_types_by_name['ConfigActionEnum'] = _CONFIGACTIONENUM -_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) - -Uuid = _reflection.GeneratedProtocolMessageType('Uuid', (_message.Message,), { - 'DESCRIPTOR' : _UUID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Uuid) - }) -_sym_db.RegisterMessage(Uuid) - -Event = _reflection.GeneratedProtocolMessageType('Event', (_message.Message,), { - 'DESCRIPTOR' : _EVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Event) - }) -_sym_db.RegisterMessage(Event) - -ContextId = _reflection.GeneratedProtocolMessageType('ContextId', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextId) - }) -_sym_db.RegisterMessage(ContextId) - -Context = _reflection.GeneratedProtocolMessageType('Context', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Context) - }) -_sym_db.RegisterMessage(Context) - -ContextIdList = _reflection.GeneratedProtocolMessageType('ContextIdList', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextIdList) - }) -_sym_db.RegisterMessage(ContextIdList) - -ContextList = _reflection.GeneratedProtocolMessageType('ContextList', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextList) - }) -_sym_db.RegisterMessage(ContextList) - -ContextEvent = _reflection.GeneratedProtocolMessageType('ContextEvent', (_message.Message,), { - 'DESCRIPTOR' : _CONTEXTEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ContextEvent) - }) -_sym_db.RegisterMessage(ContextEvent) - -TopologyId = _reflection.GeneratedProtocolMessageType('TopologyId', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyId) - }) -_sym_db.RegisterMessage(TopologyId) - -Topology = _reflection.GeneratedProtocolMessageType('Topology', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGY, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Topology) - }) -_sym_db.RegisterMessage(Topology) - -TopologyIdList = _reflection.GeneratedProtocolMessageType('TopologyIdList', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyIdList) - }) -_sym_db.RegisterMessage(TopologyIdList) - -TopologyList = _reflection.GeneratedProtocolMessageType('TopologyList', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyList) - }) -_sym_db.RegisterMessage(TopologyList) - -TopologyEvent = _reflection.GeneratedProtocolMessageType('TopologyEvent', (_message.Message,), { - 'DESCRIPTOR' : _TOPOLOGYEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.TopologyEvent) - }) -_sym_db.RegisterMessage(TopologyEvent) - -DeviceId = _reflection.GeneratedProtocolMessageType('DeviceId', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceId) - }) -_sym_db.RegisterMessage(DeviceId) - -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) - -DeviceIdList = _reflection.GeneratedProtocolMessageType('DeviceIdList', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceIdList) - }) -_sym_db.RegisterMessage(DeviceIdList) - -DeviceList = _reflection.GeneratedProtocolMessageType('DeviceList', (_message.Message,), { - 'DESCRIPTOR' : _DEVICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceList) - }) -_sym_db.RegisterMessage(DeviceList) - -DeviceEvent = _reflection.GeneratedProtocolMessageType('DeviceEvent', (_message.Message,), { - 'DESCRIPTOR' : _DEVICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.DeviceEvent) - }) -_sym_db.RegisterMessage(DeviceEvent) - -LinkId = _reflection.GeneratedProtocolMessageType('LinkId', (_message.Message,), { - 'DESCRIPTOR' : _LINKID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkId) - }) -_sym_db.RegisterMessage(LinkId) - -Link = _reflection.GeneratedProtocolMessageType('Link', (_message.Message,), { - 'DESCRIPTOR' : _LINK, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Link) - }) -_sym_db.RegisterMessage(Link) - -LinkIdList = _reflection.GeneratedProtocolMessageType('LinkIdList', (_message.Message,), { - 'DESCRIPTOR' : _LINKIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkIdList) - }) -_sym_db.RegisterMessage(LinkIdList) - -LinkList = _reflection.GeneratedProtocolMessageType('LinkList', (_message.Message,), { - 'DESCRIPTOR' : _LINKLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkList) - }) -_sym_db.RegisterMessage(LinkList) - -LinkEvent = _reflection.GeneratedProtocolMessageType('LinkEvent', (_message.Message,), { - 'DESCRIPTOR' : _LINKEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.LinkEvent) - }) -_sym_db.RegisterMessage(LinkEvent) - -ServiceId = _reflection.GeneratedProtocolMessageType('ServiceId', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceId) - }) -_sym_db.RegisterMessage(ServiceId) - -Service = _reflection.GeneratedProtocolMessageType('Service', (_message.Message,), { - 'DESCRIPTOR' : _SERVICE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Service) - }) -_sym_db.RegisterMessage(Service) - -ServiceStatus = _reflection.GeneratedProtocolMessageType('ServiceStatus', (_message.Message,), { - 'DESCRIPTOR' : _SERVICESTATUS, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceStatus) - }) -_sym_db.RegisterMessage(ServiceStatus) - -ServiceConfig = _reflection.GeneratedProtocolMessageType('ServiceConfig', (_message.Message,), { - 'DESCRIPTOR' : _SERVICECONFIG, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceConfig) - }) -_sym_db.RegisterMessage(ServiceConfig) - -ServiceIdList = _reflection.GeneratedProtocolMessageType('ServiceIdList', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceIdList) - }) -_sym_db.RegisterMessage(ServiceIdList) - -ServiceList = _reflection.GeneratedProtocolMessageType('ServiceList', (_message.Message,), { - 'DESCRIPTOR' : _SERVICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceList) - }) -_sym_db.RegisterMessage(ServiceList) - -ServiceEvent = _reflection.GeneratedProtocolMessageType('ServiceEvent', (_message.Message,), { - 'DESCRIPTOR' : _SERVICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ServiceEvent) - }) -_sym_db.RegisterMessage(ServiceEvent) - -SliceId = _reflection.GeneratedProtocolMessageType('SliceId', (_message.Message,), { - 'DESCRIPTOR' : _SLICEID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceId) - }) -_sym_db.RegisterMessage(SliceId) - -Slice = _reflection.GeneratedProtocolMessageType('Slice', (_message.Message,), { - 'DESCRIPTOR' : _SLICE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Slice) - }) -_sym_db.RegisterMessage(Slice) - -SliceStatus = _reflection.GeneratedProtocolMessageType('SliceStatus', (_message.Message,), { - 'DESCRIPTOR' : _SLICESTATUS, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceStatus) - }) -_sym_db.RegisterMessage(SliceStatus) - -SliceIdList = _reflection.GeneratedProtocolMessageType('SliceIdList', (_message.Message,), { - 'DESCRIPTOR' : _SLICEIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceIdList) - }) -_sym_db.RegisterMessage(SliceIdList) - -SliceList = _reflection.GeneratedProtocolMessageType('SliceList', (_message.Message,), { - 'DESCRIPTOR' : _SLICELIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceList) - }) -_sym_db.RegisterMessage(SliceList) - -SliceEvent = _reflection.GeneratedProtocolMessageType('SliceEvent', (_message.Message,), { - 'DESCRIPTOR' : _SLICEEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.SliceEvent) - }) -_sym_db.RegisterMessage(SliceEvent) - -ConnectionId = _reflection.GeneratedProtocolMessageType('ConnectionId', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionId) - }) -_sym_db.RegisterMessage(ConnectionId) - -Connection = _reflection.GeneratedProtocolMessageType('Connection', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTION, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Connection) - }) -_sym_db.RegisterMessage(Connection) - -ConnectionIdList = _reflection.GeneratedProtocolMessageType('ConnectionIdList', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONIDLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionIdList) - }) -_sym_db.RegisterMessage(ConnectionIdList) - -ConnectionList = _reflection.GeneratedProtocolMessageType('ConnectionList', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONLIST, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionList) - }) -_sym_db.RegisterMessage(ConnectionList) - -ConnectionEvent = _reflection.GeneratedProtocolMessageType('ConnectionEvent', (_message.Message,), { - 'DESCRIPTOR' : _CONNECTIONEVENT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConnectionEvent) - }) -_sym_db.RegisterMessage(ConnectionEvent) - -EndPointId = _reflection.GeneratedProtocolMessageType('EndPointId', (_message.Message,), { - 'DESCRIPTOR' : _ENDPOINTID, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.EndPointId) - }) -_sym_db.RegisterMessage(EndPointId) - -EndPoint = _reflection.GeneratedProtocolMessageType('EndPoint', (_message.Message,), { - 'DESCRIPTOR' : _ENDPOINT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.EndPoint) - }) -_sym_db.RegisterMessage(EndPoint) - -ConfigRule = _reflection.GeneratedProtocolMessageType('ConfigRule', (_message.Message,), { - 'DESCRIPTOR' : _CONFIGRULE, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.ConfigRule) - }) -_sym_db.RegisterMessage(ConfigRule) - -Constraint = _reflection.GeneratedProtocolMessageType('Constraint', (_message.Message,), { - 'DESCRIPTOR' : _CONSTRAINT, - '__module__' : 'context_pb2' - # @@protoc_insertion_point(class_scope:context.Constraint) - }) -_sym_db.RegisterMessage(Constraint) - -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=5273, - serialized_end=7688, - methods=[ - _descriptor.MethodDescriptor( - name='ListContextIds', - full_name='context.ContextService.ListContextIds', - index=0, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListContexts', - full_name='context.ContextService.ListContexts', - index=1, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetContext', - full_name='context.ContextService.GetContext', - index=2, - containing_service=None, - input_type=_CONTEXTID, - output_type=_CONTEXT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetContext', - full_name='context.ContextService.SetContext', - index=3, - containing_service=None, - input_type=_CONTEXT, - output_type=_CONTEXTID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveContext', - full_name='context.ContextService.RemoveContext', - index=4, - containing_service=None, - input_type=_CONTEXTID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetContextEvents', - full_name='context.ContextService.GetContextEvents', - index=5, - containing_service=None, - input_type=_EMPTY, - output_type=_CONTEXTEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListTopologyIds', - full_name='context.ContextService.ListTopologyIds', - index=6, - containing_service=None, - input_type=_CONTEXTID, - output_type=_TOPOLOGYIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListTopologies', - full_name='context.ContextService.ListTopologies', - index=7, - containing_service=None, - input_type=_CONTEXTID, - output_type=_TOPOLOGYLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetTopology', - full_name='context.ContextService.GetTopology', - index=8, - containing_service=None, - input_type=_TOPOLOGYID, - output_type=_TOPOLOGY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetTopology', - full_name='context.ContextService.SetTopology', - index=9, - containing_service=None, - input_type=_TOPOLOGY, - output_type=_TOPOLOGYID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveTopology', - full_name='context.ContextService.RemoveTopology', - index=10, - containing_service=None, - input_type=_TOPOLOGYID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetTopologyEvents', - full_name='context.ContextService.GetTopologyEvents', - index=11, - containing_service=None, - input_type=_EMPTY, - output_type=_TOPOLOGYEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListDeviceIds', - full_name='context.ContextService.ListDeviceIds', - index=12, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListDevices', - full_name='context.ContextService.ListDevices', - index=13, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetDevice', - full_name='context.ContextService.GetDevice', - index=14, - containing_service=None, - input_type=_DEVICEID, - output_type=_DEVICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetDevice', - full_name='context.ContextService.SetDevice', - index=15, - containing_service=None, - input_type=_DEVICE, - output_type=_DEVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveDevice', - full_name='context.ContextService.RemoveDevice', - index=16, - containing_service=None, - input_type=_DEVICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetDeviceEvents', - full_name='context.ContextService.GetDeviceEvents', - index=17, - containing_service=None, - input_type=_EMPTY, - output_type=_DEVICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListLinkIds', - full_name='context.ContextService.ListLinkIds', - index=18, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListLinks', - full_name='context.ContextService.ListLinks', - index=19, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetLink', - full_name='context.ContextService.GetLink', - index=20, - containing_service=None, - input_type=_LINKID, - output_type=_LINK, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetLink', - full_name='context.ContextService.SetLink', - index=21, - containing_service=None, - input_type=_LINK, - output_type=_LINKID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveLink', - full_name='context.ContextService.RemoveLink', - index=22, - containing_service=None, - input_type=_LINKID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetLinkEvents', - full_name='context.ContextService.GetLinkEvents', - index=23, - containing_service=None, - input_type=_EMPTY, - output_type=_LINKEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListServiceIds', - full_name='context.ContextService.ListServiceIds', - index=24, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SERVICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListServices', - full_name='context.ContextService.ListServices', - index=25, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SERVICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetService', - full_name='context.ContextService.GetService', - index=26, - containing_service=None, - input_type=_SERVICEID, - output_type=_SERVICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetService', - full_name='context.ContextService.SetService', - index=27, - containing_service=None, - input_type=_SERVICE, - output_type=_SERVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveService', - full_name='context.ContextService.RemoveService', - index=28, - containing_service=None, - input_type=_SERVICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetServiceEvents', - full_name='context.ContextService.GetServiceEvents', - index=29, - containing_service=None, - input_type=_EMPTY, - output_type=_SERVICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListSliceIds', - full_name='context.ContextService.ListSliceIds', - index=30, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SLICEIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListSlices', - full_name='context.ContextService.ListSlices', - index=31, - containing_service=None, - input_type=_CONTEXTID, - output_type=_SLICELIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetSlice', - full_name='context.ContextService.GetSlice', - index=32, - containing_service=None, - input_type=_SLICEID, - output_type=_SLICE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetSlice', - full_name='context.ContextService.SetSlice', - index=33, - containing_service=None, - input_type=_SLICE, - output_type=_SLICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveSlice', - full_name='context.ContextService.RemoveSlice', - index=34, - containing_service=None, - input_type=_SLICEID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetSliceEvents', - full_name='context.ContextService.GetSliceEvents', - index=35, - containing_service=None, - input_type=_EMPTY, - output_type=_SLICEEVENT, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListConnectionIds', - full_name='context.ContextService.ListConnectionIds', - index=36, - containing_service=None, - input_type=_SERVICEID, - output_type=_CONNECTIONIDLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ListConnections', - full_name='context.ContextService.ListConnections', - index=37, - containing_service=None, - input_type=_SERVICEID, - output_type=_CONNECTIONLIST, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetConnection', - full_name='context.ContextService.GetConnection', - index=38, - containing_service=None, - input_type=_CONNECTIONID, - output_type=_CONNECTION, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='SetConnection', - full_name='context.ContextService.SetConnection', - index=39, - containing_service=None, - input_type=_CONNECTION, - output_type=_CONNECTIONID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='RemoveConnection', - full_name='context.ContextService.RemoveConnection', - index=40, - containing_service=None, - input_type=_CONNECTIONID, - output_type=_EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetConnectionEvents', - full_name='context.ContextService.GetConnectionEvents', - index=41, - containing_service=None, - input_type=_EMPTY, - output_type=_CONNECTIONEVENT, - 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/opticalcentralizedattackdetector/proto/kpi_sample_types_pb2.py b/src/opticalcentralizedattackdetector/proto/kpi_sample_types_pb2.py deleted file mode 100644 index ea7fd2f82757d4c3db02d7e2c7817e2787b0b490..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/kpi_sample_types_pb2.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: kpi_sample_types.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='kpi_sample_types.proto', - package='kpi_sample_types', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x16kpi_sample_types.proto\x12\x10kpi_sample_types*\xbe\x01\n\rKpiSampleType\x12\x19\n\x15KPISAMPLETYPE_UNKNOWN\x10\x00\x12%\n!KPISAMPLETYPE_PACKETS_TRANSMITTED\x10\x65\x12\"\n\x1eKPISAMPLETYPE_PACKETS_RECEIVED\x10\x66\x12$\n\x1fKPISAMPLETYPE_BYTES_TRANSMITTED\x10\xc9\x01\x12!\n\x1cKPISAMPLETYPE_BYTES_RECEIVED\x10\xca\x01\x62\x06proto3' -) - -_KPISAMPLETYPE = _descriptor.EnumDescriptor( - name='KpiSampleType', - full_name='kpi_sample_types.KpiSampleType', - filename=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - values=[ - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_UNKNOWN', index=0, number=0, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_PACKETS_TRANSMITTED', index=1, number=101, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_PACKETS_RECEIVED', index=2, number=102, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_BYTES_TRANSMITTED', index=3, number=201, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - _descriptor.EnumValueDescriptor( - name='KPISAMPLETYPE_BYTES_RECEIVED', index=4, number=202, - serialized_options=None, - type=None, - create_key=_descriptor._internal_create_key), - ], - containing_type=None, - serialized_options=None, - serialized_start=45, - serialized_end=235, -) -_sym_db.RegisterEnumDescriptor(_KPISAMPLETYPE) - -KpiSampleType = enum_type_wrapper.EnumTypeWrapper(_KPISAMPLETYPE) -KPISAMPLETYPE_UNKNOWN = 0 -KPISAMPLETYPE_PACKETS_TRANSMITTED = 101 -KPISAMPLETYPE_PACKETS_RECEIVED = 102 -KPISAMPLETYPE_BYTES_TRANSMITTED = 201 -KPISAMPLETYPE_BYTES_RECEIVED = 202 - - -DESCRIPTOR.enum_types_by_name['KpiSampleType'] = _KPISAMPLETYPE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - -# @@protoc_insertion_point(module_scope) diff --git a/src/opticalcentralizedattackdetector/proto/monitoring_pb2.py b/src/opticalcentralizedattackdetector/proto/monitoring_pb2.py deleted file mode 100644 index b313ebb68f0da37a540898e8c362fd204a799076..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/monitoring_pb2.py +++ /dev/null @@ -1,452 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: monitoring.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 kpi_sample_types_pb2 as kpi__sample__types__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='monitoring.proto', - package='monitoring', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x10monitoring.proto\x12\nmonitoring\x1a\rcontext.proto\x1a\x16kpi_sample_types.proto\"\xda\x01\n\rKpiDescriptor\x12\x17\n\x0fkpi_description\x18\x01 \x01(\t\x12\x38\n\x0fkpi_sample_type\x18\x02 \x01(\x0e\x32\x1f.kpi_sample_types.KpiSampleType\x12$\n\tdevice_id\x18\x03 \x01(\x0b\x32\x11.context.DeviceId\x12(\n\x0b\x65ndpoint_id\x18\x04 \x01(\x0b\x32\x13.context.EndPointId\x12&\n\nservice_id\x18\x05 \x01(\x0b\x32\x12.context.ServiceId\"p\n\x11MonitorKpiRequest\x12!\n\x06kpi_id\x18\x01 \x01(\x0b\x32\x11.monitoring.KpiId\x12\x1b\n\x13sampling_duration_s\x18\x02 \x01(\x02\x12\x1b\n\x13sampling_interval_s\x18\x03 \x01(\x02\"&\n\x05KpiId\x12\x1d\n\x06kpi_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\"d\n\x03Kpi\x12!\n\x06kpi_id\x18\x01 \x01(\x0b\x32\x11.monitoring.KpiId\x12\x11\n\ttimestamp\x18\x02 \x01(\t\x12\'\n\tkpi_value\x18\x04 \x01(\x0b\x32\x14.monitoring.KpiValue\"a\n\x08KpiValue\x12\x10\n\x06intVal\x18\x01 \x01(\rH\x00\x12\x12\n\x08\x66loatVal\x18\x02 \x01(\x02H\x00\x12\x13\n\tstringVal\x18\x03 \x01(\tH\x00\x12\x11\n\x07\x62oolVal\x18\x04 \x01(\x08H\x00\x42\x07\n\x05value\",\n\x07KpiList\x12!\n\x08kpi_list\x18\x01 \x03(\x0b\x32\x0f.monitoring.Kpi2\xf3\x02\n\x11MonitoringService\x12;\n\tCreateKpi\x12\x19.monitoring.KpiDescriptor\x1a\x11.monitoring.KpiId\"\x00\x12\x42\n\x10GetKpiDescriptor\x12\x11.monitoring.KpiId\x1a\x19.monitoring.KpiDescriptor\"\x00\x12/\n\nIncludeKpi\x12\x0f.monitoring.Kpi\x1a\x0e.context.Empty\"\x00\x12=\n\nMonitorKpi\x12\x1d.monitoring.MonitorKpiRequest\x1a\x0e.context.Empty\"\x00\x12\x36\n\x0cGetStreamKpi\x12\x11.monitoring.KpiId\x1a\x0f.monitoring.Kpi\"\x00\x30\x01\x12\x35\n\rGetInstantKpi\x12\x11.monitoring.KpiId\x1a\x0f.monitoring.Kpi\"\x00\x62\x06proto3' - , - dependencies=[context__pb2.DESCRIPTOR,kpi__sample__types__pb2.DESCRIPTOR,]) - - - - -_KPIDESCRIPTOR = _descriptor.Descriptor( - name='KpiDescriptor', - full_name='monitoring.KpiDescriptor', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='kpi_description', full_name='monitoring.KpiDescriptor.kpi_description', 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='kpi_sample_type', full_name='monitoring.KpiDescriptor.kpi_sample_type', 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='device_id', full_name='monitoring.KpiDescriptor.device_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), - _descriptor.FieldDescriptor( - name='endpoint_id', full_name='monitoring.KpiDescriptor.endpoint_id', index=3, - number=4, 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='service_id', full_name='monitoring.KpiDescriptor.service_id', 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), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=72, - serialized_end=290, -) - - -_MONITORKPIREQUEST = _descriptor.Descriptor( - name='MonitorKpiRequest', - full_name='monitoring.MonitorKpiRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='kpi_id', full_name='monitoring.MonitorKpiRequest.kpi_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='sampling_duration_s', full_name='monitoring.MonitorKpiRequest.sampling_duration_s', index=1, - number=2, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(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='sampling_interval_s', full_name='monitoring.MonitorKpiRequest.sampling_interval_s', index=2, - number=3, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(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=292, - serialized_end=404, -) - - -_KPIID = _descriptor.Descriptor( - name='KpiId', - full_name='monitoring.KpiId', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='kpi_id', full_name='monitoring.KpiId.kpi_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=406, - serialized_end=444, -) - - -_KPI = _descriptor.Descriptor( - name='Kpi', - full_name='monitoring.Kpi', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='kpi_id', full_name='monitoring.Kpi.kpi_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='timestamp', full_name='monitoring.Kpi.timestamp', 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='kpi_value', full_name='monitoring.Kpi.kpi_value', index=2, - number=4, 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=446, - serialized_end=546, -) - - -_KPIVALUE = _descriptor.Descriptor( - name='KpiValue', - full_name='monitoring.KpiValue', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='intVal', full_name='monitoring.KpiValue.intVal', index=0, - number=1, type=13, cpp_type=3, 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='floatVal', full_name='monitoring.KpiValue.floatVal', index=1, - number=2, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(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='stringVal', full_name='monitoring.KpiValue.stringVal', index=2, - number=3, 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='boolVal', full_name='monitoring.KpiValue.boolVal', index=3, - number=4, 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=[ - _descriptor.OneofDescriptor( - name='value', full_name='monitoring.KpiValue.value', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=548, - serialized_end=645, -) - - -_KPILIST = _descriptor.Descriptor( - name='KpiList', - full_name='monitoring.KpiList', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='kpi_list', full_name='monitoring.KpiList.kpi_list', 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=647, - serialized_end=691, -) - -_KPIDESCRIPTOR.fields_by_name['kpi_sample_type'].enum_type = kpi__sample__types__pb2._KPISAMPLETYPE -_KPIDESCRIPTOR.fields_by_name['device_id'].message_type = context__pb2._DEVICEID -_KPIDESCRIPTOR.fields_by_name['endpoint_id'].message_type = context__pb2._ENDPOINTID -_KPIDESCRIPTOR.fields_by_name['service_id'].message_type = context__pb2._SERVICEID -_MONITORKPIREQUEST.fields_by_name['kpi_id'].message_type = _KPIID -_KPIID.fields_by_name['kpi_id'].message_type = context__pb2._UUID -_KPI.fields_by_name['kpi_id'].message_type = _KPIID -_KPI.fields_by_name['kpi_value'].message_type = _KPIVALUE -_KPIVALUE.oneofs_by_name['value'].fields.append( - _KPIVALUE.fields_by_name['intVal']) -_KPIVALUE.fields_by_name['intVal'].containing_oneof = _KPIVALUE.oneofs_by_name['value'] -_KPIVALUE.oneofs_by_name['value'].fields.append( - _KPIVALUE.fields_by_name['floatVal']) -_KPIVALUE.fields_by_name['floatVal'].containing_oneof = _KPIVALUE.oneofs_by_name['value'] -_KPIVALUE.oneofs_by_name['value'].fields.append( - _KPIVALUE.fields_by_name['stringVal']) -_KPIVALUE.fields_by_name['stringVal'].containing_oneof = _KPIVALUE.oneofs_by_name['value'] -_KPIVALUE.oneofs_by_name['value'].fields.append( - _KPIVALUE.fields_by_name['boolVal']) -_KPIVALUE.fields_by_name['boolVal'].containing_oneof = _KPIVALUE.oneofs_by_name['value'] -_KPILIST.fields_by_name['kpi_list'].message_type = _KPI -DESCRIPTOR.message_types_by_name['KpiDescriptor'] = _KPIDESCRIPTOR -DESCRIPTOR.message_types_by_name['MonitorKpiRequest'] = _MONITORKPIREQUEST -DESCRIPTOR.message_types_by_name['KpiId'] = _KPIID -DESCRIPTOR.message_types_by_name['Kpi'] = _KPI -DESCRIPTOR.message_types_by_name['KpiValue'] = _KPIVALUE -DESCRIPTOR.message_types_by_name['KpiList'] = _KPILIST -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -KpiDescriptor = _reflection.GeneratedProtocolMessageType('KpiDescriptor', (_message.Message,), { - 'DESCRIPTOR' : _KPIDESCRIPTOR, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.KpiDescriptor) - }) -_sym_db.RegisterMessage(KpiDescriptor) - -MonitorKpiRequest = _reflection.GeneratedProtocolMessageType('MonitorKpiRequest', (_message.Message,), { - 'DESCRIPTOR' : _MONITORKPIREQUEST, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.MonitorKpiRequest) - }) -_sym_db.RegisterMessage(MonitorKpiRequest) - -KpiId = _reflection.GeneratedProtocolMessageType('KpiId', (_message.Message,), { - 'DESCRIPTOR' : _KPIID, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.KpiId) - }) -_sym_db.RegisterMessage(KpiId) - -Kpi = _reflection.GeneratedProtocolMessageType('Kpi', (_message.Message,), { - 'DESCRIPTOR' : _KPI, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.Kpi) - }) -_sym_db.RegisterMessage(Kpi) - -KpiValue = _reflection.GeneratedProtocolMessageType('KpiValue', (_message.Message,), { - 'DESCRIPTOR' : _KPIVALUE, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.KpiValue) - }) -_sym_db.RegisterMessage(KpiValue) - -KpiList = _reflection.GeneratedProtocolMessageType('KpiList', (_message.Message,), { - 'DESCRIPTOR' : _KPILIST, - '__module__' : 'monitoring_pb2' - # @@protoc_insertion_point(class_scope:monitoring.KpiList) - }) -_sym_db.RegisterMessage(KpiList) - - - -_MONITORINGSERVICE = _descriptor.ServiceDescriptor( - name='MonitoringService', - full_name='monitoring.MonitoringService', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=694, - serialized_end=1065, - methods=[ - _descriptor.MethodDescriptor( - name='CreateKpi', - full_name='monitoring.MonitoringService.CreateKpi', - index=0, - containing_service=None, - input_type=_KPIDESCRIPTOR, - output_type=_KPIID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetKpiDescriptor', - full_name='monitoring.MonitoringService.GetKpiDescriptor', - index=1, - containing_service=None, - input_type=_KPIID, - output_type=_KPIDESCRIPTOR, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='IncludeKpi', - full_name='monitoring.MonitoringService.IncludeKpi', - index=2, - containing_service=None, - input_type=_KPI, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='MonitorKpi', - full_name='monitoring.MonitoringService.MonitorKpi', - index=3, - containing_service=None, - input_type=_MONITORKPIREQUEST, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetStreamKpi', - full_name='monitoring.MonitoringService.GetStreamKpi', - index=4, - containing_service=None, - input_type=_KPIID, - output_type=_KPI, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='GetInstantKpi', - full_name='monitoring.MonitoringService.GetInstantKpi', - index=5, - containing_service=None, - input_type=_KPIID, - output_type=_KPI, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), -]) -_sym_db.RegisterServiceDescriptor(_MONITORINGSERVICE) - -DESCRIPTOR.services_by_name['MonitoringService'] = _MONITORINGSERVICE - -# @@protoc_insertion_point(module_scope) diff --git a/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2.py b/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2.py deleted file mode 100644 index b97a93fef290a5d27c2369d3b69d1405ea8a6442..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2.py +++ /dev/null @@ -1,89 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: optical_centralized_attack_detector.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 monitoring_pb2 as monitoring__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name='optical_centralized_attack_detector.proto', - package='centralized_attack_detector', - syntax='proto3', - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n)optical_centralized_attack_detector.proto\x12\x1b\x63\x65ntralized_attack_detector\x1a\rcontext.proto\x1a\x10monitoring.proto2\x88\x02\n\'OpticalCentralizedAttackDetectorService\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,monitoring__pb2.DESCRIPTOR,]) - - - -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - - -_OPTICALCENTRALIZEDATTACKDETECTORSERVICE = _descriptor.ServiceDescriptor( - name='OpticalCentralizedAttackDetectorService', - full_name='centralized_attack_detector.OpticalCentralizedAttackDetectorService', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=108, - serialized_end=372, - methods=[ - _descriptor.MethodDescriptor( - name='NotifyServiceUpdate', - full_name='centralized_attack_detector.OpticalCentralizedAttackDetectorService.NotifyServiceUpdate', - index=0, - containing_service=None, - input_type=context__pb2._SERVICE, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='DetectAttack', - full_name='centralized_attack_detector.OpticalCentralizedAttackDetectorService.DetectAttack', - index=1, - containing_service=None, - input_type=context__pb2._EMPTY, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ReportSummarizedKpi', - full_name='centralized_attack_detector.OpticalCentralizedAttackDetectorService.ReportSummarizedKpi', - index=2, - containing_service=None, - input_type=monitoring__pb2._KPILIST, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='ReportKpi', - full_name='centralized_attack_detector.OpticalCentralizedAttackDetectorService.ReportKpi', - index=3, - containing_service=None, - input_type=monitoring__pb2._KPILIST, - output_type=context__pb2._EMPTY, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), -]) -_sym_db.RegisterServiceDescriptor(_OPTICALCENTRALIZEDATTACKDETECTORSERVICE) - -DESCRIPTOR.services_by_name['OpticalCentralizedAttackDetectorService'] = _OPTICALCENTRALIZEDATTACKDETECTORSERVICE - -# @@protoc_insertion_point(module_scope) diff --git a/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2_grpc.py b/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2_grpc.py deleted file mode 100644 index 17b839fa3bbaafb8ecfa795db21ba6baba8cd28b..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/optical_centralized_attack_detector_pb2_grpc.py +++ /dev/null @@ -1,168 +0,0 @@ -# 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 monitoring_pb2 as monitoring__pb2 - - -class OpticalCentralizedAttackDetectorServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.NotifyServiceUpdate = channel.unary_unary( - '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/NotifyServiceUpdate', - request_serializer=context__pb2.Service.SerializeToString, - response_deserializer=context__pb2.Empty.FromString, - ) - self.DetectAttack = channel.unary_unary( - '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/DetectAttack', - request_serializer=context__pb2.Empty.SerializeToString, - response_deserializer=context__pb2.Empty.FromString, - ) - self.ReportSummarizedKpi = channel.unary_unary( - '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/ReportSummarizedKpi', - request_serializer=monitoring__pb2.KpiList.SerializeToString, - response_deserializer=context__pb2.Empty.FromString, - ) - self.ReportKpi = channel.unary_unary( - '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/ReportKpi', - request_serializer=monitoring__pb2.KpiList.SerializeToString, - response_deserializer=context__pb2.Empty.FromString, - ) - - -class OpticalCentralizedAttackDetectorServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def NotifyServiceUpdate(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 DetectAttack(self, request, context): - """rpc that triggers the attack detection loop - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ReportSummarizedKpi(self, request, context): - """rpc called by the distributed component to report KPIs - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ReportKpi(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_OpticalCentralizedAttackDetectorServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'NotifyServiceUpdate': grpc.unary_unary_rpc_method_handler( - servicer.NotifyServiceUpdate, - request_deserializer=context__pb2.Service.FromString, - response_serializer=context__pb2.Empty.SerializeToString, - ), - 'DetectAttack': grpc.unary_unary_rpc_method_handler( - servicer.DetectAttack, - request_deserializer=context__pb2.Empty.FromString, - response_serializer=context__pb2.Empty.SerializeToString, - ), - 'ReportSummarizedKpi': grpc.unary_unary_rpc_method_handler( - servicer.ReportSummarizedKpi, - request_deserializer=monitoring__pb2.KpiList.FromString, - response_serializer=context__pb2.Empty.SerializeToString, - ), - 'ReportKpi': grpc.unary_unary_rpc_method_handler( - servicer.ReportKpi, - request_deserializer=monitoring__pb2.KpiList.FromString, - response_serializer=context__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'centralized_attack_detector.OpticalCentralizedAttackDetectorService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class OpticalCentralizedAttackDetectorService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def NotifyServiceUpdate(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, '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/NotifyServiceUpdate', - context__pb2.Service.SerializeToString, - context__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def DetectAttack(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, '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/DetectAttack', - context__pb2.Empty.SerializeToString, - context__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ReportSummarizedKpi(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, '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/ReportSummarizedKpi', - monitoring__pb2.KpiList.SerializeToString, - context__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def ReportKpi(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, '/centralized_attack_detector.OpticalCentralizedAttackDetectorService/ReportKpi', - monitoring__pb2.KpiList.SerializeToString, - context__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/src/opticalcentralizedattackdetector/proto/service_pb2.py b/src/opticalcentralizedattackdetector/proto/service_pb2.py deleted file mode 100644 index 8e2806c7685e24ab90a3d59a19f1e4f99ebc9712..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/proto/service_pb2.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: service.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 - - -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.proto2\xb9\x01\n\x0eServiceService\x12\x37\n\rCreateService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x37\n\rUpdateService\x12\x10.context.Service\x1a\x12.context.ServiceId\"\x00\x12\x35\n\rDeleteService\x12\x12.context.ServiceId\x1a\x0e.context.Empty\"\x00\x62\x06proto3' - , - dependencies=[context__pb2.DESCRIPTOR,]) - - - -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - - -_SERVICESERVICE = _descriptor.ServiceDescriptor( - name='ServiceService', - full_name='service.ServiceService', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=42, - serialized_end=227, - methods=[ - _descriptor.MethodDescriptor( - name='CreateService', - full_name='service.ServiceService.CreateService', - index=0, - containing_service=None, - input_type=context__pb2._SERVICE, - output_type=context__pb2._SERVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='UpdateService', - full_name='service.ServiceService.UpdateService', - index=1, - containing_service=None, - input_type=context__pb2._SERVICE, - output_type=context__pb2._SERVICEID, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='DeleteService', - full_name='service.ServiceService.DeleteService', - index=2, - containing_service=None, - input_type=context__pb2._SERVICEID, - output_type=context__pb2._EMPTY, - 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/opticalcentralizedattackdetector/requirements.in b/src/opticalcentralizedattackdetector/requirements.in deleted file mode 100644 index ea6b450c9c240c76b9f54ce4f3c0c6c25ec62289..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/requirements.in +++ /dev/null @@ -1,10 +0,0 @@ -grpcio-health-checking -grpcio -prometheus-client -pytest -pytest-benchmark -redis -# from the monitoring component -influxdb -python-json-logger -coverage diff --git a/src/opticalcentralizedattackdetector/requirements.txt b/src/opticalcentralizedattackdetector/requirements.txt deleted file mode 100644 index fca44cbb133ae3c6d5ba2a6d12882ecad9a2c467..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/requirements.txt +++ /dev/null @@ -1,60 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: -# -# pip-compile --output-file=opticalcentralizedattackdetector/requirements.txt opticalcentralizedattackdetector/requirements.in -# -attrs==21.2.0 - # via pytest -certifi==2021.10.8 - # via influxdb-client -grpcio==1.41.0 - # via - # -r opticalcentralizedattackdetector/requirements.in - # grpcio-health-checking -grpcio-health-checking==1.41.0 - # via -r opticalcentralizedattackdetector/requirements.in -influxdb-client==1.23.0 - # via -r opticalcentralizedattackdetector/requirements.in -iniconfig==1.1.1 - # via pytest -packaging==21.0 - # via pytest -pluggy==1.0.0 - # via pytest -prometheus-client==0.11.0 - # via -r opticalcentralizedattackdetector/requirements.in -protobuf==3.18.0 - # via grpcio-health-checking -py==1.10.0 - # via pytest -py-cpuinfo==8.0.0 - # via pytest-benchmark -pyparsing==2.4.7 - # via packaging -pytest==6.2.5 - # via - # -r opticalcentralizedattackdetector/requirements.in - # pytest-benchmark -pytest-benchmark==3.4.1 - # via -r opticalcentralizedattackdetector/requirements.in -python-dateutil==2.8.2 - # via influxdb-client -pytz==2021.3 - # via influxdb-client -redis==3.5.3 - # via -r opticalcentralizedattackdetector/requirements.in -rx==3.2.0 - # via influxdb-client -six==1.16.0 - # via - # grpcio - # influxdb-client - # python-dateutil -toml==0.10.2 - # via pytest -urllib3==1.26.7 - # via influxdb-client - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorService.py b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorService.py deleted file mode 100644 index e29566833a781afc8bf85b41b7d5dd10f2a4a2f5..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorService.py +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import grpc -import 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 opticalcentralizedattackdetector.proto.optical_centralized_attack_detector_pb2_grpc import ( - add_OpticalCentralizedAttackDetectorServiceServicer_to_server) -from opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl import ( - OpticalCentralizedAttackDetectorServiceServicerImpl) -from opticalcentralizedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD - -BIND_ADDRESS = '0.0.0.0' -LOGGER = logging.getLogger(__name__) - -class OpticalCentralizedAttackDetectorService: - 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.centralized_attack_detector_servicer = None - self.health_servicer = None - self.pool = None - self.server = None - - def start(self): - self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) - LOGGER.debug('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( - str(self.endpoint), str(self.max_workers))) - - self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) - self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) - - self.centralized_attack_detector_servicer = OpticalCentralizedAttackDetectorServiceServicerImpl() - add_OpticalCentralizedAttackDetectorServiceServicer_to_server(self.centralized_attack_detector_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 = '{:s}:{:s}'.format(str(self.address), str(port)) - LOGGER.info('Listening on {:s}...'.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 {:s} seconds)...'.format(str(self.grace_period))) - self.health_servicer.enter_graceful_shutdown() - self.server.stop(self.grace_period) - LOGGER.debug('Service stopped') diff --git a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py deleted file mode 100644 index d4c71476f016081f7d230a3cfe87e73b35654987..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import os, grpc, logging, random -from influxdb import InfluxDBClient -from common.rpc_method_wrapper.Decorator import create_metrics, safe_and_metered_rpc_method -from context.client.ContextClient import ContextClient -from monitoring.client.MonitoringClient import MonitoringClient -from service.client.ServiceClient import ServiceClient -from dbscanserving.proto.dbscanserving_pb2 import DetectionRequest, DetectionResponse, Sample -from dbscanserving.client.DbscanServingClient import DbscanServingClient -from dbscanserving.Config import GRPC_SERVICE_PORT as DBSCANSERVING_GRPC_SERVICE_PORT -from opticalattackmitigator.client.OpticalAttackMitigatorClient import OpticalAttackMitigatorClient -from opticalattackmitigator.proto.optical_attack_mitigator_pb2 import AttackDescription, AttackResponse -from opticalattackmitigator.Config import GRPC_SERVICE_PORT as ATTACK_MITIGATOR_GRPC_SERVICE_PORT -from opticalcentralizedattackdetector.proto.context_pb2 import (Empty, - Context, ContextId, ContextIdList, ContextList, - Service, ServiceId, ServiceIdList, ServiceList -) -from opticalcentralizedattackdetector.proto.monitoring_pb2 import KpiList -from opticalcentralizedattackdetector.proto.optical_centralized_attack_detector_pb2_grpc import ( - OpticalCentralizedAttackDetectorServiceServicer) -from opticalcentralizedattackdetector.Config import ( - INFERENCE_SERVICE_ADDRESS, MONITORING_SERVICE_ADDRESS, ATTACK_MITIGATOR_SERVICE_ADDRESS) - - -LOGGER = logging.getLogger(__name__) - -SERVICE_NAME = 'OpticalCentralizedAttackDetector' -METHOD_NAMES = ['NotifyServiceUpdate', 'DetectAttack', 'ReportSummarizedKpi', 'ReportKpi'] -METRICS = create_metrics(SERVICE_NAME, METHOD_NAMES) - -INFLUXDB_HOSTNAME = os.environ.get("INFLUXDB_HOSTNAME") -INFLUXDB_USER = os.environ.get("INFLUXDB_USER") -INFLUXDB_PASSWORD = os.environ.get("INFLUXDB_PASSWORD") -INFLUXDB_DATABASE = os.environ.get("INFLUXDB_DATABASE") -context_client: ContextClient = ContextClient() -influxdb_client: InfluxDBClient = InfluxDBClient( - host=MONITORING_SERVICE_ADDRESS, port=8086, username=INFLUXDB_USER, password=INFLUXDB_PASSWORD, - database=INFLUXDB_DATABASE) -monitoring_client: MonitoringClient = MonitoringClient() -dbscanserving_client: DbscanServingClient = DbscanServingClient( - address=INFERENCE_SERVICE_ADDRESS, port=DBSCANSERVING_GRPC_SERVICE_PORT) -service_client: ServiceClient = ServiceClient() -attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient( - address=ATTACK_MITIGATOR_SERVICE_ADDRESS, port=ATTACK_MITIGATOR_GRPC_SERVICE_PORT) - - -class OpticalCentralizedAttackDetectorServiceServicerImpl(OpticalCentralizedAttackDetectorServiceServicer): - - def __init__(self): - LOGGER.debug('Creating Servicer...') - LOGGER.debug('Servicer Created') - - @safe_and_metered_rpc_method(METRICS, LOGGER) - def NotifyServiceUpdate(self, request : Service, context : grpc.ServicerContext) -> Empty: - return Empty() - - @safe_and_metered_rpc_method(METRICS, LOGGER) - def DetectAttack(self, request : Empty, context : grpc.ServicerContext) -> Empty: - - # retrieve list with current contexts - # import pdb; pdb.set_trace() - context_ids: ContextIdList = context_client.ListContextIds(Empty()) - - # for each context, retrieve list of current services - services = [] - for context_id in context_ids.context_ids: - - context_services: ServiceIdList = context_client.ListServices(context_id) - for service in context_services.services: - services.append(service) - - # get monitoring data for each of the current services - results = influxdb_client.query('select * from samples;') - - for service in services: - for endpoint in service.service_endpoint_ids: - # get instant KPI for this endpoint - LOGGER.warning(f'service: {service.service_id.service_uuid.uuid}\t endpoint: {endpoint.endpoint_uuid.uuid}\tdevice: {endpoint.device_id.device_uuid.uuid}') - # how to get all KPIs for a particular device? - points = results.get_points(tags={'device_id': endpoint.device_id.device_uuid.uuid}) - print('points:', points) - for point in points: - print('\t', point) - - # run attack detection for every service - request: DetectionRequest = DetectionRequest() - - request.num_samples = 310 - request.num_features = 100 - request.eps = 100.5 - request.min_samples = 50 - - for _ in range(200): - grpc_sample = Sample() - for __ in range(100): - grpc_sample.features.append(random.uniform(0., 10.)) - request.samples.append(grpc_sample) - - for _ in range(100): - grpc_sample = Sample() - for __ in range(100): - grpc_sample.features.append(random.uniform(50., 60.)) - request.samples.append(grpc_sample) - - for _ in range(10): - grpc_sample = Sample() - for __ in range(100): - grpc_sample.features.append(random.uniform(5000., 6000.)) - request.samples.append(grpc_sample) - - response: DetectionResponse = dbscanserving_client.Detect(request) - - if -1 in response.cluster_indices: # attack detected - attack = AttackDescription() - attack.cs_id.uuid = service.service_id.service_uuid.uuid - response: AttackResponse = attack_mitigator_client.NotifyAttack(attack) - - # if attack is detected, run the attack mitigator - return Empty() - - @safe_and_metered_rpc_method(METRICS, LOGGER) - def ReportSummarizedKpi(self, request : KpiList, context : grpc.ServicerContext) -> Empty: - return Empty() - - @safe_and_metered_rpc_method(METRICS, LOGGER) - def ReportKpi(self, request : KpiList, context : grpc.ServicerContext) -> Empty: - return Empty() diff --git a/src/opticalcentralizedattackdetector/service/__init__.py b/src/opticalcentralizedattackdetector/service/__init__.py deleted file mode 100644 index 70a33251242c51f49140e596b8208a19dd5245f7..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/service/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - diff --git a/src/opticalcentralizedattackdetector/service/__main__.py b/src/opticalcentralizedattackdetector/service/__main__.py deleted file mode 100644 index d21b96cf8adc6f9d9968f3553c9249a3b8cedf31..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/service/__main__.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import os, logging, signal, sys, time, threading, multiprocessing -from prometheus_client import start_http_server - -from common.Settings import get_setting -from opticalcentralizedattackdetector.Config import ( - GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT, - MONITORING_INTERVAL) -from opticalcentralizedattackdetector.proto.context_pb2 import (Empty, - Context, ContextId, ContextIdList, ContextList, - Service, ServiceId, ServiceIdList, ServiceList -) -from opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorService import OpticalCentralizedAttackDetectorService -from opticalcentralizedattackdetector.client.OpticalCentralizedAttackDetectorClient import OpticalCentralizedAttackDetectorClient - -terminate = threading.Event() -LOGGER = None - -client: OpticalCentralizedAttackDetectorClient = None - -def signal_handler(signal, frame): # pylint: disable=redefined-outer-name - LOGGER.warning('Terminate signal received') - terminate.set() - -def detect_attack(monitoring_interval): - time.sleep(10) # wait for the service to start - LOGGER.info("Starting the attack detection loop") - client = OpticalCentralizedAttackDetectorClient(address='localhost', port=GRPC_SERVICE_PORT) - client.connect() - while True: # infinite loop that runs until the terminate is set - if terminate.is_set(): # if terminate is set - LOGGER.warning("Stopping execution...") - client.close() - break # break the while and stop execution - client.DetectAttack(Empty()) - # sleep - LOGGER.debug("Sleeping for {} seconds...".format(monitoring_interval)) - time.sleep(monitoring_interval) - -def main(): - global LOGGER # pylint: disable=global-statement - - service_port = get_setting('OPTICALCENTRALIZEDATTACKDETECTORSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) - monitoring_interval = get_setting('MONITORING_INTERVAL', default=MONITORING_INTERVAL ) - - 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 CentralizedCybersecurity service - grpc_service = OpticalCentralizedAttackDetectorService( - port=service_port, max_workers=max_workers, grace_period=grace_period) - grpc_service.start() - - # p = multiprocessing.Process(target=detect_attack, args=(monitoring_interval, )) - # p.start() - detect_attack(monitoring_interval) - - # Wait for Ctrl+C or termination signal - while not terminate.wait(timeout=0.1): pass - - LOGGER.info('Terminating...') - grpc_service.stop() - # p.kill() - - LOGGER.info('Bye') - return 0 - -if __name__ == '__main__': - sys.exit(main()) diff --git a/src/opticalcentralizedattackdetector/tests/__init__.py b/src/opticalcentralizedattackdetector/tests/__init__.py deleted file mode 100644 index 70a33251242c51f49140e596b8208a19dd5245f7..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/tests/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - diff --git a/src/opticalcentralizedattackdetector/tests/example_objects.py b/src/opticalcentralizedattackdetector/tests/example_objects.py deleted file mode 100644 index 3c5a26b6d0bde888560741f052906e0d2694c91d..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/tests/example_objects.py +++ /dev/null @@ -1,215 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -from copy import deepcopy -from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID -from context.proto.context_pb2 import ( - ConfigActionEnum, DeviceDriverEnum, DeviceOperationalStatusEnum, ServiceStatusEnum, ServiceTypeEnum) - -# Some example objects to be used by the tests - -# Helper methods -def config_rule(action, resource_key, resource_value): - return {'action': action, 'resource_key': resource_key, 'resource_value': resource_value} - -def endpoint_id(topology_id, device_id, endpoint_uuid): - return {'topology_id': deepcopy(topology_id), 'device_id': deepcopy(device_id), - 'endpoint_uuid': {'uuid': endpoint_uuid}} - -def endpoint(topology_id, device_id, endpoint_uuid, endpoint_type): - return {'endpoint_id': endpoint_id(topology_id, device_id, endpoint_uuid), 'endpoint_type': endpoint_type} - -## use "deepcopy" to prevent propagating forced changes during tests -CONTEXT_ID = {'context_uuid': {'uuid': DEFAULT_CONTEXT_UUID}} -CONTEXT = { - 'context_id': deepcopy(CONTEXT_ID), - 'topology_ids': [], - 'service_ids': [], -} - -CONTEXT_ID_2 = {'context_uuid': {'uuid': 'test'}} -CONTEXT_2 = { - 'context_id': deepcopy(CONTEXT_ID_2), - 'topology_ids': [], - 'service_ids': [], -} - -TOPOLOGY_ID = { - 'context_id': deepcopy(CONTEXT_ID), - 'topology_uuid': {'uuid': DEFAULT_TOPOLOGY_UUID}, -} -TOPOLOGY = { - 'topology_id': deepcopy(TOPOLOGY_ID), - 'device_ids': [], - 'link_ids': [], -} - -DEVICE1_UUID = 'DEV1' -DEVICE1_ID = {'device_uuid': {'uuid': DEVICE1_UUID}} -DEVICE1 = { - 'device_id': deepcopy(DEVICE1_ID), - 'device_type': 'packet-router', - 'device_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc1/value', 'value1'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc2/value', 'value2'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc3/value', 'value3'), - ]}, - 'device_operational_status': DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, - 'device_drivers': [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, DeviceDriverEnum.DEVICEDRIVER_P4], - 'device_endpoints': [ - endpoint(TOPOLOGY_ID, DEVICE1_ID, 'EP2', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE1_ID, 'EP3', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE1_ID, 'EP100', 'port-packet-10G'), - ], -} - -DEVICE2_UUID = 'DEV2' -DEVICE2_ID = {'device_uuid': {'uuid': DEVICE2_UUID}} -DEVICE2 = { - 'device_id': deepcopy(DEVICE2_ID), - 'device_type': 'packet-router', - 'device_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc1/value', 'value4'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc2/value', 'value5'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc3/value', 'value6'), - ]}, - 'device_operational_status': DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, - 'device_drivers': [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, DeviceDriverEnum.DEVICEDRIVER_P4], - 'device_endpoints': [ - endpoint(TOPOLOGY_ID, DEVICE2_ID, 'EP1', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE2_ID, 'EP3', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE2_ID, 'EP100', 'port-packet-10G'), - ], -} - -DEVICE3_UUID = 'DEV3' -DEVICE3_ID = {'device_uuid': {'uuid': DEVICE3_UUID}} -DEVICE3 = { - 'device_id': deepcopy(DEVICE3_ID), - 'device_type': 'packet-router', - 'device_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc1/value', 'value4'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc2/value', 'value5'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'dev/rsrc3/value', 'value6'), - ]}, - 'device_operational_status': DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_ENABLED, - 'device_drivers': [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG, DeviceDriverEnum.DEVICEDRIVER_P4], - 'device_endpoints': [ - endpoint(TOPOLOGY_ID, DEVICE3_ID, 'EP1', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE3_ID, 'EP2', 'port-packet-100G'), - endpoint(TOPOLOGY_ID, DEVICE3_ID, 'EP100', 'port-packet-10G'), - ], -} - -LINK_DEV1_DEV2_UUID = 'DEV1/EP2 ==> DEV2/EP1' -LINK_DEV1_DEV2_ID = {'link_uuid': {'uuid': LINK_DEV1_DEV2_UUID}} -LINK_DEV1_DEV2 = { - 'link_id': deepcopy(LINK_DEV1_DEV2_ID), - 'link_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE1_ID, 'EP2'), - endpoint_id(TOPOLOGY_ID, DEVICE2_ID, 'EP1'), - ] -} - -LINK_DEV2_DEV3_UUID = 'DEV2/EP3 ==> DEV3/EP2' -LINK_DEV2_DEV3_ID = {'link_uuid': {'uuid': LINK_DEV2_DEV3_UUID}} -LINK_DEV2_DEV3 = { - 'link_id': deepcopy(LINK_DEV2_DEV3_ID), - 'link_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE2_ID, 'EP3'), - endpoint_id(TOPOLOGY_ID, DEVICE3_ID, 'EP2'), - ] -} - -LINK_DEV1_DEV3_UUID = 'DEV1/EP3 ==> DEV3/EP1' -LINK_DEV1_DEV3_ID = {'link_uuid': {'uuid': LINK_DEV1_DEV3_UUID}} -LINK_DEV1_DEV3 = { - 'link_id': deepcopy(LINK_DEV1_DEV3_ID), - 'link_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE1_ID, 'EP3'), - endpoint_id(TOPOLOGY_ID, DEVICE3_ID, 'EP1'), - ] -} - -SERVICE_DEV1_DEV2_UUID = 'SVC:DEV1/EP100-DEV2/EP100' -SERVICE_DEV1_DEV2_ID = { - 'context_id': deepcopy(CONTEXT_ID), - 'service_uuid': {'uuid': SERVICE_DEV1_DEV2_UUID}, -} -SERVICE_DEV1_DEV2 = { - 'service_id': deepcopy(SERVICE_DEV1_DEV2_ID), - 'service_type': ServiceTypeEnum.SERVICETYPE_L3NM, - 'service_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE1_ID, 'EP100'), - endpoint_id(TOPOLOGY_ID, DEVICE2_ID, 'EP100'), - ], - 'service_constraints': [ - {'constraint_type': 'latency_ms', 'constraint_value': '15.2'}, - {'constraint_type': 'jitter_us', 'constraint_value': '1.2'}, - ], - 'service_status': {'service_status': ServiceStatusEnum.SERVICESTATUS_ACTIVE}, - 'service_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc1/value', 'value7'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc2/value', 'value8'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc3/value', 'value9'), - ]}, -} - -SERVICE_DEV1_DEV3_UUID = 'SVC:DEV1/EP100-DEV3/EP100' -SERVICE_DEV1_DEV3_ID = { - 'context_id': deepcopy(CONTEXT_ID), - 'service_uuid': {'uuid': SERVICE_DEV1_DEV3_UUID}, -} -SERVICE_DEV1_DEV3 = { - 'service_id': deepcopy(SERVICE_DEV1_DEV3_ID), - 'service_type': ServiceTypeEnum.SERVICETYPE_L3NM, - 'service_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE1_ID, 'EP100'), - endpoint_id(TOPOLOGY_ID, DEVICE3_ID, 'EP100'), - ], - 'service_constraints': [ - {'constraint_type': 'latency_ms', 'constraint_value': '5.8'}, - {'constraint_type': 'jitter_us', 'constraint_value': '0.1'}, - ], - 'service_status': {'service_status': ServiceStatusEnum.SERVICESTATUS_ACTIVE}, - 'service_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc1/value', 'value7'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc2/value', 'value8'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc3/value', 'value9'), - ]}, -} - -SERVICE_DEV2_DEV3_UUID = 'SVC:DEV2/EP100-DEV3/EP100' -SERVICE_DEV2_DEV3_ID = { - 'context_id': deepcopy(CONTEXT_ID), - 'service_uuid': {'uuid': SERVICE_DEV2_DEV3_UUID}, -} -SERVICE_DEV2_DEV3 = { - 'service_id': deepcopy(SERVICE_DEV2_DEV3_ID), - 'service_type': ServiceTypeEnum.SERVICETYPE_L3NM, - 'service_endpoint_ids' : [ - endpoint_id(TOPOLOGY_ID, DEVICE2_ID, 'EP100'), - endpoint_id(TOPOLOGY_ID, DEVICE3_ID, 'EP100'), - ], - 'service_constraints': [ - {'constraint_type': 'latency_ms', 'constraint_value': '23.1'}, - {'constraint_type': 'jitter_us', 'constraint_value': '3.4'}, - ], - 'service_status': {'service_status': ServiceStatusEnum.SERVICESTATUS_ACTIVE}, - 'service_config': {'config_rules': [ - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc1/value', 'value7'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc2/value', 'value8'), - config_rule(ConfigActionEnum.CONFIGACTION_SET, 'svc/rsrc3/value', 'value9'), - ]}, -} diff --git a/src/opticalcentralizedattackdetector/tests/test_unitary.py b/src/opticalcentralizedattackdetector/tests/test_unitary.py deleted file mode 100644 index da0f4ca9f78478073354d8645cf0b455a5f7a874..0000000000000000000000000000000000000000 --- a/src/opticalcentralizedattackdetector/tests/test_unitary.py +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) -# -# 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. - -import logging, pytest -from unittest.mock import patch -from opticalcentralizedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD -from opticalcentralizedattackdetector.client.OpticalCentralizedAttackDetectorClient import OpticalCentralizedAttackDetectorClient -from opticalcentralizedattackdetector.proto.context_pb2 import ContextIdList, ContextId, Empty, Service, ContextId, ServiceList -from opticalcentralizedattackdetector.proto.monitoring_pb2 import Kpi, KpiList -from opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorService import OpticalCentralizedAttackDetectorService -from .example_objects import CONTEXT_ID, CONTEXT_ID_2, SERVICE_DEV1_DEV2 - -port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports - -LOGGER = logging.getLogger(__name__) -LOGGER.setLevel(logging.DEBUG) - -@pytest.fixture(scope='session') -def optical_centralized_attack_detector_service(): - _service = OpticalCentralizedAttackDetectorService( - port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) - # mocker_context_client = mock.patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') - # mocker_context_client.start() - - # mocker_influx_db = mock.patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') - # mocker_influx_db.start() - - _service.start() - yield _service - _service.stop() - # mocker_context_client.stop() - # mocker_influx_db.stop() - -@pytest.fixture(scope='session') -def optical_centralized_attack_detector_client(optical_centralized_attack_detector_service): - _client = OpticalCentralizedAttackDetectorClient(address='127.0.0.1', port=port) - yield _client - _client.close() - -def test_notify_service_update(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient): - service = Service() - optical_centralized_attack_detector_client.NotifyServiceUpdate(service) - -def test_detect_attack_no_contexts(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb: - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - context.ListContextIds.assert_called_once() - influxdb.query.assert_called_once() - context.ListServices.assert_not_called() - -def test_detect_attack_with_context(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient,): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb: - # setting up the mock - cid_list = ContextIdList() - cid_list.context_ids.append(ContextId(**CONTEXT_ID)) - context.ListContextIds.return_value = cid_list - - # making the test - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - - # checking behavior - context.ListContextIds.assert_called_once() - context.ListServices.assert_called_with(cid_list.context_ids[0]) - influxdb.query.assert_called_once() - -def test_detect_attack_with_contexts(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient,): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb: - # setting up the mock - cid_list = ContextIdList() - cid_list.context_ids.append(ContextId(**CONTEXT_ID)) - cid_list.context_ids.append(ContextId(**CONTEXT_ID_2)) - context.ListContextIds.return_value = cid_list - - # making the test - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - - # checking behavior - context.ListContextIds.assert_called_once() - context.ListServices.assert_any_call(cid_list.context_ids[0]) - context.ListServices.assert_any_call(cid_list.context_ids[1]) - influxdb.query.assert_called_once() - -def test_detect_attack_with_service(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient,): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.dbscanserving_client') as dbscan: - - # setting up the mock - cid_list = ContextIdList() - cid_list.context_ids.append(ContextId(**CONTEXT_ID)) - context.ListContextIds.return_value = cid_list - - service_list = ServiceList() - service_list.services.append(Service(**SERVICE_DEV1_DEV2)) - context.ListServices.return_value = service_list - - influxdb.query.return_value.get_points.return_value = [(1, 2), (3, 4)] - - # making the test - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - - # checking behavior - context.ListContextIds.assert_called_once() - context.ListServices.assert_called_with(cid_list.context_ids[0]) - influxdb.query.assert_called_once() - dbscan.Detect.assert_called() - -def test_detect_attack_no_attack(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient,): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.dbscanserving_client') as dbscan, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.attack_mitigator_client') as mitigator: - - # setting up the mock - cid_list = ContextIdList() - cid_list.context_ids.append(ContextId(**CONTEXT_ID)) - context.ListContextIds.return_value = cid_list - - service_list = ServiceList() - service_list.services.append(Service(**SERVICE_DEV1_DEV2)) - context.ListServices.return_value = service_list - - # dbscan.Detect.return_value = object() - dbscan.Detect.return_value.cluster_indices = [0, 1, 2, 3, 4, 5] - - # making the test - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - - # checking behavior - context.ListContextIds.assert_called_once() - context.ListServices.assert_called_with(cid_list.context_ids[0]) - influxdb.query.assert_called_once() - dbscan.Detect.assert_called() - mitigator.NotifyAttack.assert_not_called() - -def test_detect_attack_with_attack(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient,): - with patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.context_client') as context, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.influxdb_client') as influxdb, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.dbscanserving_client') as dbscan, \ - patch('opticalcentralizedattackdetector.service.OpticalCentralizedAttackDetectorServiceServicerImpl.attack_mitigator_client') as mitigator: - - # setting up the mock - cid_list = ContextIdList() - cid_list.context_ids.append(ContextId(**CONTEXT_ID)) - context.ListContextIds.return_value = cid_list - - service_list = ServiceList() - service_list.services.append(Service(**SERVICE_DEV1_DEV2)) - context.ListServices.return_value = service_list - - # dbscan.Detect.return_value = object() - dbscan.Detect.return_value.cluster_indices = [0, 1, 2, 3, 4, -1] - - # making the test - request = Empty() - optical_centralized_attack_detector_client.DetectAttack(request) - - # checking behavior - context.ListContextIds.assert_called_once() - context.ListServices.assert_called_with(cid_list.context_ids[0]) - influxdb.query.assert_called_once() - dbscan.Detect.assert_called() - mitigator.NotifyAttack.assert_called() - -def test_report_summarized_kpi(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient): - kpi_list = KpiList() - optical_centralized_attack_detector_client.ReportSummarizedKpi(kpi_list) - -def test_report_kpi(optical_centralized_attack_detector_client: OpticalCentralizedAttackDetectorClient): - kpi_list = KpiList() - optical_centralized_attack_detector_client.ReportKpi(kpi_list) diff --git a/src/tests/scenario3/README.md b/src/tests/scenario3/README.md index a89d71f74b4ac35fa78aa5619019c8afad79410d..cc6d0c70417d5ec98810e557233941c3b0d043e6 100644 --- a/src/tests/scenario3/README.md +++ b/src/tests/scenario3/README.md @@ -1 +1,3 @@ -# Scenario 3 - ... +# Scenario 3 - Cybersecurity + + diff --git a/src/tests/scenario3/optical/README.md b/src/tests/scenario3/optical/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0bd562b78b2ac285a97cdef96408eea33e7fdadc --- /dev/null +++ b/src/tests/scenario3/optical/README.md @@ -0,0 +1,74 @@ +# Scenario 3 - Optical Cybersecurity + +## Workflows + +### Service creation workflow + +```mermaid + +%%{init: { 'mirrorActors':true } }%% + +sequenceDiagram + actor Customer + + participant Service + participant Context + participant Monitoring + participant Device + + participant am as Attack Manager + + Customer ->> Service: CreateService(ServiceSpec) + rect rgb(200, 150, 255) + note right of Service: Internal communication
for setting up the service + activate Service + Service -->> Context: + Service -->> Monitoring: + Service -->> Device: + end + Service ->> Customer: ServiceId + deactivate Service + + Context -->> am: ServiceEvent + loop kpi in KPIs + am -->> Monitoring: SetKpi(KpiDescriptor) + end + +``` + +### Service monitoring workflow + +```mermaid + +%%{init: { 'mirrorActors':true } }%% + +sequenceDiagram + + participant Monitoring + + participant ama as Attack Manager + participant ad as Attack Detector + participant ai as Attack Inference + participant am as Attack Mitigator + + loop service in services + ama ->> ad: DetectAttack(DetectionRequest) + activate ad + ad ->> Monitoring: QueryKpiData(KpiQuery) + Monitoring ->> ad: KpiList + ad ->> ai: Detect(DetectionRequest) + activate ai + ai ->> ad: DetectionResponse + deactivate ai + ad ->> Monitoring: IncludeKpi(DetectionResultKpi) + alt Attack detected + ad ->> am: NotifyAttack(AttackDescription) + activate am + am ->> ad: AttackResponse + deactivate am + end + ad ->> ama: Empty + deactivate ad + end + +``` diff --git a/src/tests/scenario3/optical/create_services.py b/src/tests/scenario3/optical/create_services.py new file mode 100644 index 0000000000000000000000000000000000000000..6e5832310d3a87a012aab4034ca562b2140f3389 --- /dev/null +++ b/src/tests/scenario3/optical/create_services.py @@ -0,0 +1,43 @@ +import pytest +from common.Settings import get_setting +from compute.tests.mock_osm.MockOSM import MockOSM + +import logging, pytest, random, time +from common.DeviceTypes import DeviceTypeEnum +from common.Settings import get_setting +from common.tests.EventTools import EVENT_CREATE, EVENT_UPDATE, check_events +from common.tools.object_factory.Connection import json_connection_id +from common.tools.object_factory.Device import json_device_id +from common.tools.object_factory.Service import json_service_id +from common.tools.grpc.Tools import grpc_message_to_json_string +from compute.tests.mock_osm.MockOSM import MockOSM +from context.client.ContextClient import ContextClient +from monitoring.client.MonitoringClient import MonitoringClient +from context.client.EventsCollector import EventsCollector +from common.proto.context_pb2 import ContextId, Empty +from tests.Fixtures import context_client, monitoring_client + +from tests.ofc22.tests.Objects import (WIM_MAPPING, WIM_PASSWORD, WIM_USERNAME, CONTEXT_ID, CONTEXTS, DEVICE_O1_UUID, DEVICE_R1_UUID, DEVICE_R3_UUID, DEVICES, LINKS, TOPOLOGIES, + WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE) + +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) + +DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value +DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value + +if __name__ == "__main__": + wim_url = 'http://{:s}:{:s}'.format( + get_setting('COMPUTESERVICE_SERVICE_HOST'), str(get_setting('COMPUTESERVICE_SERVICE_PORT_HTTP'))) + + osm_wim = MockOSM(wim_url, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) + + for i in range(100): + service_uuid = osm_wim.create_connectivity_service(WIM_SERVICE_TYPE, WIM_SERVICE_CONNECTION_POINTS) + print("provisioned", i) + time.sleep(1) + + # create services + while True: + service_uuid = osm_wim.create_connectivity_service(WIM_SERVICE_TYPE, WIM_SERVICE_CONNECTION_POINTS) + input("x") \ No newline at end of file diff --git a/src/tests/scenario3/optical/deploy_specs.sh b/src/tests/scenario3/optical/deploy_specs.sh new file mode 100644 index 0000000000000000000000000000000000000000..65d440cdfcc4e5304d70afa40d111f4bacb84157 --- /dev/null +++ b/src/tests/scenario3/optical/deploy_specs.sh @@ -0,0 +1,25 @@ +# Set the URL of your local Docker registry where the images will be uploaded to. +export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/" + +# Set the list of components, separated by spaces, you want to build images for, and deploy. +# Supported components are: +# context device automation policy service compute monitoring webui +# interdomain slice pathcomp dlt +# dbscanserving opticalattackmitigator opticalattackdetector +# l3_attackmitigator l3_centralizedattackdetector l3_distributedattackdetector +export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui" + +# including components of the optical cybersecurity app +export TFS_COMPONENTS="${TFS_COMPONENTS} dbscanserving opticalattackmitigator" # opticalattackdetector opticalattackmanager" + +# Set the tag you want to use for your images. +export TFS_IMAGE_TAG="dev" + +# Set the name of the Kubernetes namespace to deploy to. +export TFS_K8S_NAMESPACE="tfs" + +# Set additional manifest files to be applied after the deployment +export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml manifests/cachingservice.yaml" + +# Set the neew Grafana admin password +export TFS_GRAFANA_PASSWORD="admin123+"