Skip to content
Snippets Groups Projects
Commit 436e3c9c authored by Carlos Natalino Da Silva's avatar Carlos Natalino Da Silva
Browse files

Development version prior to merging from the develop branch with the latest developments.

parent 1d517d1b
No related branches found
No related tags found
1 merge request!54Release 2.0.0
Showing
with 2340 additions and 9 deletions
......@@ -7,7 +7,7 @@ pip install --upgrade pip setuptools wheel pip-tools pylint pytest pytest-benchm
echo "" > requirements.in
#TODO: include here your component
COMPONENTS="compute context device monitoring centralizedattackdetector"
COMPONENTS="compute context device monitoring centralizedattackdetector webui"
# compiling dependencies from all components
for component in $COMPONENTS
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: webuiservice
spec:
selector:
matchLabels:
app: webuiservice
template:
metadata:
labels:
app: webuiservice
spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: registry.gitlab.com/teraflow-h2020/controller/webui:latest
imagePullPolicy: Always
ports:
- containerPort: 8001 # TODO: define the real port
env:
- name: DB_ENGINE
value: "redis"
- name: REDIS_DATABASE_ID
value: "0"
- name: LOG_LEVEL
value: "DEBUG"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:10000"]
livenessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:10000"]
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 700m
memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
name: webuiservice
spec:
type: ClusterIP
selector:
app: webuiservice
ports:
- name: grpc
port: 10000
targetPort: 10000
---
apiVersion: v1
kind: Service
metadata:
name: webuiservice-public
labels:
app: webuiservice
spec:
type: NodePort
selector:
app: webuiservice
ports:
- name: grpc
protocol: TCP
port: 10000
targetPort: 10000
---
......@@ -2,7 +2,7 @@
PROJECTDIR=`pwd`
cd $(dirname $0)/src
cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc
COVERAGEFILE=$PROJECTDIR/coverage/.coverage
......@@ -34,11 +34,15 @@ coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
compute/tests/test_unitary.py
# Run integration tests and analyze coverage of code at same time
export DB_ENGINE='redis'
export REDIS_SERVICE_HOST='10.1.7.194'
export REDIS_SERVICE_PORT='31789'
export REDIS_DATABASE_ID='0'
coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
common/database/tests/test_engine_redis.py \
tester_integration/test_context_device_service.py
webui/tests/test_unitary.py
# Run integration tests and analyze coverage of code at same time
#TODO: umcomment the following lines
# export DB_ENGINE='redis'
# export REDIS_SERVICE_HOST='10.1.7.194'
# export REDIS_SERVICE_PORT='31789'
# export REDIS_DATABASE_ID='0'
# coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \
# common/database/tests/test_engine_redis.py \
# tester_integration/test_context_device_service.py
# Build, tag, and push the Docker images to the GitLab Docker registry
build webui:
variables:
IMAGE_NAME: 'webui' # name of the microservice
IMAGE_NAME_TEST: 'webui-test' # name of the microservice
IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
stage: build
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/
- docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
- docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
rules:
- changes:
- src/$IMAGE_NAME/**
- .gitlab-ci.yml
# Pull, execute, and run unitary tests for the Docker image from the GitLab registry
unit_test webui:
variables:
IMAGE_NAME: 'webui' # name of the microservice
IMAGE_NAME_TEST: 'webui-test' # name of the microservice
IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
stage: unit_test
needs:
- build webui
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi
script:
- docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
- docker run -d -p 10000:10000 --name $IMAGE_NAME --network=teraflowbridge "$IMAGE_NAME:$IMAGE_TAG"
- docker ps -a
- sleep 5
- docker ps -a
- docker logs $IMAGE_NAME
- docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py"
after_script:
- docker stop $IMAGE_NAME
- docker rm $IMAGE_NAME
rules:
- changes:
- src/$IMAGE_NAME/**
- .gitlab-ci.yml
# Deployment of the service in Kubernetes Cluster
deploy webui:
stage: deploy
needs:
- build webui
- unit_test webui
- dependencies all
- integ_test execute
script:
- kubectl version
- kubectl get all
- kubectl apply -f "manifests/webuiservice.yaml"
- kubectl delete pods --selector app=webuiservice
- kubectl get all
import logging
# General settings
LOG_LEVEL = logging.WARNING
# gRPC settings
WEBUI_SERVICE_PORT = 8004
# Prometheus settings
METRICS_PORT = 9192
SECRET_KEY = '>s&}24@{]]#k3&^5$f3#?6?h3{W@[}/7z}2pa]>{3&5%RP<)[('
HOST = '0.0.0.0' # accepts connections coming from any IP
DEBUG=False
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 -- not needed here... health will be asserted using HTTP
# 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/webui
# Get Python packages per module
COPY webui/requirements.in webui/requirements.in
RUN pip-compile --output-file=webui/requirements.txt webui/requirements.in
RUN python3 -m pip install -r webui/requirements.txt
# Add files into working directory
COPY common/. common
COPY webui/. webui
# Start webui service
ENTRYPOINT ["python", "-m", "webui.service"]
#!/bin/bash -eu
#
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash -e
# Make folder containing the script the root folder for its execution
cd $(dirname $0)
rm -rf proto/*.py
rm -rf proto/__pycache__
touch proto/__init__.py
# building protos of services used
python -m grpc_tools.protoc -I../../proto --python_out=proto --grpc_python_out=proto compute.proto
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 device.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
rm proto/compute_pb2_grpc.py
rm proto/context_pb2_grpc.py
rm proto/device_pb2_grpc.py
rm proto/service_pb2_grpc.py
rm proto/monitoring_pb2_grpc.py
sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/compute_pb2.py
sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/context_pb2.py
sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/device_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
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: compute.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from . import context_pb2 as context__pb2
from . import service_pb2 as service__pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='compute.proto',
package='compute',
syntax='proto3',
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\rcompute.proto\x12\x07\x63ompute\x1a\rcontext.proto\x1a\rservice.proto2\x88\x04\n\x0e\x43omputeService\x12P\n\x10\x43heckCredentials\x12\x1b.context.TeraFlowController\x1a\x1d.context.AuthenticationResult\"\x00\x12K\n\x1cGetConnectivityServiceStatus\x12\x12.service.ServiceId\x1a\x15.service.ServiceState\"\x00\x12\x43\n\x19\x43reateConnectivityService\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12\x41\n\x17\x45\x64itConnectivityService\x12\x10.service.Service\x1a\x12.service.ServiceId\"\x00\x12?\n\x19\x44\x65leteConnectivityService\x12\x10.service.Service\x1a\x0e.context.Empty\"\x00\x12L\n GetAllActiveConnectivityServices\x12\x0e.context.Empty\x1a\x16.service.ServiceIdList\"\x00\x12@\n\x1c\x43learAllConnectivityServices\x12\x0e.context.Empty\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
,
dependencies=[context__pb2.DESCRIPTOR,service__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_COMPUTESERVICE = _descriptor.ServiceDescriptor(
name='ComputeService',
full_name='compute.ComputeService',
file=DESCRIPTOR,
index=0,
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_start=57,
serialized_end=577,
methods=[
_descriptor.MethodDescriptor(
name='CheckCredentials',
full_name='compute.ComputeService.CheckCredentials',
index=0,
containing_service=None,
input_type=context__pb2._TERAFLOWCONTROLLER,
output_type=context__pb2._AUTHENTICATIONRESULT,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='GetConnectivityServiceStatus',
full_name='compute.ComputeService.GetConnectivityServiceStatus',
index=1,
containing_service=None,
input_type=service__pb2._SERVICEID,
output_type=service__pb2._SERVICESTATE,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='CreateConnectivityService',
full_name='compute.ComputeService.CreateConnectivityService',
index=2,
containing_service=None,
input_type=service__pb2._SERVICE,
output_type=service__pb2._SERVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='EditConnectivityService',
full_name='compute.ComputeService.EditConnectivityService',
index=3,
containing_service=None,
input_type=service__pb2._SERVICE,
output_type=service__pb2._SERVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='DeleteConnectivityService',
full_name='compute.ComputeService.DeleteConnectivityService',
index=4,
containing_service=None,
input_type=service__pb2._SERVICE,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='GetAllActiveConnectivityServices',
full_name='compute.ComputeService.GetAllActiveConnectivityServices',
index=5,
containing_service=None,
input_type=context__pb2._EMPTY,
output_type=service__pb2._SERVICEIDLIST,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='ClearAllConnectivityServices',
full_name='compute.ComputeService.ClearAllConnectivityServices',
index=6,
containing_service=None,
input_type=context__pb2._EMPTY,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
])
_sym_db.RegisterServiceDescriptor(_COMPUTESERVICE)
DESCRIPTOR.services_by_name['ComputeService'] = _COMPUTESERVICE
# @@protoc_insertion_point(module_scope)
This diff is collapsed.
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: device.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='device.proto',
package='device',
syntax='proto3',
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\x0c\x64\x65vice.proto\x12\x06\x64\x65vice\x1a\rcontext.proto2\xb0\x01\n\rDeviceService\x12\x31\n\tAddDevice\x12\x0f.context.Device\x1a\x11.context.DeviceId\"\x00\x12\x37\n\x0f\x43onfigureDevice\x12\x0f.context.Device\x1a\x11.context.DeviceId\"\x00\x12\x33\n\x0c\x44\x65leteDevice\x12\x11.context.DeviceId\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
,
dependencies=[context__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
_DEVICESERVICE = _descriptor.ServiceDescriptor(
name='DeviceService',
full_name='device.DeviceService',
file=DESCRIPTOR,
index=0,
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_start=40,
serialized_end=216,
methods=[
_descriptor.MethodDescriptor(
name='AddDevice',
full_name='device.DeviceService.AddDevice',
index=0,
containing_service=None,
input_type=context__pb2._DEVICE,
output_type=context__pb2._DEVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='ConfigureDevice',
full_name='device.DeviceService.ConfigureDevice',
index=1,
containing_service=None,
input_type=context__pb2._DEVICE,
output_type=context__pb2._DEVICEID,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='DeleteDevice',
full_name='device.DeviceService.DeleteDevice',
index=2,
containing_service=None,
input_type=context__pb2._DEVICEID,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
])
_sym_db.RegisterServiceDescriptor(_DEVICESERVICE)
DESCRIPTOR.services_by_name['DeviceService'] = _DEVICESERVICE
# @@protoc_insertion_point(module_scope)
# -*- 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
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\"|\n\x03Kpi\x12!\n\x06kpi_id\x18\x01 \x01(\x0b\x32\x11.monitoring.KpiId\x12\x11\n\ttimestamp\x18\x02 \x01(\t\x12\x16\n\x0ekpiDescription\x18\x03 \x01(\t\x12\'\n\tkpi_value\x18\x04 \x01(\x0b\x32\x14.monitoring.KpiValue\"&\n\x05KpiId\x12\x1d\n\x06kpi_id\x18\x01 \x01(\x0b\x32\r.context.Uuid\"T\n\tKpiDevice\x12!\n\x06kpi_id\x18\x01 \x01(\x0b\x32\x11.monitoring.KpiId\x12$\n\tdevice_id\x18\x02 \x01(\x0b\x32\x11.context.DeviceId\"+\n\x07KpiList\x12 \n\x07kpiList\x18\x01 \x03(\x0b\x32\x0f.monitoring.Kpi\"M\n\x08KpiValue\x12\x10\n\x06intVal\x18\x01 \x01(\rH\x00\x12\x13\n\tstringVal\x18\x02 \x01(\tH\x00\x12\x11\n\x07\x62oolVal\x18\x03 \x01(\x08H\x00\x42\x07\n\x05value2\xea\x01\n\x11MonitoringService\x12/\n\nIncludeKpi\x12\x0f.monitoring.Kpi\x1a\x0e.context.Empty\"\x00\x12\x35\n\nMonitorKpi\x12\x15.monitoring.KpiDevice\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 = _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='kpiDescription', full_name='monitoring.Kpi.kpiDescription', 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='kpi_value', full_name='monitoring.Kpi.kpi_value', 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=47,
serialized_end=171,
)
_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=173,
serialized_end=211,
)
_KPIDEVICE = _descriptor.Descriptor(
name='KpiDevice',
full_name='monitoring.KpiDevice',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='kpi_id', full_name='monitoring.KpiDevice.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='device_id', full_name='monitoring.KpiDevice.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=213,
serialized_end=297,
)
_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='kpiList', full_name='monitoring.KpiList.kpiList', 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=299,
serialized_end=342,
)
_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='stringVal', full_name='monitoring.KpiValue.stringVal', 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='boolVal', full_name='monitoring.KpiValue.boolVal', index=2,
number=3, 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=344,
serialized_end=421,
)
_KPI.fields_by_name['kpi_id'].message_type = _KPIID
_KPI.fields_by_name['kpi_value'].message_type = _KPIVALUE
_KPIID.fields_by_name['kpi_id'].message_type = context__pb2._UUID
_KPIDEVICE.fields_by_name['kpi_id'].message_type = _KPIID
_KPIDEVICE.fields_by_name['device_id'].message_type = context__pb2._DEVICEID
_KPILIST.fields_by_name['kpiList'].message_type = _KPI
_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['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']
DESCRIPTOR.message_types_by_name['Kpi'] = _KPI
DESCRIPTOR.message_types_by_name['KpiId'] = _KPIID
DESCRIPTOR.message_types_by_name['KpiDevice'] = _KPIDEVICE
DESCRIPTOR.message_types_by_name['KpiList'] = _KPILIST
DESCRIPTOR.message_types_by_name['KpiValue'] = _KPIVALUE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Kpi = _reflection.GeneratedProtocolMessageType('Kpi', (_message.Message,), {
'DESCRIPTOR' : _KPI,
'__module__' : 'monitoring_pb2'
# @@protoc_insertion_point(class_scope:monitoring.Kpi)
})
_sym_db.RegisterMessage(Kpi)
KpiId = _reflection.GeneratedProtocolMessageType('KpiId', (_message.Message,), {
'DESCRIPTOR' : _KPIID,
'__module__' : 'monitoring_pb2'
# @@protoc_insertion_point(class_scope:monitoring.KpiId)
})
_sym_db.RegisterMessage(KpiId)
KpiDevice = _reflection.GeneratedProtocolMessageType('KpiDevice', (_message.Message,), {
'DESCRIPTOR' : _KPIDEVICE,
'__module__' : 'monitoring_pb2'
# @@protoc_insertion_point(class_scope:monitoring.KpiDevice)
})
_sym_db.RegisterMessage(KpiDevice)
KpiList = _reflection.GeneratedProtocolMessageType('KpiList', (_message.Message,), {
'DESCRIPTOR' : _KPILIST,
'__module__' : 'monitoring_pb2'
# @@protoc_insertion_point(class_scope:monitoring.KpiList)
})
_sym_db.RegisterMessage(KpiList)
KpiValue = _reflection.GeneratedProtocolMessageType('KpiValue', (_message.Message,), {
'DESCRIPTOR' : _KPIVALUE,
'__module__' : 'monitoring_pb2'
# @@protoc_insertion_point(class_scope:monitoring.KpiValue)
})
_sym_db.RegisterMessage(KpiValue)
_MONITORINGSERVICE = _descriptor.ServiceDescriptor(
name='MonitoringService',
full_name='monitoring.MonitoringService',
file=DESCRIPTOR,
index=0,
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_start=424,
serialized_end=658,
methods=[
_descriptor.MethodDescriptor(
name='IncludeKpi',
full_name='monitoring.MonitoringService.IncludeKpi',
index=0,
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=1,
containing_service=None,
input_type=_KPIDEVICE,
output_type=context__pb2._EMPTY,
serialized_options=None,
create_key=_descriptor._internal_create_key,
),
_descriptor.MethodDescriptor(
name='GetStreamKpi',
full_name='monitoring.MonitoringService.GetStreamKpi',
index=2,
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=3,
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)
This diff is collapsed.
flask
flask-wtf
flask-healthz
grpcio
prometheus-client
pytest
pytest-benchmark
lorem-text
import os
from flask import Flask
def create_app(use_config=None):
app = Flask(__name__)
if use_config:
app.config.from_mapping(**use_config)
from webui.service.main.routes import main
app.register_blueprint(main)
from webui.service.service.routes import service
app.register_blueprint(service)
return app
import os, sys, logging
from prometheus_client import start_http_server
from webui.service import create_app
from webui.Config import WEBUI_SERVICE_PORT, LOG_LEVEL, METRICS_PORT, HOST, SECRET_KEY, DEBUG
def main():
service_port = os.environ.get('WEBUISERVICE_SERVICE_PORT', WEBUI_SERVICE_PORT)
log_level = os.environ.get('LOG_LEVEL', LOG_LEVEL )
metrics_port = os.environ.get('METRICS_PORT', METRICS_PORT )
host = os.environ.get('HOST', HOST )
debug = os.environ.get('DEBUG', DEBUG )
logging.basicConfig(level=log_level)
logger = logging.getLogger(__name__)
logger.info('Starting...')
start_http_server(metrics_port)
app = create_app(use_config={'SECRET_KEY': SECRET_KEY})
app.run(host=host, port=service_port, debug=debug)
logger.info('Bye')
return 0
if __name__ == '__main__':
sys.exit(main())
from flask import render_template, Blueprint, flash
main = Blueprint('main', __name__)
@main.route('/')
def home():
flash('This is an info message', 'info')
flash('This is a danger message', 'danger')
return render_template('main/home.html')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment