Skip to content
Snippets Groups Projects
Commit ff0877b9 authored by Javier Diaz's avatar Javier Diaz
Browse files

Code cleanup

parent 63bc4333
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!259Resolve "(CTTC) Replace DLT Gateway functionality with an opensource and Hyper Ledger v2.4+ compliant version"
...@@ -10,7 +10,8 @@ COPY src/dlt/gateway/dltApp/package*.json ./ ...@@ -10,7 +10,8 @@ COPY src/dlt/gateway/dltApp/package*.json ./
# Copy tsconfig.json # Copy tsconfig.json
COPY src/dlt/gateway/dltApp/tsconfig*.json ./ COPY src/dlt/gateway/dltApp/tsconfig*.json ./
# Copy the proto folder # Copy the proto folder
COPY src/dlt/gateway/dltApp/proto/ ./proto COPY proto/context.proto ./proto
COPY proto/dlt_gateway.proto ./proto
# Copy the src folder # Copy the src folder
COPY src/dlt/gateway/dltApp/src/ ./src COPY src/dlt/gateway/dltApp/src/ ./src
......
// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// 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.
syntax = "proto3";
package context;
message Empty {}
message Uuid {
string uuid = 1;
}
enum EventTypeEnum {
EVENTTYPE_UNDEFINED = 0;
EVENTTYPE_CREATE = 1;
EVENTTYPE_UPDATE = 2;
EVENTTYPE_REMOVE = 3;
}
message Timestamp {
double timestamp = 1;
}
message Event {
Timestamp timestamp = 1;
EventTypeEnum event_type = 2;
}
message TeraFlowController {
ContextId context_id = 1;
string ip_address = 2;
uint32 port = 3;
}
message ContextId {
Uuid context_uuid = 1;
}
// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// 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.
syntax = "proto3";
package dlt;
import "context.proto";
service DltGatewayService {
rpc RecordToDlt (DltRecord ) returns ( DltRecordStatus ) {}
rpc GetFromDlt (DltRecordId ) returns ( DltRecord ) {}
rpc SubscribeToDlt(DltRecordSubscription ) returns (stream DltRecordEvent ) {}
rpc GetDltStatus (context.TeraFlowController) returns ( DltPeerStatus ) {} // NEC is checking if it is possible
rpc GetDltPeers (context.Empty ) returns ( DltPeerStatusList) {} // NEC is checking if it is possible
}
enum DltRecordTypeEnum {
DLTRECORDTYPE_UNDEFINED = 0;
DLTRECORDTYPE_CONTEXT = 1;
DLTRECORDTYPE_TOPOLOGY = 2;
DLTRECORDTYPE_DEVICE = 3;
DLTRECORDTYPE_LINK = 4;
DLTRECORDTYPE_SERVICE = 5;
DLTRECORDTYPE_SLICE = 6;
}
enum DltRecordOperationEnum {
DLTRECORDOPERATION_UNDEFINED = 0;
DLTRECORDOPERATION_ADD = 1;
DLTRECORDOPERATION_UPDATE = 2;
DLTRECORDOPERATION_DELETE = 3;
}
enum DltRecordStatusEnum {
DLTRECORDSTATUS_UNDEFINED = 0;
DLTRECORDSTATUS_SUCCEEDED = 1;
DLTRECORDSTATUS_FAILED = 2;
}
enum DltStatusEnum {
DLTSTATUS_UNDEFINED = 0;
DLTSTATUS_NOTAVAILABLE = 1;
DLTSTATUS_INITIALIZED = 2;
DLTSTATUS_AVAILABLE = 3;
DLTSTATUS_DEINIT = 4;
}
message DltRecordId {
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 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
}
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 DltRecordEvent {
context.Event event = 1; // common event data (timestamp & event_type)
DltRecordId record_id = 2; // record identifier associated with this event
}
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
}
// GENERATED CODE -- DO NOT EDIT!
// Original file comments:
// Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// 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.
//
'use strict';
var grpc = require('grpc');
var dlt_service_pb = require('./dlt_service_pb.js');
var context_pb = require('./context_pb.js');
function serialize_context_Empty(arg) {
if (!(arg instanceof context_pb.Empty)) {
throw new Error('Expected argument of type context.Empty');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_context_Empty(buffer_arg) {
return context_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_context_TeraFlowController(arg) {
if (!(arg instanceof context_pb.TeraFlowController)) {
throw new Error('Expected argument of type context.TeraFlowController');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_context_TeraFlowController(buffer_arg) {
return context_pb.TeraFlowController.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltPeerStatus(arg) {
if (!(arg instanceof dlt_service_pb.DltPeerStatus)) {
throw new Error('Expected argument of type dlt.DltPeerStatus');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltPeerStatus(buffer_arg) {
return dlt_service_pb.DltPeerStatus.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltPeerStatusList(arg) {
if (!(arg instanceof dlt_service_pb.DltPeerStatusList)) {
throw new Error('Expected argument of type dlt.DltPeerStatusList');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltPeerStatusList(buffer_arg) {
return dlt_service_pb.DltPeerStatusList.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltRecord(arg) {
if (!(arg instanceof dlt_service_pb.DltRecord)) {
throw new Error('Expected argument of type dlt.DltRecord');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltRecord(buffer_arg) {
return dlt_service_pb.DltRecord.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltRecordEvent(arg) {
if (!(arg instanceof dlt_service_pb.DltRecordEvent)) {
throw new Error('Expected argument of type dlt.DltRecordEvent');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltRecordEvent(buffer_arg) {
return dlt_service_pb.DltRecordEvent.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltRecordId(arg) {
if (!(arg instanceof dlt_service_pb.DltRecordId)) {
throw new Error('Expected argument of type dlt.DltRecordId');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltRecordId(buffer_arg) {
return dlt_service_pb.DltRecordId.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltRecordStatus(arg) {
if (!(arg instanceof dlt_service_pb.DltRecordStatus)) {
throw new Error('Expected argument of type dlt.DltRecordStatus');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltRecordStatus(buffer_arg) {
return dlt_service_pb.DltRecordStatus.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_dlt_DltRecordSubscription(arg) {
if (!(arg instanceof dlt_service_pb.DltRecordSubscription)) {
throw new Error('Expected argument of type dlt.DltRecordSubscription');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_dlt_DltRecordSubscription(buffer_arg) {
return dlt_service_pb.DltRecordSubscription.deserializeBinary(new Uint8Array(buffer_arg));
}
var DltGatewayServiceService = exports.DltGatewayServiceService = {
recordToDlt: {
path: '/dlt.DltGatewayService/RecordToDlt',
requestStream: false,
responseStream: false,
requestType: dlt_service_pb.DltRecord,
responseType: dlt_service_pb.DltRecordStatus,
requestSerialize: serialize_dlt_DltRecord,
requestDeserialize: deserialize_dlt_DltRecord,
responseSerialize: serialize_dlt_DltRecordStatus,
responseDeserialize: deserialize_dlt_DltRecordStatus,
},
getFromDlt: {
path: '/dlt.DltGatewayService/GetFromDlt',
requestStream: false,
responseStream: false,
requestType: dlt_service_pb.DltRecordId,
responseType: dlt_service_pb.DltRecord,
requestSerialize: serialize_dlt_DltRecordId,
requestDeserialize: deserialize_dlt_DltRecordId,
responseSerialize: serialize_dlt_DltRecord,
responseDeserialize: deserialize_dlt_DltRecord,
},
subscribeToDlt: {
path: '/dlt.DltGatewayService/SubscribeToDlt',
requestStream: false,
responseStream: true,
requestType: dlt_service_pb.DltRecordSubscription,
responseType: dlt_service_pb.DltRecordEvent,
requestSerialize: serialize_dlt_DltRecordSubscription,
requestDeserialize: deserialize_dlt_DltRecordSubscription,
responseSerialize: serialize_dlt_DltRecordEvent,
responseDeserialize: deserialize_dlt_DltRecordEvent,
},
getDltStatus: {
path: '/dlt.DltGatewayService/GetDltStatus',
requestStream: false,
responseStream: false,
requestType: context_pb.TeraFlowController,
responseType: dlt_service_pb.DltPeerStatus,
requestSerialize: serialize_context_TeraFlowController,
requestDeserialize: deserialize_context_TeraFlowController,
responseSerialize: serialize_dlt_DltPeerStatus,
responseDeserialize: deserialize_dlt_DltPeerStatus,
},
getDltPeers: {
path: '/dlt.DltGatewayService/GetDltPeers',
requestStream: false,
responseStream: false,
requestType: context_pb.Empty,
responseType: dlt_service_pb.DltPeerStatusList,
requestSerialize: serialize_context_Empty,
requestDeserialize: deserialize_context_Empty,
responseSerialize: serialize_dlt_DltPeerStatusList,
responseDeserialize: deserialize_dlt_DltPeerStatusList,
},
};
exports.DltGatewayServiceClient = grpc.makeGenericClientConstructor(DltGatewayServiceService);
This diff is collapsed.
...@@ -20,7 +20,7 @@ const { connectToNetwork } = require('../dist/fabricConnect'); ...@@ -20,7 +20,7 @@ const { connectToNetwork } = require('../dist/fabricConnect');
const utf8Decoder = new TextDecoder(); const utf8Decoder = new TextDecoder();
// Load the protocol buffer definitions // Load the protocol buffer definitions
const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_service.proto'); const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_gateway.proto');
const packageDefinition = protoLoader.loadSync(PROTO_PATH, { const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true, keepCase: true,
longs: String, longs: String,
......
...@@ -17,7 +17,7 @@ const grpc = require('@grpc/grpc-js'); ...@@ -17,7 +17,7 @@ const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader'); const protoLoader = require('@grpc/proto-loader');
const path = require('path'); const path = require('path');
const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_service.proto'); const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_gateway.proto');
const packageDefinition = protoLoader.loadSync(PROTO_PATH, { const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true, keepCase: true,
longs: String, longs: String,
......
...@@ -20,7 +20,7 @@ const fs = require('fs').promises; ...@@ -20,7 +20,7 @@ const fs = require('fs').promises;
const { v4: uuidv4 } = require('uuid'); // Import the UUID library const { v4: uuidv4 } = require('uuid'); // Import the UUID library
const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_service.proto'); const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_gateway.proto');
const packageDefinition = protoLoader.loadSync(PROTO_PATH, { const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true, keepCase: true,
longs: String, longs: String,
......
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