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

Updated gRPC proto files to prevent trouble with KPI sample types in devices,...

Updated gRPC proto files to prevent trouble with KPI sample types in devices, also updated files related to this issue.
parent 7d78dc01
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ message EndPointId {
message EndPoint {
  EndPointId endpoint_id = 1;
  string endpoint_type = 2;
  repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3;
}


@@ -257,7 +258,6 @@ message ConfigRule {
  ConfigActionEnum action = 1;
  string resource_key = 2;
  string resource_value = 3;
  kpi_sample_types.KpiSampleType kpi_sample_type = 4;
}


+5 −5
Original line number Diff line number Diff line
@@ -2,9 +2,9 @@ syntax = "proto3";
package kpi_sample_types;

enum KpiSampleType {
    UNKNOWN = 0;
    PACKETS_TRANSMITTED = 101;
    PACKETS_RECEIVED    = 102;
    BYTES_TRANSMITTED   = 201;
    BYTES_RECEIVED      = 202;
    KPISAMPLETYPE_UNKNOWN = 0;
    KPISAMPLETYPE_PACKETS_TRANSMITTED = 101;
    KPISAMPLETYPE_PACKETS_RECEIVED    = 102;
    KPISAMPLETYPE_BYTES_TRANSMITTED   = 201;
    KPISAMPLETYPE_BYTES_RECEIVED      = 202;
}
+14 −1
Original line number Diff line number Diff line
@@ -27,6 +27,16 @@ def validate_device_operational_status_enum(message):
        'DEVICEOPERATIONALSTATUS_ENABLED'
    ]

def validate_kpi_sample_types_enum(message):
    assert isinstance(message, str)
    assert message in [
        'KPISAMPLETYPE_UNKNOWN',
        'KPISAMPLETYPE_PACKETS_TRANSMITTED',
        'KPISAMPLETYPE_PACKETS_RECEIVED',
        'KPISAMPLETYPE_BYTES_TRANSMITTED',
        'KPISAMPLETYPE_BYTES_RECEIVED',
    ]

def validate_service_type_enum(message):
    assert isinstance(message, str)
    assert message in [
@@ -222,11 +232,14 @@ def validate_topology(message, num_devices=None, num_links=None):

def validate_endpoint(message):
    assert isinstance(message, dict)
    assert len(message.keys()) == 2
    assert len(message.keys()) == 3
    assert 'endpoint_id' in message
    validate_endpoint_id(message['endpoint_id'])
    assert 'endpoint_type' in message
    assert isinstance(message['endpoint_type'], str)
    assert 'kpi_sample_types' in message
    assert isinstance(message['kpi_sample_types'], list)
    for kpi_sample_type in message['kpi_sample_types']: validate_kpi_sample_types_enum(kpi_sample_type)

def validate_device(message):
    assert isinstance(message, dict)
+2 −0
Original line number Diff line number Diff line
@@ -26,9 +26,11 @@ touch proto/__init__.py
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 compute.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/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
+108 −98

File changed.

Preview size limit exceeded, changes collapsed.

Loading