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

Merge branch 'feat/dlt-component' into 'develop'

DLT component - updated proto & re-structured

See merge request teraflow-h2020/controller!114
parents fa8ec615 ea50d792
Loading
Loading
Loading
Loading
+55 −41
Original line number Diff line number Diff line
@@ -12,72 +12,86 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//Example of topology
syntax = "proto3";
package dlt;

import "context.proto";

service DltService {
  rpc RecordToDlt ( DltRecord ) returns ( RecordStatus ) {}
  rpc RecordToDlt   (DltRecord                 ) returns (       DltRecordStatus  ) {}
  rpc GetFromDlt    (DltRecordId               ) returns (       DltRecord        ) {}
  rpc SubscribeToDlt ( DltRecordSubscription ) returns ( stream DltRecord ) {}
  rpc GetDltStatus ( context.Empty ) returns ( DltStatus ) {}
  rpc SubscribeToDlt(DltRecordSubscription     ) returns (stream DltRecordEvent   ) {}
  rpc GetDltStatus  (context.TeraFlowController) returns (       DltPeerStatus    ) {}  // NEC is checkig if it is possible
  rpc GetDltPeers   (context.Empty             ) returns (       DltPeerStatusList) {}  // NEC is checkig if it is possible
}

message DltRecordSubscription {
  DltRecordType type = 1;
  DltRecordOperation operation = 2;
enum DltRecordTypeEnum {
  DLTRECORDTYPE_UNDEFINED = 0;
  DLTRECORDTYPE_CONTEXT   = 1;
  DLTRECORDTYPE_TOPOLOGY  = 2;
  DLTRECORDTYPE_DEVICE    = 3;
  DLTRECORDTYPE_LINK      = 4;
  DLTRECORDTYPE_SERVICE   = 5;
  DLTRECORDTYPE_SLICE     = 6;
}

enum DltRecordType {
  UNKNOWN = 0;
  SERVICE = 1;
  DEVICE = 2;
  SLICE = 3;
enum DltRecordOperationEnum {
  DLTRECORDOPERATION_UNDEFINED = 0;
  DLTRECORDOPERATION_ADD       = 1;
  DLTRECORDOPERATION_UPDATE    = 2;
  DLTRECORDOPERATION_DELETE    = 3;
}

enum DltRecordOperation {
  ADD = 0;
  UPDATE = 1;
  DELETE = 2;
enum DltRecordStatusEnum {
  DLTRECORDSTATUS_UNDEFINED = 0;
  DLTRECORDSTATUS_SUCCEEDED = 1;
  DLTRECORDSTATUS_FAILED    = 2;
}

message DltRecord {
  DltRecordId id = 1;
  DltRecordType type = 2;  
  DltRecordOperation operation = 3;
  string json = 4;
enum DltStatusEnum {
  DLTSTATUS_UNDEFINED    = 0;
  DLTSTATUS_NOTAVAILABLE = 1;
  DLTSTATUS_INITIALIZED  = 2;
  DLTSTATUS_AVAILABLE    = 3;
  DLTSTATUS_DEINIT       = 4;
}

message DltRecordId {
  context.Uuid id = 1;
  context.Uuid      domain_uuid = 1;          // unique identifier of domain owning the record
  DltRecordTypeEnum type        = 2;          // type of record
  context.Uuid      record_uuid = 3;          // unique identifier of the record within the domain context_uuid/topology_uuid
}

message RecordStatus {
  DltRecordId id = 1;
  DltRecordStatusEnum status = 2;
message DltRecord {
  DltRecordId            record_id = 1;       // record identifier
  DltRecordOperationEnum operation = 2;       // operation to be performed over the record
  string                 data_json = 3;       // record content: JSON-encoded record content
}

enum DltRecordStatusEnum {
  REQUESTED = 0;
  STORED = 1;
  DISABLED = 2;
message DltRecordSubscription {
  // retrieved events have to match ALL conditions.
  //   i.e., type in types requested, AND operation in operations requested
  // TODO: consider adding a more sophisticated filtering
  repeated DltRecordTypeEnum      type      = 1;  // selected event types, empty=all
  repeated DltRecordOperationEnum operation = 2;  // selected event operations, empty=all
}


message DltStatus {
  context.TeraFlowController ctl = 1;
  DltStatusEnum status = 2;
message DltRecordEvent {
  context.Event event     = 1;                // common event data (timestamp & event_type)
  DltRecordId   record_id = 2;                // record identifier associated with this event
}

enum DltStatusEnum {
  NOT_AVAILABLE = 0;
  INITIALIZED = 1;
  AVAILABLE = 2;
  DEINIT = 3;
message DltRecordStatus {
  DltRecordId         record_id     = 1;      // identifier of the associated record
  DltRecordStatusEnum status        = 2;      // status of the record
  string              error_message = 3;      // error message in case of failure, empty otherwise
}

message DltPeerStatus {
  context.TeraFlowController controller = 1;  // Identifier of the TeraFlow controller instance
  DltStatusEnum              status     = 2;  // Status of the TeraFlow controller instance
}


message DltPeerStatusList {
  repeated DltPeerStatus peers = 1;           // List of peers and their status
}

src/dlt/__init__.py

0 → 100644
+14 −0
Original line number Diff line number Diff line
# 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.
+14 −0
Original line number Diff line number Diff line
# 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.
+14 −0
Original line number Diff line number Diff line
# 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.
+49 −0
Original line number Diff line number Diff line
#!/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

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 kpi_sample_types.proto
python -m grpc_tools.protoc -I../../../proto --python_out=proto --grpc_python_out=proto dlt.proto

rm proto/context_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/dlt_pb2.py
sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/dlt_pb2_grpc.py
sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' proto/kpi_sample_types_pb2.py
Loading