From 52bab918c4ba712cb1d0925375d6309fa01a1341 Mon Sep 17 00:00:00 2001 From: Jose Luis Carcel <jose.carcel@atos.net> Date: Wed, 26 Jul 2023 07:42:54 +0000 Subject: [PATCH 01/14] Update file context.proto --- proto/context.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proto/context.proto b/proto/context.proto index 55a80470d..87680a5b9 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -448,9 +448,10 @@ message EndPointId { message EndPoint { EndPointId endpoint_id = 1; string name = 2; - string endpoint_type = 3; + string endpoint_type = 3; // == 'smartnics' repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; Location endpoint_location = 5; + map<string, google.Any> capabilities = 6; } message EndPointName { -- GitLab From ab9a0dcd86da5bcd9e2230b9b9bbd18b3c696797 Mon Sep 17 00:00:00 2001 From: Jose Luis Carcel <jose.carcel@atos.net> Date: Wed, 26 Jul 2023 08:18:08 +0000 Subject: [PATCH 02/14] Create Context Smartnics --- proto/context-ext-smartnics.proto | 100 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 proto/context-ext-smartnics.proto diff --git a/proto/context-ext-smartnics.proto b/proto/context-ext-smartnics.proto new file mode 100644 index 000000000..f4783da73 --- /dev/null +++ b/proto/context-ext-smartnics.proto @@ -0,0 +1,100 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +// References: +// https://www.nvidia.com/content/dam/en-zz/Solutions/data-center/products/a30-gpu/pdf/a30-datasheet.pdf +// https://www.nvidia.com/content/dam/en-zz/Solutions/Data-Center/documents/datasheet-nvidia-bluefield-2-dpu.pdf +// https://www.nvidia.com/content/dam/en-zz/Solutions/networking/ethernet-adapters/connectX-6-dx-datasheet.pdf +// converged accel: https://www.nvidia.com/content/dam/en-zz/Solutions/gtcf21/converged-accelerator/pdf/datasheet.pdf + +// bluefield-2 = connectX-6 + DPUs +// conv_accel = bluefield-2 + GPU + +syntax = "proto3"; +package context-ext-smartnics; + +import context; +import "kpi_sample_types.proto"; + +message SmartnicsCapabilities { + string vendor = 1; + string model = 2; + string serial_number = 3; + repeated Transceiver transceivers = 4; + repeated DPU dpus = 5; + repeated GPU gpus = 6; +} + +enum TransceiverPortTypeEnum { + TRANSCEIVER_PORT_TYPE_UNDEFINED = 0; + TRANSCEIVER_PORT_TYPE_SFP = 1; + TRANSCEIVER_PORT_TYPE_SFP_PLUS = 2; + TRANSCEIVER_PORT_TYPE_QSFP_28 = 3; + TRANSCEIVER_PORT_TYPE_QSFP_56 = 4; + TRANSCEIVER_PORT_TYPE_QSFP_DD = 5; +} + +enum TransceiverPortSpeedEnum { + TRANSCEIVER_PORT_SPEED_UNDEFINED = 0; + TRANSCEIVER_PORT_SPEED_1G = 1; + TRANSCEIVER_PORT_SPEED_10G = 2; + TRANSCEIVER_PORT_SPEED_25G = 3; + TRANSCEIVER_PORT_SPEED_40G = 4; + TRANSCEIVER_PORT_SPEED_100G = 5; + TRANSCEIVER_PORT_SPEED_200G = 6; + TRANSCEIVER_PORT_SPEED_400G = 7; + TRANSCEIVER_PORT_SPEED_800G = 8; +} + +message Transceiver { + TransceiverPortTypeEnum port_type = 1; + repeated TransceiverPortSpeedEnum port_speeds = 2; + repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; +} + +message DPU { + uint32 num_cores = 1; + repeated DPU_Core cores = 2; + repeated DPU_Memory memories = 3; +} + +enum DpuCoreArchitectureEnum { + DPU_CORE_ARCHITECTURE_UNDEFINED = 0; + DPU_CORE_ARCHITECTURE_32BIT = 1; + DPU_CORE_ARCHITECTURE_64BIT = 2; +} + +message DPU_Core { + string model = 1; // Armv8 A72 + enum DpuCoreArchitectureEnum architecture = 2; // 64-bit + // define cache: + // -- 1MB L2 cache per 2 cores + // -- 6MB L3 cache with plurality of eviction policies +} + +message DPU_Memory { + // define RAM and eMMC + // -- DDR4 DIMM Support + // -- > Single DDR4 DRAM controller + // -- > 16GB / 32GB of on-board DDR4 + // -- > ECC error protection support +} + +message GPU { + enum Architecture architecture = 1; + enum ComputeCapabilities compute_capabilities = 2; + uint64 memory_size_mb = 3; + uint32 num_cores = 4; + // complete with specs of GPU +} -- GitLab From baf109068617e6002665b0a3b07888c160e37da9 Mon Sep 17 00:00:00 2001 From: Jose Luis Carcel <jose.carcel@atos.net> Date: Wed, 26 Jul 2023 08:58:00 +0000 Subject: [PATCH 03/14] Add new directory --- src/device/service/drivers/smartnic_probes/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/device/service/drivers/smartnic_probes/.gitkeep diff --git a/src/device/service/drivers/smartnic_probes/.gitkeep b/src/device/service/drivers/smartnic_probes/.gitkeep new file mode 100644 index 000000000..e69de29bb -- GitLab From 1e17fbc1da0fb88c5dead7d83de277ea118d7323 Mon Sep 17 00:00:00 2001 From: Jose Luis Carcel <jose.carcel@atos.net> Date: Wed, 26 Jul 2023 08:58:54 +0000 Subject: [PATCH 04/14] Added Probes-Agent YANG --- .../drivers/smartnic_probes/probes-agent.yang | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/device/service/drivers/smartnic_probes/probes-agent.yang diff --git a/src/device/service/drivers/smartnic_probes/probes-agent.yang b/src/device/service/drivers/smartnic_probes/probes-agent.yang new file mode 100644 index 000000000..71e1337c4 --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/probes-agent.yang @@ -0,0 +1,44 @@ +probes-agent.yang + +# augment de openconfig probes + +augment /probes/probe { + leaf probe_type { + type enumeration { + enum plain_traffic; + enum morpheus_pipeline; + } + } +} + +augment /probes/probe/tests/test/config { + uses morpheus_pipelines; +} + +grouping morpheus_pipelines { + list morpheus_pipelines { + key name; + uses morpheus_pipeline; + } +} + +grouping morpheus_pipeline { + leaf name { type string; } + leaf num_threads { type uint16; } + // other settings + // https://github.com/nv-morpheus/Morpheus/blob/branch-23.11/examples/abp_pcap_detection/run.py + + list stages { + key name; + uses morpheus_pipeline_stage; + } +} + +grouping morpheus_pipeline_stage { + leaf name { type string; } + // enum stage type + // stage parameters + // soportar custom stages + // https://github.com/nv-morpheus/Morpheus/blob/branch-23.11/examples/abp_pcap_detection/run.py + +} -- GitLab From af997d4865cd625ae2ed9feb06f0f35a84325df6 Mon Sep 17 00:00:00 2001 From: Ricard Vilalta <ricard.vilalta@cttc.es> Date: Thu, 27 Jul 2023 07:57:31 +0000 Subject: [PATCH 05/14] Add new directory --- .../drivers/smartnic_probes/smartnics_probes_agent/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep diff --git a/src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep b/src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep new file mode 100644 index 000000000..e69de29bb -- GitLab From e6505c21208113eff2b8e5dbe7fed0b8ed2f1f7e Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Thu, 3 Aug 2023 12:14:12 +0200 Subject: [PATCH 06/14] Update Context SmartNICs --- proto/context-ext-smartnics.proto | 56 ++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/proto/context-ext-smartnics.proto b/proto/context-ext-smartnics.proto index f4783da73..2a3fe6138 100644 --- a/proto/context-ext-smartnics.proto +++ b/proto/context-ext-smartnics.proto @@ -13,8 +13,6 @@ // limitations under the License. // References: -// https://www.nvidia.com/content/dam/en-zz/Solutions/data-center/products/a30-gpu/pdf/a30-datasheet.pdf -// https://www.nvidia.com/content/dam/en-zz/Solutions/Data-Center/documents/datasheet-nvidia-bluefield-2-dpu.pdf // https://www.nvidia.com/content/dam/en-zz/Solutions/networking/ethernet-adapters/connectX-6-dx-datasheet.pdf // converged accel: https://www.nvidia.com/content/dam/en-zz/Solutions/gtcf21/converged-accelerator/pdf/datasheet.pdf @@ -77,24 +75,50 @@ enum DpuCoreArchitectureEnum { message DPU_Core { string model = 1; // Armv8 A72 - enum DpuCoreArchitectureEnum architecture = 2; // 64-bit - // define cache: - // -- 1MB L2 cache per 2 cores - // -- 6MB L3 cache with plurality of eviction policies + enum DpuCoreArchitectureEnum architecture = 2; + uint64 l2_cache_size_mb = 3; + uint64 l3_cache_size_mb = 4; } message DPU_Memory { - // define RAM and eMMC - // -- DDR4 DIMM Support - // -- > Single DDR4 DRAM controller - // -- > 16GB / 32GB of on-board DDR4 - // -- > ECC error protection support + string RamMemoryType = 1; //On-Board DDR4 + string eMMCMemoryType = 2; //eMMC + enum DpuRamMemorySizeGB RamMemorySizeGB = 3; + enum DpueMMCMemorySizeGB eMMCMemorySizeGB = 4; +} + +enum DpuRamMemorySizeGB { + DPU_MEMORY_DDR4_RAM_UNDEFINED = 0; + DPU_MEMORY_DDR4_RAM_16GB = 1; + DPU_MEMORY_DDR4_RAM_32GB = 2; +} + +enum DpueMMCMemorySizeGB { + DPU_MEMORY_eMMC_UNDEFINED = 0; + DPU_MEMORY_eMMC_32GB = 1; + DPU_MEMORY_eMMC_64GB = 2; + DPU_MEMORY_eMMC_128GB = 3; } message GPU { - enum Architecture architecture = 1; - enum ComputeCapabilities compute_capabilities = 2; - uint64 memory_size_mb = 3; - uint32 num_cores = 4; - // complete with specs of GPU + enum Architecture architecture = 1; //AMPERE? + enum ComputeCapabilities compute_capabilities = 2; //MIG? + uint64 memory_size_gb = 3; //24 GB HBM2 + uint32 num_CUDA_cores = 4; //3804 + uint32 num_Tensor_cores = 5; //224 + uint32 peak_fp_32 = 6; //10.3TF + uint32 peak_fp_64 = 7; //5.2TF + uint32 peak fp_64_tensor_core = 8; //10.3TF +} + +enum Architecture { + ARCH_UNDEFINED = 0; + ARCH_AMPERE = 1; +} + +enum ComputeCapabilities { + MIG_UNDEFINED = 0; + MIG_4_AT_6GB = 1; + MIG_2_AT_12GB = 2; + MIG_1_AT_24GB = 3; } -- GitLab From 6d77d5e611716a23a7a23148167ce3285714dd81 Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Thu, 3 Aug 2023 12:32:01 +0200 Subject: [PATCH 07/14] Update Context SmartNICs --- proto/context-ext-smartnics.proto | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/proto/context-ext-smartnics.proto b/proto/context-ext-smartnics.proto index 2a3fe6138..f54535e7b 100644 --- a/proto/context-ext-smartnics.proto +++ b/proto/context-ext-smartnics.proto @@ -15,14 +15,13 @@ // References: // https://www.nvidia.com/content/dam/en-zz/Solutions/networking/ethernet-adapters/connectX-6-dx-datasheet.pdf // converged accel: https://www.nvidia.com/content/dam/en-zz/Solutions/gtcf21/converged-accelerator/pdf/datasheet.pdf - // bluefield-2 = connectX-6 + DPUs // conv_accel = bluefield-2 + GPU syntax = "proto3"; package context-ext-smartnics; -import context; +import "context"; import "kpi_sample_types.proto"; message SmartnicsCapabilities { @@ -75,7 +74,7 @@ enum DpuCoreArchitectureEnum { message DPU_Core { string model = 1; // Armv8 A72 - enum DpuCoreArchitectureEnum architecture = 2; + DpuCoreArchitectureEnum architecture = 2; uint64 l2_cache_size_mb = 3; uint64 l3_cache_size_mb = 4; } @@ -83,8 +82,8 @@ message DPU_Core { message DPU_Memory { string RamMemoryType = 1; //On-Board DDR4 string eMMCMemoryType = 2; //eMMC - enum DpuRamMemorySizeGB RamMemorySizeGB = 3; - enum DpueMMCMemorySizeGB eMMCMemorySizeGB = 4; + DpuRamMemorySizeGB RamMemorySizeGB = 3; + DpueMMCMemorySizeGB eMMCMemorySizeGB = 4; } enum DpuRamMemorySizeGB { @@ -100,17 +99,6 @@ enum DpueMMCMemorySizeGB { DPU_MEMORY_eMMC_128GB = 3; } -message GPU { - enum Architecture architecture = 1; //AMPERE? - enum ComputeCapabilities compute_capabilities = 2; //MIG? - uint64 memory_size_gb = 3; //24 GB HBM2 - uint32 num_CUDA_cores = 4; //3804 - uint32 num_Tensor_cores = 5; //224 - uint32 peak_fp_32 = 6; //10.3TF - uint32 peak_fp_64 = 7; //5.2TF - uint32 peak fp_64_tensor_core = 8; //10.3TF -} - enum Architecture { ARCH_UNDEFINED = 0; ARCH_AMPERE = 1; @@ -122,3 +110,16 @@ enum ComputeCapabilities { MIG_2_AT_12GB = 2; MIG_1_AT_24GB = 3; } + + +message GPU { + Architecture architecture = 1; //AMPERE? + ComputeCapabilities compute_capabilities = 2; //MIG? + uint64 memory_size_gb = 3; //24 GB HBM2 + uint32 num_CUDA_cores = 4; //3804 + uint32 num_Tensor_cores = 5; //224 + uint32 peak_fp_32 = 6; //10.3TF + uint32 peak_fp_64 = 7; //5.2TF + uint32 peak_fp_64_tensor_core = 8; //10.3TF +} + -- GitLab From 69d1887348454e7ab1aed261b60e3dc7cd9afffb Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Thu, 21 Sep 2023 16:42:23 +0200 Subject: [PATCH 08/14] SmartNIC, NOS and NS Data Models --- proto/context-ext-smartnics.proto | 31 +++---- proto/nfv_client.proto | 44 +++++++++ .../drivers/smartnic_probes/probes-agent.yang | 89 ++++++++++++++++--- ztp_device.yang | 43 +++++++++ 4 files changed, 180 insertions(+), 27 deletions(-) create mode 100644 proto/nfv_client.proto create mode 100644 ztp_device.yang diff --git a/proto/context-ext-smartnics.proto b/proto/context-ext-smartnics.proto index f54535e7b..953b27e86 100644 --- a/proto/context-ext-smartnics.proto +++ b/proto/context-ext-smartnics.proto @@ -16,7 +16,7 @@ // https://www.nvidia.com/content/dam/en-zz/Solutions/networking/ethernet-adapters/connectX-6-dx-datasheet.pdf // converged accel: https://www.nvidia.com/content/dam/en-zz/Solutions/gtcf21/converged-accelerator/pdf/datasheet.pdf // bluefield-2 = connectX-6 + DPUs -// conv_accel = bluefield-2 + GPU +// conv_accel = bluefield-2 + GPU (A30) syntax = "proto3"; package context-ext-smartnics; @@ -73,15 +73,15 @@ enum DpuCoreArchitectureEnum { } message DPU_Core { - string model = 1; // Armv8 A72 + string model = 1; DpuCoreArchitectureEnum architecture = 2; uint64 l2_cache_size_mb = 3; uint64 l3_cache_size_mb = 4; } message DPU_Memory { - string RamMemoryType = 1; //On-Board DDR4 - string eMMCMemoryType = 2; //eMMC + string RamMemoryType = 1; + string eMMCMemoryType = 2; DpuRamMemorySizeGB RamMemorySizeGB = 3; DpueMMCMemorySizeGB eMMCMemorySizeGB = 4; } @@ -99,27 +99,28 @@ enum DpueMMCMemorySizeGB { DPU_MEMORY_eMMC_128GB = 3; } -enum Architecture { +enum GPUArchitecture { ARCH_UNDEFINED = 0; ARCH_AMPERE = 1; } -enum ComputeCapabilities { +enum GPUComputeCapabilities { MIG_UNDEFINED = 0; - MIG_4_AT_6GB = 1; + MIG_4_AT_6GB = 1; MIG_2_AT_12GB = 2; MIG_1_AT_24GB = 3; } message GPU { - Architecture architecture = 1; //AMPERE? - ComputeCapabilities compute_capabilities = 2; //MIG? - uint64 memory_size_gb = 3; //24 GB HBM2 - uint32 num_CUDA_cores = 4; //3804 - uint32 num_Tensor_cores = 5; //224 - uint32 peak_fp_32 = 6; //10.3TF - uint32 peak_fp_64 = 7; //5.2TF - uint32 peak_fp_64_tensor_core = 8; //10.3TF + string model = 1; + GPUArchitecture architecture = 2; + GPUComputeCapabilities compute_capabilities = 3; + uint64 memory_size_gb = 4; + uint32 num_CUDA_cores = 5; + uint32 num_Tensor_cores = 6; + uint32 peak_fp_32 = 7; + uint32 peak_fp_64 = 8; + uint32 peak_fp_64_tensor_core = 9; } diff --git a/proto/nfv_client.proto b/proto/nfv_client.proto new file mode 100644 index 000000000..d880a394c --- /dev/null +++ b/proto/nfv_client.proto @@ -0,0 +1,44 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 nfv_client; + +import "context.proto"; + +message Nsd { + string nsd_name = 1; +} + +message Ns { + string ns_id=1; + string ns_name=2; + string nsd_name=3; + string vim_account=4; +} + +message NsList { + repeated Ns ns = 1; +} + +message NsdList { + repeated Nsd nsd = 1; +} + +service nfv_client { + rpc CreateNs (ns) returns (ns_id) {} // Stable not final + rpc DeleteNs (ns) returns (context.Empty) {} +} + + diff --git a/src/device/service/drivers/smartnic_probes/probes-agent.yang b/src/device/service/drivers/smartnic_probes/probes-agent.yang index 71e1337c4..6029cd204 100644 --- a/src/device/service/drivers/smartnic_probes/probes-agent.yang +++ b/src/device/service/drivers/smartnic_probes/probes-agent.yang @@ -1,8 +1,18 @@ -probes-agent.yang +module probes-agent { -# augment de openconfig probes +namespace "urn:probes-agent"; +prefix "probes-agent"; -augment /probes/probe { +import openconfig-probes { prefix oc-probes; } + +organization "EVIDEN"; +contact "jose.carcel@eviden.com"; +description "Basic example of data model for configuring SmartNICs through Morpheus API"; +revision "2023-08-03" { + description "Basic example of data model for configuring SmartNICs through Morpheus API"; +} + +augment '/oc-probes:probes/oc-probes:probe' { leaf probe_type { type enumeration { enum plain_traffic; @@ -11,7 +21,7 @@ augment /probes/probe { } } -augment /probes/probe/tests/test/config { +augment '/oc-probes:probes/oc-probes:probe/oc-probes:tests/oc-probes:test/oc-probes:config' { uses morpheus_pipelines; } @@ -25,20 +35,75 @@ grouping morpheus_pipelines { grouping morpheus_pipeline { leaf name { type string; } leaf num_threads { type uint16; } - // other settings - // https://github.com/nv-morpheus/Morpheus/blob/branch-23.11/examples/abp_pcap_detection/run.py - + leaf pipeline_batch_size {type uint64; } + leaf model_max_batch_size {type uint64; } + leaf input_file {type string; } + leaf output_file {type string; } + leaf model_fea_length {type uint16; } + leaf model_name {type string; } + leaf iterative {type boolean; } + leaf server_url {type string; } + leaf file_type {type files; } list stages { key name; uses morpheus_pipeline_stage; } } +typedef files { + type enumeration { + enum "auto"; + enum "csv"; + enum "json"; + } +} + +typedef stage { + type enumeration { + enum "FileSourceStage"; + enum "DeserializeStage"; + enum "AbpPcapPreprocessingStage"; + enum "MonitorStage"; + enum "TritonInferenceStage"; + enum "AddClassificationsStage"; + enum "SerializeStage"; + enum "WriteToFileStage"; + } +} + +grouping prob { + leaf value { + type string; + description "probs"; + } +} + +grouping conf { + leaf mode {type string; } + leaf num_threads { type uint16; } + leaf pipeline_batch_size { type uint64; } + leaf model_max_batch_size { type uint64; } + leaf model_fea_length { type uint64; } + list class_labels { + key "value"; + uses prob; } +} + grouping morpheus_pipeline_stage { leaf name { type string; } - // enum stage type - // stage parameters - // soportar custom stages - // https://github.com/nv-morpheus/Morpheus/blob/branch-23.11/examples/abp_pcap_detection/run.py - + leaf stage_type {type stage; } + list configuration {key "mode"; uses conf;} + leaf filename {type string;} + leaf iterative {type boolean;} + leaf file_type {type files;} + leaf filter_null {type boolean;} + leaf descriptions {type string;} + leaf model_name {type string;} + leaf server_url {type string;} + leaf force_convert_inputs {type boolean;} + leaf unit {type string;} + list labels {key "value"; uses prob;} + leaf kwargs {type empty;} + leaf overwrite {type boolean;} } +} \ No newline at end of file diff --git a/ztp_device.yang b/ztp_device.yang new file mode 100644 index 000000000..748bc54c3 --- /dev/null +++ b/ztp_device.yang @@ -0,0 +1,43 @@ +module ztp_device { + + yang-version "1"; + + namespace "urn:ztp_nos"; + prefix "ztp_nos"; + organization "EVIDEN"; + contact "jose.carcel@eviden.com"; + description "Basic example of data model for modelling NOS ZTP Device"; + + revision "2023-08-03" { + description "Basic example of data model for modelling NOS ZTP Device"; + reference ""; + } + + grouping config{ + leaf ztp_device_sw_url{ + type string; + } + leaf config_script_url{ + type string; + } + } + + typedef state { + type enumeration{ + enum "UNDEF"; + enum "INIT_HW"; + enum "INIT_SW"; + enum "CONFIGURED"; + enum "RUNNING"; + enum "UPDATING"; + enum "MIGRATING"; + enum "DELETED"; + } + } + + grouping state { + leaf ztp_device_state { + type state; + } + } +} \ No newline at end of file -- GitLab From 432b8193084f06f381afad5bf2dac269de747d84 Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Tue, 3 Oct 2023 17:26:37 +0200 Subject: [PATCH 09/14] Update SmartNIC, NOS and NS Data Models --- proto/any.proto | 162 +++++ proto/context.proto | 3 +- ...nics.proto => context_ext_smartnics.proto} | 37 +- proto/nfv_client.proto | 11 +- proto/nos_client.proto | 33 + .../automation/src/ztp-agent/ztp_device.yang | 3 + .../smartnic_probes/ietf-yang-types.yang | 480 +++++++++++++++ .../openconfig-extensions.yang | 206 +++++++ .../openconfig-inet-types.yang | 478 +++++++++++++++ .../openconfig-probes-types.yang | 86 +++ .../smartnic_probes/openconfig-probes.yang | 575 ++++++++++++++++++ .../smartnic_probes/openconfig-types.yang | 471 ++++++++++++++ .../drivers/smartnic_probes/probes-agent.yang | 150 +++-- .../references_probes_libraries.txt | 6 + 14 files changed, 2611 insertions(+), 90 deletions(-) create mode 100644 proto/any.proto rename proto/{context-ext-smartnics.proto => context_ext_smartnics.proto} (79%) create mode 100644 proto/nos_client.proto rename ztp_device.yang => src/automation/src/ztp-agent/ztp_device.yang (91%) create mode 100644 src/device/service/drivers/smartnic_probes/ietf-yang-types.yang create mode 100644 src/device/service/drivers/smartnic_probes/openconfig-extensions.yang create mode 100644 src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang create mode 100644 src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang create mode 100644 src/device/service/drivers/smartnic_probes/openconfig-probes.yang create mode 100644 src/device/service/drivers/smartnic_probes/openconfig-types.yang create mode 100644 src/device/service/drivers/smartnic_probes/references_probes_libraries.txt diff --git a/proto/any.proto b/proto/any.proto new file mode 100644 index 000000000..eff44e509 --- /dev/null +++ b/proto/any.proto @@ -0,0 +1,162 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/known/anypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "AnyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// `Any` contains an arbitrary serialized protocol buffer message along with a +// URL that describes the type of the serialized message. +// +// Protobuf library provides support to pack/unpack Any values in the form +// of utility functions or additional generated methods of the Any type. +// +// Example 1: Pack and unpack a message in C++. +// +// Foo foo = ...; +// Any any; +// any.PackFrom(foo); +// ... +// if (any.UnpackTo(&foo)) { +// ... +// } +// +// Example 2: Pack and unpack a message in Java. +// +// Foo foo = ...; +// Any any = Any.pack(foo); +// ... +// if (any.is(Foo.class)) { +// foo = any.unpack(Foo.class); +// } +// // or ... +// if (any.isSameTypeAs(Foo.getDefaultInstance())) { +// foo = any.unpack(Foo.getDefaultInstance()); +// } +// +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } +// ... +// foo := &pb.Foo{} +// if err := any.UnmarshalTo(foo); err != nil { +// ... +// } +// +// The pack methods provided by protobuf library will by default use +// 'type.googleapis.com/full.type.name' as the type URL and the unpack +// methods only use the fully qualified type name after the last '/' +// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// name "y.z". +// +// JSON +// ==== +// The JSON representation of an `Any` value uses the regular +// representation of the deserialized, embedded message, with an +// additional field `@type` which contains the type URL. Example: +// +// package google.profile; +// message Person { +// string first_name = 1; +// string last_name = 2; +// } +// +// { +// "@type": "type.googleapis.com/google.profile.Person", +// "firstName": <string>, +// "lastName": <string> +// } +// +// If the embedded message type is well-known and has a custom JSON +// representation, that representation will be embedded adding a field +// `value` which holds the custom JSON in addition to the `@type` +// field. Example (for message [google.protobuf.Duration][]): +// +// { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": "1.212s" +// } +// +message Any { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. As of May 2023, there are no widely used type server + // implementations and no plans to implement one. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + // + string type_url = 1; + + // Must be a valid serialized protocol buffer of the above specified type. + bytes value = 2; +} diff --git a/proto/context.proto b/proto/context.proto index 87680a5b9..856d6f71d 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -15,6 +15,7 @@ syntax = "proto3"; package context; +import "any.proto"; import "acl.proto"; import "kpi_sample_types.proto"; @@ -451,7 +452,7 @@ message EndPoint { string endpoint_type = 3; // == 'smartnics' repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; Location endpoint_location = 5; - map<string, google.Any> capabilities = 6; + map<string, google.protobuf.Any> capabilities = 6; } message EndPointName { diff --git a/proto/context-ext-smartnics.proto b/proto/context_ext_smartnics.proto similarity index 79% rename from proto/context-ext-smartnics.proto rename to proto/context_ext_smartnics.proto index 953b27e86..fe834b493 100644 --- a/proto/context-ext-smartnics.proto +++ b/proto/context_ext_smartnics.proto @@ -19,9 +19,8 @@ // conv_accel = bluefield-2 + GPU (A30) syntax = "proto3"; -package context-ext-smartnics; +package context_ext_smartnics; -import "context"; import "kpi_sample_types.proto"; message SmartnicsCapabilities { @@ -82,40 +81,14 @@ message DPU_Core { message DPU_Memory { string RamMemoryType = 1; string eMMCMemoryType = 2; - DpuRamMemorySizeGB RamMemorySizeGB = 3; - DpueMMCMemorySizeGB eMMCMemorySizeGB = 4; + uint64 RamMemorySizeGB = 3; + uint64 eMMCMemorySizeGB = 4; } -enum DpuRamMemorySizeGB { - DPU_MEMORY_DDR4_RAM_UNDEFINED = 0; - DPU_MEMORY_DDR4_RAM_16GB = 1; - DPU_MEMORY_DDR4_RAM_32GB = 2; -} - -enum DpueMMCMemorySizeGB { - DPU_MEMORY_eMMC_UNDEFINED = 0; - DPU_MEMORY_eMMC_32GB = 1; - DPU_MEMORY_eMMC_64GB = 2; - DPU_MEMORY_eMMC_128GB = 3; -} - -enum GPUArchitecture { - ARCH_UNDEFINED = 0; - ARCH_AMPERE = 1; -} - -enum GPUComputeCapabilities { - MIG_UNDEFINED = 0; - MIG_4_AT_6GB = 1; - MIG_2_AT_12GB = 2; - MIG_1_AT_24GB = 3; -} - - message GPU { string model = 1; - GPUArchitecture architecture = 2; - GPUComputeCapabilities compute_capabilities = 3; + string architecture = 2; + string compute_capabilities = 3; uint64 memory_size_gb = 4; uint32 num_CUDA_cores = 5; uint32 num_Tensor_cores = 6; diff --git a/proto/nfv_client.proto b/proto/nfv_client.proto index d880a394c..d903e7907 100644 --- a/proto/nfv_client.proto +++ b/proto/nfv_client.proto @@ -19,6 +19,7 @@ import "context.proto"; message Nsd { string nsd_name = 1; + string config_params=2; } message Ns { @@ -26,6 +27,9 @@ message Ns { string ns_name=2; string nsd_name=3; string vim_account=4; + string config_params=5; + string status = 6; + string status_message = 7; } message NsList { @@ -37,8 +41,11 @@ message NsdList { } service nfv_client { - rpc CreateNs (ns) returns (ns_id) {} // Stable not final - rpc DeleteNs (ns) returns (context.Empty) {} + rpc GetNsList (context.Empty) returns (NsList) {} + rpc GetNsdList (context.Empty) returns (NsdList) {} + rpc CreateNs (Ns) returns (Ns) {} + rpc UpdateNs (Ns) returns (Ns) {} + rpc DeleteNs (Ns) returns (context.Empty) {} } diff --git a/proto/nos_client.proto b/proto/nos_client.proto new file mode 100644 index 000000000..e0e35a648 --- /dev/null +++ b/proto/nos_client.proto @@ -0,0 +1,33 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 nos_client; + +message NOS_SW { + string ztp_device_sw_url = 1; + bytes ztp_device_sw_file = 2; +} + +message Config_Script { + string config_script_url = 1; + bytes config_script_file = 2; +} + +service nos_client { + rpc GetNOSFile (NOS_SW) returns (NOS_SW) {} + rpc GetConfigScriptFile (Config_Script) returns (Config_Script) {} +} + + diff --git a/ztp_device.yang b/src/automation/src/ztp-agent/ztp_device.yang similarity index 91% rename from ztp_device.yang rename to src/automation/src/ztp-agent/ztp_device.yang index 748bc54c3..f506d6413 100644 --- a/ztp_device.yang +++ b/src/automation/src/ztp-agent/ztp_device.yang @@ -20,6 +20,9 @@ module ztp_device { leaf config_script_url{ type string; } + leaf ip_range { + type string; // check IP regular expression + } } typedef state { diff --git a/src/device/service/drivers/smartnic_probes/ietf-yang-types.yang b/src/device/service/drivers/smartnic_probes/ietf-yang-types.yang new file mode 100644 index 000000000..371a091d1 --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/ietf-yang-types.yang @@ -0,0 +1,480 @@ +module ietf-yang-types { + + namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; + prefix "yang"; + + organization + "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; + + contact + "WG Web: <http://tools.ietf.org/wg/netmod/> + WG List: <mailto:netmod@ietf.org> + + WG Chair: David Kessens + <mailto:david.kessens@nsn.com> + + WG Chair: Juergen Schoenwaelder + <mailto:j.schoenwaelder@jacobs-university.de> + + Editor: Juergen Schoenwaelder + <mailto:j.schoenwaelder@jacobs-university.de>"; + + description + "This module contains a collection of generally useful derived + YANG data types. + + Copyright (c) 2013 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 6991; see + the RFC itself for full legal notices."; + + revision 2013-07-15 { + description + "This revision adds the following new data types: + - yang-identifier + - hex-string + - uuid + - dotted-quad"; + reference + "RFC 6991: Common YANG Data Types"; + } + + revision 2010-09-24 { + description + "Initial revision."; + reference + "RFC 6021: Common YANG Data Types"; + } + + /*** collection of counter and gauge types ***/ + + typedef counter32 { + type uint32; + description + "The counter32 type represents a non-negative integer + that monotonically increases until it reaches a + maximum value of 2^32-1 (4294967295 decimal), when it + wraps around and starts increasing again from zero. + + Counters have no defined 'initial' value, and thus, a + single value of a counter has (in general) no information + content. Discontinuities in the monotonically increasing + value normally occur at re-initialization of the + management system, and at other times as specified in the + description of a schema node using this type. If such + other times can occur, for example, the creation of + a schema node of type counter32 at times other than + re-initialization, then a corresponding schema node + should be defined, with an appropriate type, to indicate + the last discontinuity. + + The counter32 type should not be used for configuration + schema nodes. A default statement SHOULD NOT be used in + combination with the type counter32. + + In the value set and its semantics, this type is equivalent + to the Counter32 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef zero-based-counter32 { + type yang:counter32; + default "0"; + description + "The zero-based-counter32 type represents a counter32 + that has the defined 'initial' value zero. + + A schema node of this type will be set to zero (0) on creation + and will thereafter increase monotonically until it reaches + a maximum value of 2^32-1 (4294967295 decimal), when it + wraps around and starts increasing again from zero. + + Provided that an application discovers a new schema node + of this type within the minimum time to wrap, it can use the + 'initial' value as a delta. It is important for a management + station to be aware of this minimum time and the actual time + between polls, and to discard data if the actual time is too + long or there is no defined minimum time. + + In the value set and its semantics, this type is equivalent + to the ZeroBasedCounter32 textual convention of the SMIv2."; + reference + "RFC 4502: Remote Network Monitoring Management Information + Base Version 2"; + } + + typedef counter64 { + type uint64; + description + "The counter64 type represents a non-negative integer + that monotonically increases until it reaches a + maximum value of 2^64-1 (18446744073709551615 decimal), + when it wraps around and starts increasing again from zero. + + Counters have no defined 'initial' value, and thus, a + single value of a counter has (in general) no information + content. Discontinuities in the monotonically increasing + value normally occur at re-initialization of the + management system, and at other times as specified in the + description of a schema node using this type. If such + other times can occur, for example, the creation of + a schema node of type counter64 at times other than + re-initialization, then a corresponding schema node + should be defined, with an appropriate type, to indicate + the last discontinuity. + + The counter64 type should not be used for configuration + schema nodes. A default statement SHOULD NOT be used in + combination with the type counter64. + + In the value set and its semantics, this type is equivalent + to the Counter64 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef zero-based-counter64 { + type yang:counter64; + default "0"; + description + "The zero-based-counter64 type represents a counter64 that + has the defined 'initial' value zero. + + + + + A schema node of this type will be set to zero (0) on creation + and will thereafter increase monotonically until it reaches + a maximum value of 2^64-1 (18446744073709551615 decimal), + when it wraps around and starts increasing again from zero. + + Provided that an application discovers a new schema node + of this type within the minimum time to wrap, it can use the + 'initial' value as a delta. It is important for a management + station to be aware of this minimum time and the actual time + between polls, and to discard data if the actual time is too + long or there is no defined minimum time. + + In the value set and its semantics, this type is equivalent + to the ZeroBasedCounter64 textual convention of the SMIv2."; + reference + "RFC 2856: Textual Conventions for Additional High Capacity + Data Types"; + } + + typedef gauge32 { + type uint32; + description + "The gauge32 type represents a non-negative integer, which + may increase or decrease, but shall never exceed a maximum + value, nor fall below a minimum value. The maximum value + cannot be greater than 2^32-1 (4294967295 decimal), and + the minimum value cannot be smaller than 0. The value of + a gauge32 has its maximum value whenever the information + being modeled is greater than or equal to its maximum + value, and has its minimum value whenever the information + being modeled is smaller than or equal to its minimum value. + If the information being modeled subsequently decreases + below (increases above) the maximum (minimum) value, the + gauge32 also decreases (increases). + + In the value set and its semantics, this type is equivalent + to the Gauge32 type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef gauge64 { + type uint64; + description + "The gauge64 type represents a non-negative integer, which + may increase or decrease, but shall never exceed a maximum + value, nor fall below a minimum value. The maximum value + cannot be greater than 2^64-1 (18446744073709551615), and + the minimum value cannot be smaller than 0. The value of + a gauge64 has its maximum value whenever the information + being modeled is greater than or equal to its maximum + value, and has its minimum value whenever the information + being modeled is smaller than or equal to its minimum value. + If the information being modeled subsequently decreases + below (increases above) the maximum (minimum) value, the + gauge64 also decreases (increases). + + In the value set and its semantics, this type is equivalent + to the CounterBasedGauge64 SMIv2 textual convention defined + in RFC 2856"; + reference + "RFC 2856: Textual Conventions for Additional High Capacity + Data Types"; + } + + /*** collection of identifier-related types ***/ + + typedef object-identifier { + type string { + pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))' + + '(\.(0|([1-9]\d*)))*'; + } + description + "The object-identifier type represents administratively + assigned names in a registration-hierarchical-name tree. + + Values of this type are denoted as a sequence of numerical + non-negative sub-identifier values. Each sub-identifier + value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers + are separated by single dots and without any intermediate + whitespace. + + The ASN.1 standard restricts the value space of the first + sub-identifier to 0, 1, or 2. Furthermore, the value space + of the second sub-identifier is restricted to the range + 0 to 39 if the first sub-identifier is 0 or 1. Finally, + the ASN.1 standard requires that an object identifier + has always at least two sub-identifiers. The pattern + captures these restrictions. + + Although the number of sub-identifiers is not limited, + module designers should realize that there may be + implementations that stick with the SMIv2 limit of 128 + sub-identifiers. + + This type is a superset of the SMIv2 OBJECT IDENTIFIER type + since it is not restricted to 128 sub-identifiers. Hence, + this type SHOULD NOT be used to represent the SMIv2 OBJECT + IDENTIFIER type; the object-identifier-128 type SHOULD be + used instead."; + reference + "ISO9834-1: Information technology -- Open Systems + Interconnection -- Procedures for the operation of OSI + Registration Authorities: General procedures and top + arcs of the ASN.1 Object Identifier tree"; + } + + typedef object-identifier-128 { + type object-identifier { + pattern '\d*(\.\d*){1,127}'; + } + description + "This type represents object-identifiers restricted to 128 + sub-identifiers. + + In the value set and its semantics, this type is equivalent + to the OBJECT IDENTIFIER type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef yang-identifier { + type string { + length "1..max"; + pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*'; + pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*'; + } + description + "A YANG identifier string as defined by the 'identifier' + rule in Section 12 of RFC 6020. An identifier must + start with an alphabetic character or an underscore + followed by an arbitrary sequence of alphabetic or + numeric characters, underscores, hyphens, or dots. + + A YANG identifier MUST NOT start with any possible + combination of the lowercase or uppercase character + sequence 'xml'."; + reference + "RFC 6020: YANG - A Data Modeling Language for the Network + Configuration Protocol (NETCONF)"; + } + + /*** collection of types related to date and time***/ + + typedef date-and-time { + type string { + pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' + + '(Z|[\+\-]\d{2}:\d{2})'; + } + description + "The date-and-time type is a profile of the ISO 8601 + standard for representation of dates and times using the + Gregorian calendar. The profile is defined by the + date-time production in Section 5.6 of RFC 3339. + + The date-and-time type is compatible with the dateTime XML + schema type with the following notable exceptions: + + (a) The date-and-time type does not allow negative years. + + (b) The date-and-time time-offset -00:00 indicates an unknown + time zone (see RFC 3339) while -00:00 and +00:00 and Z + all represent the same time zone in dateTime. + + (c) The canonical format (see below) of data-and-time values + differs from the canonical format used by the dateTime XML + schema type, which requires all times to be in UTC using + the time-offset 'Z'. + + This type is not equivalent to the DateAndTime textual + convention of the SMIv2 since RFC 3339 uses a different + separator between full-date and full-time and provides + higher resolution of time-secfrac. + + The canonical format for date-and-time values with a known time + zone uses a numeric time zone offset that is calculated using + the device's configured known offset to UTC time. A change of + the device's offset to UTC time will cause date-and-time values + to change accordingly. Such changes might happen periodically + in case a server follows automatically daylight saving time + (DST) time zone offset changes. The canonical format for + date-and-time values with an unknown time zone (usually + referring to the notion of local time) uses the time-offset + -00:00."; + reference + "RFC 3339: Date and Time on the Internet: Timestamps + RFC 2579: Textual Conventions for SMIv2 + XSD-TYPES: XML Schema Part 2: Datatypes Second Edition"; + } + + typedef timeticks { + type uint32; + description + "The timeticks type represents a non-negative integer that + represents the time, modulo 2^32 (4294967296 decimal), in + hundredths of a second between two epochs. When a schema + node is defined that uses this type, the description of + the schema node identifies both of the reference epochs. + + In the value set and its semantics, this type is equivalent + to the TimeTicks type of the SMIv2."; + reference + "RFC 2578: Structure of Management Information Version 2 + (SMIv2)"; + } + + typedef timestamp { + type yang:timeticks; + description + "The timestamp type represents the value of an associated + timeticks schema node at which a specific occurrence + happened. The specific occurrence must be defined in the + description of any schema node defined using this type. When + the specific occurrence occurred prior to the last time the + associated timeticks attribute was zero, then the timestamp + value is zero. Note that this requires all timestamp values + to be reset to zero when the value of the associated timeticks + attribute reaches 497+ days and wraps around to zero. + + The associated timeticks schema node must be specified + in the description of any schema node using this type. + + In the value set and its semantics, this type is equivalent + to the TimeStamp textual convention of the SMIv2."; + reference + "RFC 2579: Textual Conventions for SMIv2"; + } + + /*** collection of generic address types ***/ + + typedef phys-address { + type string { + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; + } + + + + + description + "Represents media- or physical-level addresses represented + as a sequence octets, each octet represented by two hexadecimal + numbers. Octets are separated by colons. The canonical + representation uses lowercase characters. + + In the value set and its semantics, this type is equivalent + to the PhysAddress textual convention of the SMIv2."; + reference + "RFC 2579: Textual Conventions for SMIv2"; + } + + typedef mac-address { + type string { + pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'; + } + description + "The mac-address type represents an IEEE 802 MAC address. + The canonical representation uses lowercase characters. + + In the value set and its semantics, this type is equivalent + to the MacAddress textual convention of the SMIv2."; + reference + "IEEE 802: IEEE Standard for Local and Metropolitan Area + Networks: Overview and Architecture + RFC 2579: Textual Conventions for SMIv2"; + } + + /*** collection of XML-specific types ***/ + + typedef xpath1.0 { + type string; + description + "This type represents an XPATH 1.0 expression. + + When a schema node is defined that uses this type, the + description of the schema node MUST specify the XPath + context in which the XPath expression is evaluated."; + reference + "XPATH: XML Path Language (XPath) Version 1.0"; + } + + /*** collection of string types ***/ + + typedef hex-string { + type string { + pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?'; + } + description + "A hexadecimal string with octets represented as hex digits + separated by colons. The canonical representation uses + lowercase characters."; + } + + typedef uuid { + type string { + pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-' + + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'; + } + description + "A Universally Unique IDentifier in the string representation + defined in RFC 4122. The canonical representation uses + lowercase characters. + + The following is an example of a UUID in string representation: + f81d4fae-7dec-11d0-a765-00a0c91e6bf6 + "; + reference + "RFC 4122: A Universally Unique IDentifier (UUID) URN + Namespace"; + } + + typedef dotted-quad { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; + } + description + "An unsigned 32-bit number expressed in the dotted-quad + notation, i.e., four octets written as decimal numbers + and separated with the '.' (full stop) character."; + } +} diff --git a/src/device/service/drivers/smartnic_probes/openconfig-extensions.yang b/src/device/service/drivers/smartnic_probes/openconfig-extensions.yang new file mode 100644 index 000000000..2e0fd9f07 --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/openconfig-extensions.yang @@ -0,0 +1,206 @@ +module openconfig-extensions { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/openconfig-ext"; + + prefix "oc-ext"; + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module provides extensions to the YANG language to allow + OpenConfig specific functionality and meta-data to be defined."; + + oc-ext:openconfig-version "0.5.1"; + + revision "2022-10-05" { + description + "Add missing version statement."; + reference "0.5.1"; + } + + revision "2020-06-16" { + description + "Add extension for POSIX pattern statements."; + reference "0.5.0"; + } + + revision "2018-10-17" { + description + "Add extension for regular expression type."; + reference "0.4.0"; + } + + revision "2017-04-11" { + description + "rename password type to 'hashed' and clarify description"; + reference "0.3.0"; + } + + revision "2017-01-29" { + description + "Added extension for annotating encrypted values."; + reference "0.2.0"; + } + + revision "2015-10-09" { + description + "Initial OpenConfig public release"; + reference "0.1.0"; + } + + + // extension statements + extension openconfig-version { + argument "semver" { + yin-element false; + } + description + "The OpenConfig version number for the module. This is + expressed as a semantic version number of the form: + x.y.z + where: + * x corresponds to the major version, + * y corresponds to a minor version, + * z corresponds to a patch version. + This version corresponds to the model file within which it is + defined, and does not cover the whole set of OpenConfig models. + + Individual YANG modules are versioned independently -- the + semantic version is generally incremented only when there is a + change in the corresponding file. Submodules should always + have the same semantic version as their parent modules. + + A major version number of 0 indicates that this model is still + in development (whether within OpenConfig or with industry + partners), and is potentially subject to change. + + Following a release of major version 1, all modules will + increment major revision number where backwards incompatible + changes to the model are made. + + The minor version is changed when features are added to the + model that do not impact current clients use of the model. + + The patch-level version is incremented when non-feature changes + (such as bugfixes or clarifications to human-readable + descriptions that do not impact model functionality) are made + that maintain backwards compatibility. + + The version number is stored in the module meta-data."; + } + + extension openconfig-hashed-value { + description + "This extension provides an annotation on schema nodes to + indicate that the corresponding value should be stored and + reported in hashed form. + + Hash algorithms are by definition not reversible. Clients + reading the configuration or applied configuration for the node + should expect to receive only the hashed value. Values written + in cleartext will be hashed. This annotation may be used on + nodes such as secure passwords in which the device never reports + a cleartext value, even if the input is provided as cleartext."; + } + + extension regexp-posix { + description + "This extension indicates that the regular expressions included + within the YANG module specified are conformant with the POSIX + regular expression format rather than the W3C standard that is + specified by RFC6020 and RFC7950."; + } + + extension posix-pattern { + argument "pattern" { + yin-element false; + } + description + "Provides a POSIX ERE regular expression pattern statement as an + alternative to YANG regular expresssions based on XML Schema Datatypes. + It is used the same way as the standard YANG pattern statement defined in + RFC6020 and RFC7950, but takes an argument that is a POSIX ERE regular + expression string."; + reference + "POSIX Extended Regular Expressions (ERE) Specification: + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04"; + } + + extension telemetry-on-change { + description + "The telemetry-on-change annotation is specified in the context + of a particular subtree (container, or list) or leaf within the + YANG schema. Where specified, it indicates that the value stored + by the nodes within the context change their value only in response + to an event occurring. The event may be local to the target, for + example - a configuration change, or external - such as the failure + of a link. + + When a telemetry subscription allows the target to determine whether + to export the value of a leaf in a periodic or event-based fashion + (e.g., TARGET_DEFINED mode in gNMI), leaves marked as + telemetry-on-change should only be exported when they change, + i.e., event-based."; + } + + extension telemetry-atomic { + description + "The telemetry-atomic annotation is specified in the context of + a subtree (containre, or list), and indicates that all nodes + within the subtree are always updated together within the data + model. For example, all elements under the subtree may be updated + as a result of a new alarm being raised, or the arrival of a new + protocol message. + + Transport protocols may use the atomic specification to determine + optimisations for sending or storing the corresponding data."; + } + + extension operational { + description + "The operational annotation is specified in the context of a + grouping, leaf, or leaf-list within a YANG module. It indicates + that the nodes within the context are derived state on the device. + + OpenConfig data models divide nodes into the following three categories: + + - intended configuration - these are leaves within a container named + 'config', and are the writable configuration of a target. + - applied configuration - these are leaves within a container named + 'state' and are the currently running value of the intended configuration. + - derived state - these are the values within the 'state' container which + are not part of the applied configuration of the device. Typically, they + represent state values reflecting underlying operational counters, or + protocol statuses."; + } + + extension catalog-organization { + argument "org" { + yin-element false; + } + description + "This extension specifies the organization name that should be used within + the module catalogue on the device for the specified YANG module. It stores + a pithy string where the YANG organization statement may contain more + details."; + } + + extension origin { + argument "origin" { + yin-element false; + } + description + "This extension specifies the name of the origin that the YANG module + falls within. This allows multiple overlapping schema trees to be used + on a single network element without requiring module based prefixing + of paths."; + } +} diff --git a/src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang b/src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang new file mode 100644 index 000000000..3d3ed425e --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang @@ -0,0 +1,478 @@ +module openconfig-inet-types { + + yang-version "1"; + namespace "http://openconfig.net/yang/types/inet"; + prefix "oc-inet"; + + import openconfig-extensions { prefix "oc-ext"; } + + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module contains a set of Internet address related + types for use in OpenConfig modules. + + Portions of this code were derived from IETF RFC 6021. + Please reproduce this note if possible. + + IETF code is subject to the following copyright and license: + Copyright (c) IETF Trust and the persons identified as authors of + the code. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, is permitted pursuant to, and subject to the license + terms contained in, the Simplified BSD License set forth in + Section 4.c of the IETF Trust's Legal Provisions Relating + to IETF Documents (http://trustee.ietf.org/license-info)."; + + oc-ext:openconfig-version "0.6.0"; + + revision "2023-02-06" { + description + "Add ipv6-link-local and ipv6-address-type"; + reference "0.6.0"; + } + + revision "2021-08-17" { + description + "Add ip-address-zoned typedef as a union between ipv4-address-zoned + and ipv6-address-zoned types."; + reference "0.5.0"; + } + + revision "2021-07-14" { + description + "Use auto-generated regex for ipv4 pattern statements: + - ipv4-address + - ipv4-address-zoned + - ipv4-prefix"; + reference "0.4.1"; + } + + revision "2021-01-07" { + description + "Remove module extension oc-ext:regexp-posix by making pattern regexes + conform to RFC7950. + + Types impacted: + - ipv4-address + - ipv4-address-zoned + - ipv6-address + - domain-name"; + reference "0.4.0"; + } + + revision "2020-10-12" { + description + "Fix anchors for domain-name pattern."; + reference "0.3.5"; + } + + revision "2020-06-30" { + description + "Add OpenConfig POSIX pattern extensions and add anchors for domain-name + pattern."; + reference "0.3.4"; + } + + revision "2019-04-25" { + description + "Fix regex bug for ipv6-prefix type"; + reference "0.3.3"; + } + + revision "2018-11-21" { + description + "Add OpenConfig module metadata extensions."; + reference "0.3.2"; + } + + revision 2017-08-24 { + description + "Minor formatting fixes."; + reference "0.3.1"; + } + + revision 2017-07-06 { + description + "Add domain-name and host typedefs"; + reference "0.3.0"; + } + + revision 2017-04-03 { + description + "Add ip-version typedef."; + reference "0.2.0"; + } + + revision 2017-04-03 { + description + "Update copyright notice."; + reference "0.1.1"; + } + + revision 2017-01-26 { + description + "Initial module for inet types"; + reference "0.1.0"; + } + + // OpenConfig specific extensions for module metadata. + oc-ext:catalog-organization "openconfig"; + oc-ext:origin "openconfig"; + + // IPv4 and IPv6 types. + + typedef ipv4-address { + type string { + pattern + '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}'; + oc-ext:posix-pattern + '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3})$'; + } + description + "An IPv4 address in dotted quad notation using the default + zone."; + } + + typedef ipv4-address-zoned { + type string { + pattern + '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(%[a-zA-Z0-9_]+)'; + oc-ext:posix-pattern + '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(%[a-zA-Z0-9_]+))$'; + } + description + "An IPv4 address in dotted quad notation. This type allows + specification of a zone index to disambiguate identical + address values. For link-local addresses, the index is + typically the interface index or interface name."; + } + + typedef ipv6-address { + type string { + pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')'; + oc-ext:posix-pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')$'; + } + description + "An IPv6 address represented as either a full address; shortened + or mixed-shortened formats, using the default zone."; + } + + typedef ipv6-address-zoned { + type string { + pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')(%[a-zA-Z0-9_]+)$'; + oc-ext:posix-pattern + // Must support compression through different lengths + // therefore this regexp is complex. + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')(%[a-zA-Z0-9_]+)$'; + } + description + "An IPv6 address represented as either a full address; shortened + or mixed-shortened formats. This type allows specification of + a zone index to disambiguate identical address values. For + link-local addresses, the index is typically the interface + index or interface name."; + } + + typedef ipv4-prefix { + type string { + pattern + '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}/([0-9]|[12][0-9]|' + + '3[0-2])'; + oc-ext:posix-pattern + '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|' + + '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}/([0-9]|[12][0-9]|' + + '3[0-2]))$'; + } + description + "An IPv4 prefix represented in dotted quad notation followed by + a slash and a CIDR mask (0 <= mask <= 32)."; + } + + typedef ipv6-prefix { + type string { + pattern + '(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])'; + oc-ext:posix-pattern + '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,7}:|' + + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + + ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$'; + } + description + "An IPv6 prefix represented in full, shortened, or mixed + shortened format followed by a slash and CIDR mask + (0 <= mask <= 128)."; + } + + typedef ip-address { + type union { + type ipv4-address; + type ipv6-address; + } + description + "An IPv4 or IPv6 address with no prefix specified."; + } + + typedef ip-address-zoned { + type union { + type ipv4-address-zoned; + type ipv6-address-zoned; + } + description + "An IPv4 or IPv6 address with no prefix specified and an optional + zone index."; + } + + typedef ip-prefix { + type union { + type ipv4-prefix; + type ipv6-prefix; + } + description + "An IPv4 or IPv6 prefix."; + } + + typedef ip-version { + type enumeration { + enum UNKNOWN { + value 0; + description + "An unknown or unspecified version of the Internet + protocol."; + } + enum IPV4 { + value 4; + description + "The IPv4 protocol as defined in RFC 791."; + } + enum IPV6 { + value 6; + description + "The IPv6 protocol as defined in RFC 2460."; + } + } + description + "This value represents the version of the IP protocol. + Note that integer representation of the enumerated values + are not specified, and are not required to follow the + InetVersion textual convention in SMIv2."; + reference + "RFC 791: Internet Protocol + RFC 2460: Internet Protocol, Version 6 (IPv6) Specification + RFC 4001: Textual Conventions for Internet Network Addresses"; + } + + typedef ipv6-address-type { + type enumeration { + enum GLOBAL_UNICAST { + description + "The IPv6 address is a global unicast address type and must be in + the format defined in RFC 4291 section 2.4."; + } + enum LINK_LOCAL_UNICAST { + description + "The IPv6 address is a Link-Local unicast address type and must be + in the format defined in RFC 4291 section 2.4."; + } + } + description + "The value represents the type of IPv6 address"; + reference + "RFC 4291: IP Version 6 Addressing Architecture + section 2.5"; + } + + typedef domain-name { + type string { + length "1..253"; + pattern + '(((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + + '|\.)'; + oc-ext:posix-pattern + '^(((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + + '|\.)$'; + } + description + "The domain-name type represents a DNS domain name. + Fully quallified left to the models which utilize this type. + + Internet domain names are only loosely specified. Section + 3.5 of RFC 1034 recommends a syntax (modified in Section + 2.1 of RFC 1123). The pattern above is intended to allow + for current practice in domain name use, and some possible + future expansion. It is designed to hold various types of + domain names, including names used for A or AAAA records + (host names) and other records, such as SRV records. Note + that Internet host names have a stricter syntax (described + in RFC 952) than the DNS recommendations in RFCs 1034 and + 1123, and that systems that want to store host names in + schema nodes using the domain-name type are recommended to + adhere to this stricter standard to ensure interoperability. + + The encoding of DNS names in the DNS protocol is limited + to 255 characters. Since the encoding consists of labels + prefixed by a length bytes and there is a trailing NULL + byte, only 253 characters can appear in the textual dotted + notation. + + Domain-name values use the US-ASCII encoding. Their canonical + format uses lowercase US-ASCII characters. Internationalized + domain names MUST be encoded in punycode as described in RFC + 3492"; + } + + typedef host { + type union { + type ip-address; + type domain-name; + } + description + "The host type represents either an unzoned IP address or a DNS + domain name."; + } + + typedef as-number { + type uint32; + description + "A numeric identifier for an autonomous system (AS). An AS is a + single domain, under common administrative control, which forms + a unit of routing policy. Autonomous systems can be assigned a + 2-byte identifier, or a 4-byte identifier which may have public + or private scope. Private ASNs are assigned from dedicated + ranges. Public ASNs are assigned from ranges allocated by IANA + to the regional internet registries (RIRs)."; + reference + "RFC 1930 Guidelines for creation, selection, and registration + of an Autonomous System (AS) + RFC 4271 A Border Gateway Protocol 4 (BGP-4)"; + } + + typedef dscp { + type uint8 { + range "0..63"; + } + description + "A differentiated services code point (DSCP) marking within the + IP header."; + reference + "RFC 2474 Definition of the Differentiated Services Field + (DS Field) in the IPv4 and IPv6 Headers"; + } + + typedef ipv6-flow-label { + type uint32 { + range "0..1048575"; + } + description + "The IPv6 flow-label is a 20-bit value within the IPv6 header + which is optionally used by the source of the IPv6 packet to + label sets of packets for which special handling may be + required."; + reference + "RFC 2460 Internet Protocol, Version 6 (IPv6) Specification"; + } + + typedef port-number { + type uint16; + description + "A 16-bit port number used by a transport protocol such as TCP + or UDP."; + reference + "RFC 768 User Datagram Protocol + RFC 793 Transmission Control Protocol"; + } + + typedef uri { + type string; + description + "An ASCII-encoded Uniform Resource Identifier (URI) as defined + in RFC 3986."; + reference + "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax"; + } + + typedef url { + type string; + description + "An ASCII-encoded Uniform Resource Locator (URL) as defined + in RFC 3986, section 1.1.3"; + reference + "RFC 3986, paragraph 1.1.3"; + } + +} diff --git a/src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang b/src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang new file mode 100644 index 000000000..c5e13f370 --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang @@ -0,0 +1,86 @@ +module openconfig-probes-types { + + yang-version "1"; + + // namespace + namespace "http://openconfig.net/yang/probes/types"; + + prefix "oc-probes-types"; + + // import some basic types + import openconfig-extensions { prefix oc-ext; } + + // meta + organization "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module defines types related to the probes."; + + oc-ext:openconfig-version "0.1.1"; + + revision "2018-11-21" { + description + "Add OpenConfig module metadata extensions."; + reference "0.1.1"; + } + + revision "2017-09-05" { + description + "Initial public revision"; + reference "0.1.0"; + } + + // OpenConfig specific extensions for module metadata. + oc-ext:regexp-posix; + oc-ext:catalog-organization "openconfig"; + oc-ext:origin "openconfig"; + + typedef test-type { + type enumeration { + enum ICMP { + description + "Send ICMP echo requests."; + } + enum ICMP6 { + description + "Send ICMP6 echo requests."; + } + enum ICMP_TIMESTAMP { + description + "Send ICMP timestamp requests."; + } + enum ICMP6_TIMESTAMP { + description + "Sedn ICMP6 timestamp requests."; + } + enum TCP { + description + "Send TPC packets."; + } + enum UDP { + description + "Send UDP packets."; + } + enum UDP_TIMESTAMP { + description + "Send UDP packets with timestamp."; + } + enum HTTP_GET { + description + "Execute HTTP GET requests."; + } + enum HTTP_GET_META { + description + "Execute HTTP GET requests of metadata."; + } + } + description + "Type definition with enumerations describing the basis of + the probe test type identifier"; + } + +} \ No newline at end of file diff --git a/src/device/service/drivers/smartnic_probes/openconfig-probes.yang b/src/device/service/drivers/smartnic_probes/openconfig-probes.yang new file mode 100644 index 000000000..27b7e4c0d --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/openconfig-probes.yang @@ -0,0 +1,575 @@ +module openconfig-probes { + + // namespace + namespace "http://openconfig.net/yang/probes"; + + prefix "oc-probes"; + + import ietf-yang-types { prefix yang; } + import openconfig-types { prefix oc-types; } + import openconfig-extensions { prefix oc-ext; } + import openconfig-inet-types { prefix oc-inet; } + import openconfig-probes-types { prefix oc-probes-types; } + + organization "OpenConfig working group"; + + contact + "OpenConfig working group + www.openconfig.net"; + + description + "This module defines configuration and operational state data + for the probes. + A probe consists on a group of tests, each test being a + source-destination pair to poll. The destination can be either + IP Address (and eventually port) or URL, depending on the + nature of the test. The test can send ICMP, UDP, TCP, or HTTP + requests. + Each test groups a list of test items, the test results + being an overall view or average of the items list. + However, the test preserves only a limited set of history + items, whose length can be controlled using the history-size."; + + oc-ext:openconfig-version "0.0.2"; + + revision "2018-11-21" { + description + "Add OpenConfig module metadata extensions."; + reference "0.0.2"; + } + + revision "2017-09-05" { + description + "Initial public revision"; + reference "0.0.1"; + } + + // OpenConfig specific extensions for module metadata. + oc-ext:regexp-posix; + oc-ext:catalog-organization "openconfig"; + oc-ext:origin "openconfig"; + + grouping test-target { + description + "Groups the config and state containers + for an individual test."; + + container target { + description + "The target configuration of the test. + The nature of the target depends on the probe type: + for HTTP probes we need to provide an URL to poll, + while ICMP probes require an IP address to monitor."; + + container config { + description + "Configuration data for the test target."; + + uses test-target-base; + } + + container state { + config false; + + description + "Operational data for the test target."; + + uses test-target-base; + } + } + } + + grouping test-target-base { + description + "Targe types for the probe test."; + + leaf address { + type oc-inet:ip-address; + description + "IP address of the target, either IPv4 or IPv6."; + } + + leaf port { + type oc-inet:port-number; + description + "Destination port."; + } + + leaf url { + type oc-inet:url; + description + "Target URL to probe."; + } + } + + grouping probe-test-config-base { + description + "Definition of test details."; + + leaf test-type { + type oc-probes-types:test-type; + description + "The type of the probe test."; + mandatory true; + } + + leaf count { + type yang:counter64; + description + "The number of probes per test."; + } + + leaf interval { + type yang:counter64; + description + "Time between two consecutive probes."; + } + + leaf source { + type oc-inet:ip-address; + description + "Source address used when probing, either IPv4 or IPv6."; + } + + leaf history-size { + type yang:counter64; + description + "The number of history entries stored."; + } + + leaf source-port { + type oc-inet:port-number; + description + "Source number used."; + } + + leaf dscp { + type oc-inet:dscp; + description + "DSCP code points"; + } + + } + + grouping probe-test-state-history-item-base { + description + "The test item results counters and statistics. + An item presents the results of a single execution + of the test. + The results of the test depend on the values + of the total items, or an average over a certain + period of time."; + + leaf id { + type yang:counter64; + description + "The test item ID."; + } + + leaf timestamp { + type oc-types:timeticks64; + description + "The test timestamp. + This is not the timestamp when the test + was actually executed nither when it finished. + Should be the timestamp when the test has been scheduled. + It may not be the same with start-timestamp."; + } + + leaf start-timestamp { + type oc-types:timeticks64; + description + "The timestamp when the test started."; + } + + leaf end-timestamp { + type oc-types:timeticks64; + description + "The timestamp when the test finished."; + } + + leaf test-duration { + type yang:counter64; + description + "The duration of the test, in microseconds."; + } + + leaf failed { + type boolean; + description + "Whether the test failed or succeeded."; + } + + leaf probes-sent { + type yang:counter64; + description + "Number of test probes sent."; + } + + leaf probes-received { + type yang:counter64; + description + "Number of test probes received."; + } + + leaf loss-percentage { + type oc-types:percentage; + description + "The loss percentage."; + } + + leaf jitter { + type yang:counter64; + description + "The round trip jitter, in microseconds."; + } + + leaf min-delay { + type yang:counter64; + description + "The minimum delay recorded during the test, in microseconds."; + } + + leaf max-delay { + type yang:counter64; + description + "The maximum delay recorded during the test, in microseconds."; + } + + leaf avg-delay { + type yang:counter64; + description + "The average delay recorded during the test, in microseconds."; + } + + leaf stddev-delay { + type yang:counter64; + description + "The standard deviation of the delay of the test."; + } + + } + + grouping probe-test-state-history-item { + description + "A history item of the probe results."; + + container state { + + config false; + + description + "A history item of the probe results: operational data only."; + + uses probe-test-state-history-item-base; + } + + } + + grouping probe-test-state-history { + + description + "The history of the test results."; + + container items { + + description + "The list of items in the probe history. + The length depends on the history size."; + + list item { + key "id"; + description + "List of history items."; + + leaf id { + type leafref { + path "../state/id"; + } + description + "Reference to the history entry ID."; + } + + uses probe-test-state-history-item; + } + + } + + } + + grouping probe-test-state-results { + description + "The test results counters and statistics."; + + leaf timestamp { + type oc-types:timeticks64; + description + "The test timestamp. + This is not the timestamp when the test + was actually executed nither when it finished. + Should be the timestamp when the test has been scheduled. + It may not be the same with start-timestamp."; + } + + leaf start-timestamp { + type oc-types:timeticks64; + description + "The timestamp when the test started."; + } + + leaf last-test-timestamp { + type oc-types:timeticks64; + description + "The timestamp when the test finished."; + } + + leaf test-duration { + type yang:counter64; + description + "The duration of the test, in microseconds."; + } + + leaf failed { + type boolean; + description + "Whether the test failed or succeeded."; + } + + leaf probes-sent { + type yang:counter64; + description + "Number of test probes sent."; + } + + leaf probes-received { + type yang:counter64; + description + "Number of test probes received."; + } + + leaf loss-percentage { + type oc-types:percentage; + description + "The loss percentage."; + } + + leaf jitter { + type yang:counter64; + description + "The round trip jitter, in microseconds."; + } + + leaf min-delay { + type yang:counter64; + description + "The minimum delay recorded during the test, in microseconds."; + } + + leaf max-delay { + type yang:counter64; + description + "The maximum delay recorded during the test, in microseconds."; + } + + leaf avg-delay { + type yang:counter64; + description + "The average delay recorded during the test, in microseconds."; + } + + leaf stddev-delay { + type yang:counter64; + description + "The standard deviation of the delay of the test."; + } + + + } + + grouping probe-test-state { + + description + "Operational data and results for the probes."; + + } + + grouping probe-test-config { + description + "Definition of test details."; + + leaf name { + type string; + description + "The name of the test probe"; + mandatory true; + } + + leaf enabled { + type boolean; + default true; + description + "Whether the test is enabled."; + } + + uses probe-test-config-base; + + } + + grouping probe-tests-top { + description + "Top-level grouping for the tests withing a probe."; + + list test { + key "name"; + description + "List of tests associated with this probe."; + + leaf name { + type leafref { + path "../config/name"; + } + description + "Reference to the list key"; + } + + container config { + description + "Configuration data for the test of this probe."; + + uses probe-test-config; + } + + container state { + + config false; + + description + "Operational state data"; + + uses probe-test-config; + uses probe-test-state; + } + + uses test-target; + + container results { + description + "Contains the results of the tests."; + + container state { + + config false; + + description + "Results of this test: operational data only"; + + uses probe-test-state-results; + } + + container history { + + config false; + + description + "Historical data of the tests."; + + uses probe-test-state-history; + } + + } + + } + // end list of probes + + } + + grouping probe-config { + description + "Definition of probe details."; + + leaf name { + type string; + description + "The name of the probe."; + mandatory true; + } + + leaf enabled { + type boolean; + default true; + description + "Whether the probe is enabled."; + } + + } + + grouping probe-state { + description + "Definition of probes operation data."; + } + + grouping probes-top { + description + "Top-level grouping for probes model"; + + list probe { + key "name"; + description + "List of probes configured."; + + leaf name { + type leafref { + path "../config/name"; + } + description + "Reference to the list key"; + } + + container config { + description + "Configuration data for the probes."; + + uses probe-config; + } + + container state { + + config false; + + description + "Operational state data"; + + uses probe-config; + uses probe-state; + } + + container tests { + + description + "The tests associated to be executed for the probe."; + + uses probe-tests-top; + } + + } + // end list of probes + + } + + grouping openconfig-probes-top { + + description + "The top level grouping of the probes model."; + + container probes { + description + "The container containing the list of probes."; + + uses probes-top; + } + + } + + uses openconfig-probes-top; + +} \ No newline at end of file diff --git a/src/device/service/drivers/smartnic_probes/openconfig-types.yang b/src/device/service/drivers/smartnic_probes/openconfig-types.yang new file mode 100644 index 000000000..89e32d515 --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/openconfig-types.yang @@ -0,0 +1,471 @@ +module openconfig-types { + yang-version "1"; + + namespace "http://openconfig.net/yang/openconfig-types"; + + prefix "oc-types"; + + // import statements + import openconfig-extensions { prefix oc-ext; } + + // meta + organization + "OpenConfig working group"; + + contact + "OpenConfig working group + netopenconfig@googlegroups.com"; + + description + "This module contains a set of general type definitions that + are used across OpenConfig models. It can be imported by modules + that make use of these types."; + + oc-ext:openconfig-version "0.6.0"; + + revision "2019-04-16" { + description + "Clarify definition of timeticks64."; + reference "0.6.0"; + } + + revision "2018-11-21" { + description + "Add OpenConfig module metadata extensions."; + reference "0.5.1"; + } + + revision "2018-05-05" { + description + "Add grouping of min-max-time and + included them to all stats with min/max/avg"; + reference "0.5.0"; + } + + revision "2018-01-16" { + description + "Add interval to min/max/avg stats; add percentage stat"; + reference "0.4.0"; + } + + revision "2017-08-16" { + description + "Apply fix for ieetfloat32 length parameter"; + reference "0.3.3"; + } + + revision "2017-01-13" { + description + "Add ADDRESS_FAMILY identity"; + reference "0.3.2"; + } + + revision "2016-11-14" { + description + "Correct length of ieeefloat32"; + reference "0.3.1"; + } + + revision "2016-11-11" { + description + "Additional types - ieeefloat32 and routing-password"; + reference "0.3.0"; + } + + revision "2016-05-31" { + description + "OpenConfig public release"; + reference "0.2.0"; + } + + // OpenConfig specific extensions for module metadata. + oc-ext:regexp-posix; + oc-ext:catalog-organization "openconfig"; + oc-ext:origin "openconfig"; + + typedef percentage { + type uint8 { + range "0..100"; + } + description + "Integer indicating a percentage value"; + } + + typedef std-regexp { + type string; + description + "This type definition is a placeholder for a standard + definition of a regular expression that can be utilised in + OpenConfig models. Further discussion is required to + consider the type of regular expressions that are to be + supported. An initial proposal is POSIX compatible."; + } + + typedef timeticks64 { + type uint64; + units "nanoseconds"; + description + "The timeticks64 represents the time, modulo 2^64 in + nanoseconds between two epochs. The leaf using this + type must define the epochs that tests are relative to."; + } + + typedef ieeefloat32 { + type binary { + length "4"; + } + description + "An IEEE 32-bit floating point number. The format of this number + is of the form: + 1-bit sign + 8-bit exponent + 23-bit fraction + The floating point value is calculated using: + (-1)**S * 2**(Exponent-127) * (1+Fraction)"; + } + + typedef routing-password { + type string; + description + "This type is indicative of a password that is used within + a routing protocol which can be returned in plain text to the + NMS by the local system. Such passwords are typically stored + as encrypted strings. Since the encryption used is generally + well known, it is possible to extract the original value from + the string - and hence this format is not considered secure. + Leaves specified with this type should not be modified by + the system, and should be returned to the end-user in plain + text. This type exists to differentiate passwords, which + may be sensitive, from other string leaves. It could, for + example, be used by the NMS to censor this data when + viewed by particular users."; + } + + typedef stat-interval { + type uint64; + units nanoseconds; + description + "A time interval over which a set of statistics is computed. + A common usage is to report the interval over which + avg/min/max stats are computed and reported."; + } + + grouping stat-interval-state { + description + "Reusable leaf definition for stats computation interval"; + + leaf interval { + type oc-types:stat-interval; + description + "If supported by the system, this reports the time interval + over which the min/max/average statistics are computed by + the system."; + } + } + + grouping min-max-time { + description + "Common grouping for recording the absolute time at which + the minimum and maximum values occurred in the statistics"; + + leaf min-time { + type oc-types:timeticks64; + description + "The absolute time at which the minimum value occurred. + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + + leaf max-time { + type oc-types:timeticks64; + description + "The absolute time at which the maximum value occurred. + The value is the timestamp in nanoseconds relative to + the Unix Epoch (Jan 1, 1970 00:00:00 UTC)."; + } + } + + grouping avg-min-max-stats-precision1 { + description + "Common nodes for recording average, minimum, and + maximum values for a statistic. These values all have + fraction-digits set to 1. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed is also reported."; + + leaf avg { + type decimal64 { + fraction-digits 1; + } + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 1; + } + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 1; + } + description + "The maximum value of the statitic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision1 { + description + "Common grouping for recording an instantaneous statistic value + in addition to avg-min-max stats"; + + leaf instant { + type decimal64 { + fraction-digits 1; + } + description + "The instantaneous value of the statistic."; + } + + uses avg-min-max-stats-precision1; + } + + grouping avg-min-max-instant-stats-precision2-dB { + description + "Common grouping for recording dB values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The minimum value of the statistic over the time interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units dB; + description + "The maximum value of the statistic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision2-dBm { + description + "Common grouping for recording dBm values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units dBm; + description + "The maximum value of the statistic over the time interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-precision2-mA { + description + "Common grouping for recording mA values with 2 decimal + precision. Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The instantaneous value of the statistic."; + } + + leaf avg { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The arithmetic mean value of the statistic over the + time interval."; + } + + leaf min { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The minimum value of the statistic over the time + interval."; + } + + leaf max { + type decimal64 { + fraction-digits 2; + } + units mA; + description + "The maximum value of the statistic over the time + interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + grouping avg-min-max-instant-stats-pct { + description + "Common grouping for percentage statistics. + Values include the instantaneous, average, + minimum, and maximum statistics. Statistics are computed + and reported based on a moving time interval (e.g., the last + 30s). If supported by the device, the time interval over which + the statistics are computed, and the times at which the minimum + and maximum values occurred, are also reported."; + + leaf instant { + type oc-types:percentage; + description + "The instantaneous percentage value."; + } + + leaf avg { + type oc-types:percentage; + description + "The arithmetic mean value of the percentage measure of the + statistic over the time interval."; + } + + leaf min { + type oc-types:percentage; + description + "The minimum value of the percentage measure of the + statistic over the time interval."; + } + + leaf max { + type oc-types:percentage; + description + "The maximum value of the percentage measure of the + statistic over the time interval."; + } + + uses stat-interval-state; + uses min-max-time; + } + + identity ADDRESS_FAMILY { + description + "A base identity for all address families"; + } + + identity IPV4 { + base ADDRESS_FAMILY; + description + "The IPv4 address family"; + } + + identity IPV6 { + base ADDRESS_FAMILY; + description + "The IPv6 address family"; + } + + identity MPLS { + base ADDRESS_FAMILY; + description + "The MPLS address family"; + } + + identity L2_ETHERNET { + base ADDRESS_FAMILY; + description + "The 802.3 Ethernet address family"; + } + +} diff --git a/src/device/service/drivers/smartnic_probes/probes-agent.yang b/src/device/service/drivers/smartnic_probes/probes-agent.yang index 6029cd204..897d2f129 100644 --- a/src/device/service/drivers/smartnic_probes/probes-agent.yang +++ b/src/device/service/drivers/smartnic_probes/probes-agent.yang @@ -25,32 +25,7 @@ augment '/oc-probes:probes/oc-probes:probe/oc-probes:tests/oc-probes:test/oc-pro uses morpheus_pipelines; } -grouping morpheus_pipelines { - list morpheus_pipelines { - key name; - uses morpheus_pipeline; - } -} - -grouping morpheus_pipeline { - leaf name { type string; } - leaf num_threads { type uint16; } - leaf pipeline_batch_size {type uint64; } - leaf model_max_batch_size {type uint64; } - leaf input_file {type string; } - leaf output_file {type string; } - leaf model_fea_length {type uint16; } - leaf model_name {type string; } - leaf iterative {type boolean; } - leaf server_url {type string; } - leaf file_type {type files; } - list stages { - key name; - uses morpheus_pipeline_stage; - } -} - -typedef files { +typedef files{ type enumeration { enum "auto"; enum "csv"; @@ -58,27 +33,14 @@ typedef files { } } -typedef stage { - type enumeration { - enum "FileSourceStage"; - enum "DeserializeStage"; - enum "AbpPcapPreprocessingStage"; - enum "MonitorStage"; - enum "TritonInferenceStage"; - enum "AddClassificationsStage"; - enum "SerializeStage"; - enum "WriteToFileStage"; - } -} - -grouping prob { +grouping prob{ leaf value { - type string; + type string; // e.g. "probs" description "probs"; } } -grouping conf { +grouping conf{ leaf mode {type string; } leaf num_threads { type uint16; } leaf pipeline_batch_size { type uint64; } @@ -90,20 +52,98 @@ grouping conf { } grouping morpheus_pipeline_stage { - leaf name { type string; } - leaf stage_type {type stage; } - list configuration {key "mode"; uses conf;} - leaf filename {type string;} - leaf iterative {type boolean;} - leaf file_type {type files;} - leaf filter_null {type boolean;} - leaf descriptions {type string;} + leaf stage_name { type string; } + choice stage_type { + case FileSourceStage { + container FileSourceStage { + list fs_configuration {key "mode"; uses conf;} + leaf filename {type string;} + leaf iterative {type boolean;} + leaf file_type {type files;} + leaf filter_null {type boolean;} + } + } + case DeserializeStage { + container DeserializeStage { + list ds_configuration {key "mode"; uses conf;} + } + } + case AbpPcapPreprocessingStage { + container AbpPcapPreprocessingStage { + list apps_configuration {key "mode"; uses conf;} + } + } + case MonitorStage { + container MonitorStage { + list ms_configuration {key "mode"; uses conf;} + leaf descriptions {type string;} + leaf unit {type string;} + } + } + case TritonInferenceStage { + container TritonInferenceStage { + list tis_configuration {key "mode"; uses conf;} + leaf model_name {type string;} + leaf server_url {type string;} + leaf force_convert_inputs {type boolean;} + } + } + case AddClassificationsStage{ + container AddClassificationsStage { + list acs_configuration {key "mode"; uses conf;} + list labels {key "value"; uses prob;} + } + } + case SerializeStage { + container SerializeStage { + list ss_configuration {key "mode"; uses conf;} + leaf kwargs {type empty;} + } + } + case WriteToFileStage{ + container WriteToFileStage { + list wfs_configuration {key "mode"; uses conf;} + leaf wfs_filename {type string;} + leaf overwrite {type boolean;} + } + } + case CustomStage { + list custom { + key "field_name"; + leaf field_name {type string;} + leaf field_value {type string;} + } + } + } +} + +grouping morpheus_pipeline { + leaf pipeline_name {type string;} + leaf num_threads {type uint16;} + leaf pipeline_batch_size {type uint64; } + leaf model_max_batch_size {type uint64; } + leaf input_file {type string;} + leaf output_file {type string;} + leaf model_fea_length {type uint16;} leaf model_name {type string;} + leaf iterative {type boolean;} leaf server_url {type string;} - leaf force_convert_inputs {type boolean;} - leaf unit {type string;} - list labels {key "value"; uses prob;} - leaf kwargs {type empty;} - leaf overwrite {type boolean;} + leaf file_type {type files;} + list stages { + key "stage_name"; + uses morpheus_pipeline_stage; + } +} + +grouping morpheus_pipelines { + list morpheus_pipeline { + key "pipeline_name"; + uses morpheus_pipeline; + } +} + +container morpheus_pipelines { + uses morpheus_pipelines; } + } \ No newline at end of file diff --git a/src/device/service/drivers/smartnic_probes/references_probes_libraries.txt b/src/device/service/drivers/smartnic_probes/references_probes_libraries.txt new file mode 100644 index 000000000..7628b7c2f --- /dev/null +++ b/src/device/service/drivers/smartnic_probes/references_probes_libraries.txt @@ -0,0 +1,6 @@ +ietf-yang-types.yang -> https://github.com/YangModels/yang/blob/main/vendor/cisco/xe/1661/ietf-yang-types.yang +openconfig-extensions.yang -> https://github.com/openconfig/public/blob/master/release/models/openconfig-extensions.yang +openconfig-inet-types.yang -> https://github.com/openconfig/public/blob/master/release/models/types/openconfig-inet-types.yang +openconfig-probes-types.yang -> https://github.com/openconfig/public/blob/master/release/models/probes/openconfig-probes-types.yang +openconfig-probes.yang -> https://github.com/openconfig/public/blob/master/release/models/probes/openconfig-probes.yang +openconfig-types.yang -> https://github.com/openconfig/public/blob/master/release/models/types/openconfig-types.yang -- GitLab From 654eb4328bdb90c9b267cad11683385e02d191f6 Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Wed, 20 Mar 2024 10:14:21 +0000 Subject: [PATCH 10/14] Morpheus Client Extension --- manifests/nginx_ingress_http.yaml | 7 + proto/context.proto | 1 + src/common/DeviceTypes.py | 1 + src/common/tools/object_factory/Device.py | 11 + src/common/type_checkers/Assertions.py | 1 + .../data/sql_hash_join_full_scan_tests.sql | 2 +- .../database/models/enums/DeviceDriver.py | 1 + src/device/service/drivers/__init__.py | 12 + .../drivers/ietf_l2vpn/TfsDebugApiClient.py | 2 + .../drivers/smartnic/SmartnicDriver.py | 122 ++++ src/device/service/drivers/smartnic/Tools.py | 174 +++++ .../service/drivers/smartnic/__init__.py | 20 + src/nbi/service/__main__.py | 2 + .../nbi_plugins/agent_probes/Resources.py | 236 +++++++ .../nbi_plugins/agent_probes/Tools.py | 118 ++++ .../nbi_plugins/agent_probes/__init__.py | 69 ++ .../data/agent_probes_configuration_rule.json | 17 + src/nbi/tests/data/agent_probes_device.json | 27 + src/policy/Dockerfile | 67 +- .../java/org/etsi/tfs/policy/Serializer.java | 4 + .../context/model/DeviceDriverEnum.java | 3 +- src/policy/src/main/proto/acl.proto | 70 +- src/policy/src/main/proto/context.proto | 616 +++++++++++++++++- .../src/main/proto/context_policy.proto | 29 +- src/policy/src/main/proto/device.proto | 35 +- .../src/main/proto/kpi_sample_types.proto | 43 +- src/policy/src/main/proto/monitoring.proto | 175 ++++- src/policy/src/main/proto/policy.proto | 114 +++- src/policy/src/main/proto/policy_action.proto | 43 +- .../src/main/proto/policy_condition.proto | 44 +- src/policy/src/main/proto/service.proto | 26 +- .../service_handler_api/FilterFields.py | 1 + .../service/service_handlers/__init__.py | 6 + src/webui/service/device/forms.py | 1 + src/webui/service/device/routes.py | 2 + src/webui/service/templates/device/add.html | 1 + src/ztp/Dockerfile | 68 +- src/ztp/src/main/proto/acl.proto | 70 +- src/ztp/src/main/proto/context.proto | 616 +++++++++++++++++- src/ztp/src/main/proto/device.proto | 35 +- src/ztp/src/main/proto/kpi_sample_types.proto | 43 +- src/ztp/src/main/proto/monitoring.proto | 175 ++++- src/ztp/src/main/proto/ztp.proto | 70 +- 43 files changed, 3160 insertions(+), 20 deletions(-) create mode 100644 src/device/service/drivers/smartnic/SmartnicDriver.py create mode 100644 src/device/service/drivers/smartnic/Tools.py create mode 100644 src/device/service/drivers/smartnic/__init__.py create mode 100644 src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py create mode 100644 src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py create mode 100644 src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py create mode 100644 src/nbi/tests/data/agent_probes_configuration_rule.json create mode 100644 src/nbi/tests/data/agent_probes_device.json mode change 120000 => 100644 src/policy/Dockerfile mode change 120000 => 100644 src/policy/src/main/proto/acl.proto mode change 120000 => 100644 src/policy/src/main/proto/context.proto mode change 120000 => 100644 src/policy/src/main/proto/context_policy.proto mode change 120000 => 100644 src/policy/src/main/proto/device.proto mode change 120000 => 100644 src/policy/src/main/proto/kpi_sample_types.proto mode change 120000 => 100644 src/policy/src/main/proto/monitoring.proto mode change 120000 => 100644 src/policy/src/main/proto/policy.proto mode change 120000 => 100644 src/policy/src/main/proto/policy_action.proto mode change 120000 => 100644 src/policy/src/main/proto/policy_condition.proto mode change 120000 => 100644 src/policy/src/main/proto/service.proto mode change 120000 => 100644 src/ztp/Dockerfile mode change 120000 => 100644 src/ztp/src/main/proto/acl.proto mode change 120000 => 100644 src/ztp/src/main/proto/context.proto mode change 120000 => 100644 src/ztp/src/main/proto/device.proto mode change 120000 => 100644 src/ztp/src/main/proto/kpi_sample_types.proto mode change 120000 => 100644 src/ztp/src/main/proto/monitoring.proto mode change 120000 => 100644 src/ztp/src/main/proto/ztp.proto diff --git a/manifests/nginx_ingress_http.yaml b/manifests/nginx_ingress_http.yaml index e8e8a80e4..336f164b4 100644 --- a/manifests/nginx_ingress_http.yaml +++ b/manifests/nginx_ingress_http.yaml @@ -50,6 +50,13 @@ spec: name: nbiservice port: number: 8080 + - path: /()(agent-probes/.*) + pathType: Prefix + backend: + service: + name: nbiservice + port: + number: 8080 - path: /()(bmw/.*) pathType: Prefix backend: diff --git a/proto/context.proto b/proto/context.proto index 5085cad33..856caa4f9 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -204,6 +204,7 @@ enum DeviceDriverEnum { DEVICEDRIVER_GNMI_OPENCONFIG = 8; DEVICEDRIVER_FLEXSCALE = 9; DEVICEDRIVER_IETF_ACTN = 10; + DEVICEDRIVER_SMARTNIC = 12; } enum DeviceOperationalStatusEnum { diff --git a/src/common/DeviceTypes.py b/src/common/DeviceTypes.py index 72b3e21fd..5ed4b6681 100644 --- a/src/common/DeviceTypes.py +++ b/src/common/DeviceTypes.py @@ -47,6 +47,7 @@ class DeviceTypeEnum(Enum): PACKET_ROUTER = 'packet-router' PACKET_SWITCH = 'packet-switch' XR_CONSTELLATION = 'xr-constellation' + SMARTNIC = 'smartnic' # ETSI TeraFlowSDN controller TERAFLOWSDN_CONTROLLER = 'teraflowsdn' diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index 76959232a..b3182e302 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -49,6 +49,9 @@ DEVICE_TFS_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_IETF_L2VPN] DEVICE_IETF_ACTN_TYPE = DeviceTypeEnum.OPEN_LINE_SYSTEM.value DEVICE_IETF_ACTN_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN] +DEVICE_SMARTNIC_TYPE = DeviceTypeEnum.SMARTNIC.value +DEVICE_SMARTNIC_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_SMARTNIC] + def json_device_id(device_uuid : str): return {'device_uuid': {'uuid': device_uuid}} @@ -148,6 +151,14 @@ def json_device_ietf_actn_disabled( device_uuid, DEVICE_IETF_ACTN_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, drivers=drivers) +def json_device_smartnic_disabled( + device_uuid : str, name : Optional[str] = None, endpoints : List[Dict] = [], config_rules : List[Dict] = [], + drivers : List[Dict] = DEVICE_SMARTNIC_DRIVERS + ): + return json_device( + device_uuid, DEVICE_SMARTNIC_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, + drivers=drivers) + def json_device_connect_rules(address : str, port : int, settings : Dict = {}) -> List[Dict]: return [ json_config_rule_set('_connect/address', address), diff --git a/src/common/type_checkers/Assertions.py b/src/common/type_checkers/Assertions.py index 87d8e54ee..06bcd4482 100644 --- a/src/common/type_checkers/Assertions.py +++ b/src/common/type_checkers/Assertions.py @@ -48,6 +48,7 @@ def validate_device_driver_enum(message): 'DEVICEDRIVER_GNMI_OPENCONFIG', 'DEVICEDRIVER_FLEXSCALE', 'DEVICEDRIVER_IETF_ACTN', + 'DEVICEDRIVER_SMARTNIC' ] def validate_device_operational_status_enum(message): diff --git a/src/context/data/sql_hash_join_full_scan_tests.sql b/src/context/data/sql_hash_join_full_scan_tests.sql index ebead1be6..34330f916 100644 --- a/src/context/data/sql_hash_join_full_scan_tests.sql +++ b/src/context/data/sql_hash_join_full_scan_tests.sql @@ -9,7 +9,7 @@ CREATE DATABASE tests; USE tests; CREATE TYPE public.orm_deviceoperationalstatusenum AS ENUM ('UNDEFINED', 'DISABLED', 'ENABLED'); -CREATE TYPE public.orm_devicedriverenum AS ENUM ('UNDEFINED', 'OPENCONFIG', 'TRANSPORT_API', 'P4', 'IETF_NETWORK_TOPOLOGY', 'ONF_TR_352', 'XR', 'IETF_L2VPN'); +CREATE TYPE public.orm_devicedriverenum AS ENUM ('UNDEFINED', 'OPENCONFIG', 'TRANSPORT_API', 'P4', 'IETF_NETWORK_TOPOLOGY', 'ONF_TR_352', 'XR', 'IETF_L2VPN', 'SMARTNIC'); CREATE TYPE public.configrulekindenum AS ENUM ('CUSTOM', 'ACL'); CREATE TYPE public.orm_configactionenum AS ENUM ('UNDEFINED', 'SET', 'DELETE'); diff --git a/src/context/service/database/models/enums/DeviceDriver.py b/src/context/service/database/models/enums/DeviceDriver.py index 8e15bf058..559291965 100644 --- a/src/context/service/database/models/enums/DeviceDriver.py +++ b/src/context/service/database/models/enums/DeviceDriver.py @@ -33,6 +33,7 @@ class ORM_DeviceDriverEnum(enum.Enum): GNMI_OPENCONFIG = DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG FLEXSCALE = DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE IETF_ACTN = DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN + SMARTNIC = DeviceDriverEnum.DEVICEDRIVER_SMARTNIC grpc_to_enum__device_driver = functools.partial( grpc_to_enum, DeviceDriverEnum, ORM_DeviceDriverEnum) diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py index 27c61f89f..1534655db 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -136,6 +136,18 @@ if LOAD_ALL_DEVICE_DRIVERS: FilterFieldEnum.DRIVER : DeviceDriverEnum.DEVICEDRIVER_P4, } ])) + +if LOAD_ALL_DEVICE_DRIVERS: + from .smartnic.SmartnicDriver import SmartnicDriver # pylint: disable=wrong-import-position + DRIVERS.append( + (SmartnicDriver, [ + { + # Real P4 Switch, specifying P4 Driver => use P4Driver + FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.SMARTNIC, + FilterFieldEnum.DRIVER : DeviceDriverEnum.DEVICEDRIVER_SMARTNIC, + } + ])) + if LOAD_ALL_DEVICE_DRIVERS: from .microwave.IETFApiDriver import IETFApiDriver # pylint: disable=wrong-import-position diff --git a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py index 06c55c5dc..ee2d1ab6e 100644 --- a/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py +++ b/src/device/service/drivers/ietf_l2vpn/TfsDebugApiClient.py @@ -45,6 +45,8 @@ MAPPING_DRIVER = { 'DEVICEDRIVER_IETF_L2VPN' : 7, 'DEVICEDRIVER_GNMI_OPENCONFIG' : 8, 'DEVICEDRIVER_FLEXSCALE' : 9, + 'DEVICEDRIVER_IETF_ACTN' : 10, + 'DEVICEDRIVER_SMARTNIC' : 12 } MSG_ERROR = 'Could not retrieve devices in remote TeraFlowSDN instance({:s}). status_code={:s} reply={:s}' diff --git a/src/device/service/drivers/smartnic/SmartnicDriver.py b/src/device/service/drivers/smartnic/SmartnicDriver.py new file mode 100644 index 000000000..4bad52db4 --- /dev/null +++ b/src/device/service/drivers/smartnic/SmartnicDriver.py @@ -0,0 +1,122 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +import logging, requests, threading +from requests.auth import HTTPBasicAuth +from typing import Any, Iterator, List, Optional, Tuple, Union +from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method +from common.type_checkers.Checkers import chk_string, chk_type +from device.service.driver_api._Driver import _Driver +from . import ALL_RESOURCE_KEYS +from .Tools import create_connectivity_service, find_key, config_getter, delete_connectivity_service + +LOGGER = logging.getLogger(__name__) + +DRIVER_NAME = 'smartnic' +METRICS_POOL = MetricsPool('Device', 'Driver', labels={'driver': DRIVER_NAME}) + +class SmartnicDriver(_Driver): + def __init__(self, address: str, port: int, **settings) -> None: + super().__init__(DRIVER_NAME, address, port, **settings) + self.__lock = threading.Lock() + self.__started = threading.Event() + self.__terminate = threading.Event() + username = self.settings.get('username') + password = self.settings.get('password') + #self.__auth = HTTPBasicAuth(username, password) if username is not None and password is not None else None + scheme = self.settings.get('scheme', 'http') + self.__tapi_root = '{:s}://{:s}:{:d}'.format(scheme, self.address, int(self.port)) + self.__timeout = int(self.settings.get('timeout', 120)) + + def Connect(self) -> bool: + url = self.__tapi_root + with self.__lock: + if self.__started.is_set(): return True + try: + requests.get(url, timeout=self.__timeout, verify=False) + #requests.get(url, timeout=self.__timeout, verify=False, auth=self.__auth) + except requests.exceptions.Timeout: + LOGGER.exception('Timeout connecting {:s}'.format(str(self.__tapi_root))) + return False + except Exception: # pylint: disable=broad-except + LOGGER.exception('Exception connecting {:s}'.format(str(self.__tapi_root))) + return False + else: + self.__started.set() + return True + + def Disconnect(self) -> bool: + with self.__lock: + self.__terminate.set() + return True + + @metered_subclass_method(METRICS_POOL) + def GetInitialConfig(self) -> List[Tuple[str, Any]]: + with self.__lock: + return [] + + @metered_subclass_method(METRICS_POOL) + def GetConfig(self, resource_keys : List[str] = []) -> List[Tuple[str, Union[Any, None, Exception]]]: + chk_type('resources', resource_keys, list) + results = [] + with self.__lock: + if len(resource_keys) == 0: resource_keys = ALL_RESOURCE_KEYS + for i, resource_key in enumerate(resource_keys): + str_resource_name = 'resource_key[#{:d}]'.format(i) + chk_string(str_resource_name, resource_key, allow_empty=False) + results.extend(config_getter( + self.__tapi_root, resource_key, timeout=self.__timeout)) + return results + + @metered_subclass_method(METRICS_POOL) + def SetConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: + results = [] + if len(resources) == 0: + return results + with self.__lock: + for resource in resources: + LOGGER.info('resource = {:s}'.format(str(resource))) + config_rules = find_key(resource, 'config_rules') + data = create_connectivity_service( + self.__tapi_root, config_rules, timeout=self.__timeout) + results.extend(data) + return results + + @metered_subclass_method(METRICS_POOL) + def DeleteConfig(self, resources: List[Tuple[str, Any]]) -> List[Union[bool, Exception]]: + results = [] + if len(resources) == 0: return results + with self.__lock: + for resource in resources: + LOGGER.info('resource = {:s}'.format(str(resource))) + config_rules = find_key(resource, 'config_rules') + results.extend(delete_connectivity_service( + self.__tapi_root, config_rules, timeout=self.__timeout)) + return results + + @metered_subclass_method(METRICS_POOL) + def SubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: + # TODO: TAPI does not support monitoring by now + return [False for _ in subscriptions] + + @metered_subclass_method(METRICS_POOL) + def UnsubscribeState(self, subscriptions : List[Tuple[str, float, float]]) -> List[Union[bool, Exception]]: + # TODO: TAPI does not support monitoring by now + return [False for _ in subscriptions] + + def GetState( + self, blocking=False, terminate : Optional[threading.Event] = None + ) -> Iterator[Tuple[float, str, Any]]: + # TODO: TAPI does not support monitoring by now + return [] diff --git a/src/device/service/drivers/smartnic/Tools.py b/src/device/service/drivers/smartnic/Tools.py new file mode 100644 index 000000000..54961bbdd --- /dev/null +++ b/src/device/service/drivers/smartnic/Tools.py @@ -0,0 +1,174 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +import json, logging, operator, requests +from requests.auth import HTTPBasicAuth +from typing import Optional +#from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_SERVICES, RESOURCE_INTERFACES + + +import logging +from typing import Any, Dict, Optional, Tuple +from common.proto.kpi_sample_types_pb2 import KpiSampleType +from common.type_checkers.Checkers import chk_attribute, chk_string, chk_type +from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_INTERFACES + +LOGGER = logging.getLogger(__name__) + + +SPECIAL_RESOURCE_MAPPINGS = { + RESOURCE_ENDPOINTS : '/endpoints', + RESOURCE_INTERFACES : '/interfaces' +} + +HTTP_OK_CODES = { + 200, # OK + 201, # Created + 202, # Accepted + 204, # No Content +} + +def find_key(resource, key): + return json.loads(resource[1])[key] + + +def config_getter( + root_url : str, resource_key : str, auth : Optional[HTTPBasicAuth] = None, timeout : Optional[int] = None +): + url = '{:s}/manage-probe/ports'.format(root_url) + result = [] + try: + response = requests.get(url, timeout=timeout, verify=False) + except requests.exceptions.Timeout: + LOGGER.exception('Timeout connecting {:s}'.format(url)) + return result + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception retrieving {:s}'.format(resource_key)) + result.append((resource_key, e)) + return result + return response + + # try: + # context = json.loads(response.content) + # except Exception as e: # pylint: disable=broad-except + # LOGGER.warning('Unable to decode reply: {:s}'.format(str(response.content))) + # result.append((resource_key, e)) + # return result + + + +def create_connectivity_service( + root_url, config_rules, timeout : Optional[int] = None, auth : Optional[HTTPBasicAuth] = None +): + + url = '{:s}/configure'.format(root_url) + headers = {'content-type': 'application/json'} + results = [] + try: + LOGGER.info('Configuring Smartnic rules') + response = requests.post( + url=url, data=json.dumps(config_rules), timeout=timeout, headers=headers, verify=False) + LOGGER.info('SmartNIC Probes response: {:s}'.format(str(response))) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception creating ConfigRule') + results.append(e) + else: + if response.status_code not in HTTP_OK_CODES: + msg = 'Could not create ConfigRule status_code={:s} reply={:s}' + LOGGER.error(msg.format(str(response.status_code), str(response))) + results.append(response.status_code in HTTP_OK_CODES) + return results + +def delete_connectivity_service(root_url, config_rules, timeout : Optional[int] = None, auth : Optional[HTTPBasicAuth] = None +): + url = '{:s}/configure'.format(root_url) + results = [] + try: + response = requests.delete(url=url, timeout=timeout, verify=False) + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception deleting ConfigRule') + results.append(e) + else: + if response.status_code not in HTTP_OK_CODES: + msg = 'Could not delete ConfigRule status_code={:s} reply={:s}' + LOGGER.error(msg.format(str(response.status_code), str(response))) + results.append(response.status_code in HTTP_OK_CODES) + return results + +def process_optional_string_field( + endpoint_data : Dict[str, Any], field_name : str, endpoint_resource_value : Dict[str, Any] +) -> None: + field_value = chk_attribute(field_name, endpoint_data, 'endpoint_data', default=None) + if field_value is None: return + chk_string('endpoint_data.{:s}'.format(field_name), field_value) + if len(field_value) > 0: endpoint_resource_value[field_name] = field_value + +def compose_resource_endpoint(endpoint_data : Dict[str, Any]) -> Optional[Tuple[str, Dict]]: + try: + # Check type of endpoint_data + chk_type('endpoint_data', endpoint_data, dict) + + # Check endpoint UUID (mandatory) + endpoint_uuid = chk_attribute('uuid', endpoint_data, 'endpoint_data') + chk_string('endpoint_data.uuid', endpoint_uuid, min_length=1) + endpoint_resource_path = SPECIAL_RESOURCE_MAPPINGS.get(RESOURCE_ENDPOINTS) + endpoint_resource_key = '{:s}/endpoint[{:s}]'.format(endpoint_resource_path, endpoint_uuid) + endpoint_resource_value = {'uuid': endpoint_uuid} + + # Check endpoint optional string fields + process_optional_string_field(endpoint_data, 'name', endpoint_resource_value) + process_optional_string_field(endpoint_data, 'type', endpoint_resource_value) + process_optional_string_field(endpoint_data, 'context_uuid', endpoint_resource_value) + process_optional_string_field(endpoint_data, 'topology_uuid', endpoint_resource_value) + + # Check endpoint sample types (optional) + endpoint_sample_types = chk_attribute('sample_types', endpoint_data, 'endpoint_data', default=[]) + chk_type('endpoint_data.sample_types', endpoint_sample_types, list) + sample_types = {} + sample_type_errors = [] + for i,endpoint_sample_type in enumerate(endpoint_sample_types): + field_name = 'endpoint_data.sample_types[{:d}]'.format(i) + try: + chk_type(field_name, endpoint_sample_type, (int, str)) + if isinstance(endpoint_sample_type, int): + metric_name = KpiSampleType.Name(endpoint_sample_type) + metric_id = endpoint_sample_type + elif isinstance(endpoint_sample_type, str): + metric_id = KpiSampleType.Value(endpoint_sample_type) + metric_name = endpoint_sample_type + else: + str_type = str(type(endpoint_sample_type)) + raise Exception('Bad format: {:s}'.format(str_type)) # pylint: disable=broad-exception-raised + except Exception as e: # pylint: disable=broad-exception-caught + MSG = 'Unsupported {:s}({:s}) : {:s}' + sample_type_errors.append(MSG.format(field_name, str(endpoint_sample_type), str(e))) + + metric_name = metric_name.lower().replace('kpisampletype_', '') + monitoring_resource_key = '{:s}/state/{:s}'.format(endpoint_resource_key, metric_name) + sample_types[metric_id] = monitoring_resource_key + + if len(sample_type_errors) > 0: + # pylint: disable=broad-exception-raised + raise Exception('Malformed Sample Types:\n{:s}'.format('\n'.join(sample_type_errors))) + + if len(sample_types) > 0: + endpoint_resource_value['sample_types'] = sample_types + + if 'location' in endpoint_data: + endpoint_resource_value['location'] = endpoint_data['location'] + + return endpoint_resource_key, endpoint_resource_value + except: # pylint: disable=bare-except + LOGGER.exception('Problem composing endpoint({:s})'.format(str(endpoint_data))) + return None diff --git a/src/device/service/drivers/smartnic/__init__.py b/src/device/service/drivers/smartnic/__init__.py new file mode 100644 index 000000000..bc88d00fa --- /dev/null +++ b/src/device/service/drivers/smartnic/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. +from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_SERVICES, RESOURCE_INTERFACES + +ALL_RESOURCE_KEYS = [ + RESOURCE_ENDPOINTS, + RESOURCE_SERVICES, + RESOURCE_INTERFACES +] diff --git a/src/nbi/service/__main__.py b/src/nbi/service/__main__.py index 8834e45a2..0b6fb18e3 100644 --- a/src/nbi/service/__main__.py +++ b/src/nbi/service/__main__.py @@ -20,6 +20,7 @@ from common.Settings import ( wait_for_environment_variables) from .NbiService import NbiService from .rest_server.RestServer import RestServer +from .rest_server.nbi_plugins.agent_probes import register_agent_probes from .rest_server.nbi_plugins.debug_api import register_debug_api from .rest_server.nbi_plugins.etsi_bwm import register_etsi_bwm_api from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn @@ -62,6 +63,7 @@ def main(): grpc_service.start() rest_server = RestServer() + register_agent_probes(rest_server) register_debug_api(rest_server) register_etsi_bwm_api(rest_server) register_ietf_l2vpn(rest_server) # Registering L2VPN entrypoint diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py new file mode 100644 index 000000000..2b0a537cc --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py @@ -0,0 +1,236 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +import json +from flask.json import jsonify +from flask_restful import Resource, request +from common.proto.context_pb2 import Empty +from common.tools.grpc.Tools import grpc_message_to_json +from context.client.ContextClient import ContextClient +from device.client.DeviceClient import DeviceClient +from service.client.ServiceClient import ServiceClient +from .Tools import ( + format_grpc_to_json, grpc_connection_id, grpc_context_id, grpc_device, grpc_device_id, grpc_link_id, grpc_policy_rule_id, + grpc_service_id, grpc_service, grpc_slice_id, grpc_topology_id) + +class _Resource(Resource): + def __init__(self) -> None: + super().__init__() + self.client = ContextClient() + self.device_client = DeviceClient() + self.service_client = ServiceClient() + +class ContextIds(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListContextIds(Empty())) + +class Contexts(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListContexts(Empty())) + +class DummyContexts(_Resource): + def get(self): + contexts = grpc_message_to_json(self.client.ListContexts(Empty()), use_integers_for_enums=True)['contexts'] + devices = grpc_message_to_json(self.client.ListDevices(Empty()), use_integers_for_enums=True)['devices'] + links = grpc_message_to_json(self.client.ListLinks(Empty()), use_integers_for_enums=True)['links'] + + topologies = list() + slices = list() + services = list() + connections = list() + + for context in contexts: + context_uuid = context['context_id']['context_uuid']['uuid'] + context_id = grpc_context_id(context_uuid) + + topologies.extend(grpc_message_to_json( + self.client.ListTopologies(context_id), + use_integers_for_enums=True + )['topologies']) + + slices.extend(grpc_message_to_json( + self.client.ListSlices(context_id), + use_integers_for_enums=True + )['slices']) + + context_services = grpc_message_to_json( + self.client.ListServices(context_id), + use_integers_for_enums=True + )['services'] + services.extend(context_services) + + for service in context_services: + service_uuid = service['service_id']['service_uuid']['uuid'] + service_id = grpc_service_id(context_uuid, service_uuid) + connections.extend(grpc_message_to_json( + self.client.ListConnections(service_id), + use_integers_for_enums=True + )['connections']) + + for device in devices: + for config_rule in device['device_config']['config_rules']: + if 'custom' not in config_rule: continue + resource_value = config_rule['custom']['resource_value'] + if not isinstance(resource_value, str): continue + try: + resource_value = json.loads(resource_value) + except: # pylint: disable=bare-except + pass + config_rule['custom']['resource_value'] = resource_value + + dummy_context = {'dummy_mode': True} + if len(contexts ) > 0: dummy_context['contexts' ] = contexts + if len(topologies ) > 0: dummy_context['topologies' ] = topologies + if len(devices ) > 0: dummy_context['devices' ] = devices + if len(links ) > 0: dummy_context['links' ] = links + if len(slices ) > 0: dummy_context['slices' ] = slices + if len(services ) > 0: dummy_context['services' ] = services + if len(connections) > 0: dummy_context['connections'] = connections + return jsonify(dummy_context) + +class Context(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.GetContext(grpc_context_id(context_uuid))) + +class TopologyIds(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListTopologyIds(grpc_context_id(context_uuid))) + +class Topologies(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListTopologies(grpc_context_id(context_uuid))) + +class Topology(_Resource): + def get(self, context_uuid : str, topology_uuid : str): + return format_grpc_to_json(self.client.GetTopology(grpc_topology_id(context_uuid, topology_uuid))) + +class ServiceIds(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListServiceIds(grpc_context_id(context_uuid))) + +class Services(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListServices(grpc_context_id(context_uuid))) + +class Service(_Resource): + def get(self, context_uuid : str, service_uuid : str): + return format_grpc_to_json(self.client.GetService(grpc_service_id(context_uuid, service_uuid))) + + def post(self, context_uuid : str, service_uuid : str): # pylint: disable=unused-argument + service = request.get_json()['services'][0] + return format_grpc_to_json(self.service_client.CreateService(grpc_service( + service_uuid = service['service_id']['service_uuid']['uuid'], + service_type = service['service_type'], + context_uuid = service['service_id']['context_id']['context_uuid']['uuid'], + ))) + + def put(self, context_uuid : str, service_uuid : str): # pylint: disable=unused-argument + service = request.get_json()['services'][0] + return format_grpc_to_json(self.service_client.UpdateService(grpc_service( + service_uuid = service['service_id']['service_uuid']['uuid'], + service_type = service['service_type'], + context_uuid = service['service_id']['context_id']['context_uuid']['uuid'], + status = service['service_status']['service_status'], + endpoint_ids = service['service_endpoint_ids'], + constraints = service['service_constraints'], + config_rules = service['service_config']['config_rules'] + ))) + + def delete(self, context_uuid : str, service_uuid : str): + return format_grpc_to_json(self.service_client.DeleteService(grpc_service_id( + context_uuid, service_uuid, + ))) + +class SliceIds(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListSliceIds(grpc_context_id(context_uuid))) + +class Slices(_Resource): + def get(self, context_uuid : str): + return format_grpc_to_json(self.client.ListSlices(grpc_context_id(context_uuid))) + +class Slice(_Resource): + def get(self, context_uuid : str, slice_uuid : str): + return format_grpc_to_json(self.client.GetSlice(grpc_slice_id(context_uuid, slice_uuid))) + +class DeviceIds(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListDeviceIds(Empty())) + +class Devices(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListDevices(Empty())) + +class Device(_Resource): + def get(self, device_uuid : str): + return format_grpc_to_json(self.client.GetDevice(grpc_device_id(device_uuid))) + + def post(self, device_uuid : str): # pylint: disable=unused-argument + device = request.get_json()['devices'][0] + return format_grpc_to_json(self.device_client.AddDevice(grpc_device( + device_uuid = device['device_id']['device_uuid']['uuid'], + device_type = device['device_type'], + config_rules = device['device_config']['config_rules'], + status = device['device_operational_status'], + drivers = device['device_drivers'], + endpoints = device['device_endpoints'] + ))) + + def put(self, device_uuid : str): # pylint: disable=unused-argument + device = request.get_json()['devices'][0] + return format_grpc_to_json(self.device_client.ConfigureDevice(grpc_device( + device_uuid = device['device_id']['device_uuid']['uuid'], + device_type = device['device_type'], + device_config = device['device_config']['config_rules'], + device_operational_status = device['device_operational_status'], + device_drivers = device['device_drivers'], + device_endpoints = device['device_endpoints'] + ))) + + +class LinkIds(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListLinkIds(Empty())) + +class Links(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListLinks(Empty())) + +class Link(_Resource): + def get(self, link_uuid : str): + return format_grpc_to_json(self.client.GetLink(grpc_link_id(link_uuid))) + +class ConnectionIds(_Resource): + def get(self, context_uuid : str, service_uuid : str): + return format_grpc_to_json(self.client.ListConnectionIds(grpc_service_id(context_uuid, service_uuid))) + +class Connections(_Resource): + def get(self, context_uuid : str, service_uuid : str): + return format_grpc_to_json(self.client.ListConnections(grpc_service_id(context_uuid, service_uuid))) + +class Connection(_Resource): + def get(self, connection_uuid : str): + return format_grpc_to_json(self.client.GetConnection(grpc_connection_id(connection_uuid))) + +class PolicyRuleIds(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListPolicyRuleIds(Empty())) + +class PolicyRules(_Resource): + def get(self): + return format_grpc_to_json(self.client.ListPolicyRules(Empty())) + +class PolicyRule(_Resource): + def get(self, policy_rule_uuid : str): + return format_grpc_to_json(self.client.GetPolicyRule(grpc_policy_rule_id(policy_rule_uuid))) diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py new file mode 100644 index 000000000..17b6dcdfd --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py @@ -0,0 +1,118 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +from flask.json import jsonify +from common.proto.context_pb2 import ( + ConnectionId, ContextId, DeviceDriverEnum, Device, DeviceId, DeviceOperationalStatusEnum, LinkId, ServiceId, SliceId, TopologyId, Service, ServiceStatusEnum +) +from common.proto.policy_pb2 import PolicyRuleId +from common.tools.grpc.Tools import grpc_message_to_json +from common.tools.object_factory.Connection import json_connection_id +from common.tools.object_factory.Context import json_context_id +from common.tools.object_factory.ConfigRule import json_config_rule +from common.tools.object_factory.Constraint import json_constraint_custom +from common.tools.object_factory.EndPoint import json_endpoint_id, json_endpoint +from common.tools.object_factory.Device import json_device_id, json_device +from common.tools.object_factory.Link import json_link_id +from common.tools.object_factory.PolicyRule import json_policyrule_id +from common.tools.object_factory.Service import json_service_id, json_service +from common.tools.object_factory.Slice import json_slice_id +from common.tools.object_factory.Topology import json_topology_id + + +def format_grpc_to_json(grpc_reply): + return jsonify(grpc_message_to_json(grpc_reply)) + +def grpc_connection_id(connection_uuid): + return ConnectionId(**json_connection_id(connection_uuid)) + +def grpc_context_id(context_uuid): + return ContextId(**json_context_id(context_uuid)) + +def grpc_device_id(device_uuid): + return DeviceId(**json_device_id(device_uuid)) + +def grpc_device( + device_uuid, device_type, config_rules=None, status=None, drivers=None, endpoints=None +): + json_config_rules = [ + json_config_rule( + config_rule['action'], + config_rule['custom']['resource_key'], + config_rule['custom']['resource_value'] + ) + for config_rule in config_rules + ] if config_rules else [] + json_status = status if status else DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_UNDEFINED + json_drivers = drivers if drivers else DeviceDriverEnum.DEVICEDRIVER_UNDEFINED + json_endpoints = [ + json_endpoint( + endpoint['device_id']['device_uuid']['uuid'], + endpoint['endpoint_uuid']['uuid'], + endpoint['endpoint_type'], + endpoint['topology_id'], + endpoint['kpi_sample_types'], + endpoint['location']['region'] + ) + for endpoint in endpoints + ] if endpoints else [] + return Device(**json_device( + device_uuid, device_type, json_config_rules, json_status, + json_drivers, json_endpoints)) + +def grpc_link_id(link_uuid): + return LinkId(**json_link_id(link_uuid)) + +def grpc_service_id(context_uuid, service_uuid): + return ServiceId(**json_service_id(service_uuid, context_id=json_context_id(context_uuid))) + +def grpc_service( + service_uuid, service_type, context_uuid, status=None, endpoint_ids=None, constraints=None, config_rules=None +): + json_context = json_context_id(context_uuid) + json_status = status if status else ServiceStatusEnum.SERVICESTATUS_PLANNED + json_endpoints_ids = [ + json_endpoint_id( + json_device_id(endpoint_id['device_id']['device_uuid']['uuid']), + endpoint_id['endpoint_uuid']['uuid'] + ) + for endpoint_id in endpoint_ids + ] if endpoint_ids else [] + json_constraints = [ + json_constraint_custom( + constraint['custom']['constraint_type'], + constraint['custom']['constraint_value'] + ) + for constraint in constraints + ] if constraints else [] + json_config_rules = [ + json_config_rule( + config_rule['action'], + config_rule['custom']['resource_key'], + config_rule['custom']['resource_value'] + ) + for config_rule in config_rules + ] if config_rules else [] + return Service(**json_service( + service_uuid, service_type, json_context, json_status, + json_endpoints_ids, json_constraints, json_config_rules)) + +def grpc_slice_id(context_uuid, slice_uuid): + return SliceId(**json_slice_id(slice_uuid, context_id=json_context_id(context_uuid))) + +def grpc_topology_id(context_uuid, topology_uuid): + return TopologyId(**json_topology_id(topology_uuid, context_id=json_context_id(context_uuid))) + +def grpc_policy_rule_id(policy_rule_uuid): + return PolicyRuleId(**json_policyrule_id(policy_rule_uuid)) diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py new file mode 100644 index 000000000..0b85500fc --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py @@ -0,0 +1,69 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +from nbi.service.rest_server.RestServer import RestServer +from .Resources import ( + Connection, ConnectionIds, Connections, + Context, ContextIds, Contexts, + Device, DeviceIds, Devices, + DummyContexts, + Link, LinkIds, Links, + PolicyRule, PolicyRuleIds, PolicyRules, + Service, ServiceIds, Services, + Slice, SliceIds, Slices, + Topologies, Topology, TopologyIds +) + +URL_PREFIX = '/agent-probes' + +# Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type. +RESOURCES = [ + # (endpoint_name, resource_class, resource_url) + # ('api.context_ids', ContextIds, '/context_ids'), + # ('api.contexts', Contexts, '/contexts'), + # ('api.dummy_contexts', DummyContexts, '/dummy_contexts'), + # ('api.context', Context, '/context/<path:context_uuid>'), + + # ('api.topology_ids', TopologyIds, '/context/<path:context_uuid>/topology_ids'), + # ('api.topologies', Topologies, '/context/<path:context_uuid>/topologies'), + # ('api.topology', Topology, '/context/<path:context_uuid>/topology/<path:topology_uuid>'), + + # ('api.service_ids', ServiceIds, '/context/<path:context_uuid>/service_ids'), + # ('api.services', Services, '/context/<path:context_uuid>/services'), + # ('api.service', Service, '/context/<path:context_uuid>/service/<path:service_uuid>'), + + # ('api.slice_ids', SliceIds, '/context/<path:context_uuid>/slice_ids'), + # ('api.slices', Slices, '/context/<path:context_uuid>/slices'), + # ('api.slice', Slice, '/context/<path:context_uuid>/slice/<path:slice_uuid>'), + + ('api.smartnic.device_ids', DeviceIds, '/device_ids'), + ('api.smartnic.devices', Devices, '/devices'), + ('api.smartnic.device', Device, '/device/<path:device_uuid>'), + + # ('api.link_ids', LinkIds, '/link_ids'), + # ('api.links', Links, '/links'), + # ('api.link', Link, '/link/<path:link_uuid>'), + + # ('api.connection_ids', ConnectionIds, '/context/<path:context_uuid>/service/<path:service_uuid>/connection_ids'), + # ('api.connections', Connections, '/context/<path:context_uuid>/service/<path:service_uuid>/connections'), + # ('api.connection', Connection, '/connection/<path:connection_uuid>'), + + # ('api.policyrule_ids', PolicyRuleIds, '/policyrule_ids'), + # ('api.policyrules', PolicyRules, '/policyrules'), + # ('api.policyrule', PolicyRule, '/policyrule/<path:policyrule_uuid>'), +] + +def register_agent_probes(rest_server : RestServer): + for endpoint_name, resource_class, resource_url in RESOURCES: + rest_server.add_resource(resource_class, URL_PREFIX + resource_url, endpoint=endpoint_name) diff --git a/src/nbi/tests/data/agent_probes_configuration_rule.json b/src/nbi/tests/data/agent_probes_configuration_rule.json new file mode 100644 index 000000000..dbbf953ad --- /dev/null +++ b/src/nbi/tests/data/agent_probes_configuration_rule.json @@ -0,0 +1,17 @@ +{ + "devices": [ + { + "device_id": {"device_uuid":{"uuid":"smp-01"}}, + "device_type": "smartnic", + "device_config": {"config_rules": [ + {"action": 1, "custom": { + "resource_key": "config_rules", + "resource_value": {"pipeline_name":"pipeline_example","num_threads":2,"pipeline_batch_size":2048,"model_max_batch_size":4096,"input_file":"inputfile1.csv","output_file":"outputfile1.csv","nic_addr": "10.10.2.25", "gpu_addr":"11.6.15.2", "model_fea_length":8,"model_name":"modelname1","iterative":false,"server_url":"servertest.com","file_type":"csv","stages":{"FileSourceStage":{"stage_name":"FileSourceStage","FileSourceStage":{"fs_configuration":{"FsConf":{"mode":"FsConf"}},"filename":"file1.csv","file_type":"csv"}},"DeserializeStage":{"stage_name":"DeserializeStage","DeserializeStage":{"ds_configuration":{"DeserializeConf":{"mode":"DeserializeConf"}}}},"AbpPcapPreprocessingStage":{"stage_name":"AbpPcapPreprocessingStage","AbpPcapPreprocessingStage":{"apps_configuration":{"AppsConf":{"mode":"AppsConf"}}}},"MonitorStage":{"stage_name":"MonitorStage","MonitorStage":{"ms_configuration":{"MonitoringConf":{"mode":"MonitoringConf"}},"descriptions":"MetricMonitoring","unit":"kbps"}},"TritonInferenceStage":{"stage_name":"TritonInferenceStage","TritonInferenceStage":{"tis_configuration":{"TritonConf":{"mode":"TritonConf"}},"model_name":"Modeltest1","server_url":"servertest.com","force_convert_inputs":false}},"AddClassificationsStage":{"stage_name":"AddClassificationsStage","AddClassificationsStage":{"acs_configuration":{"ClassificationConf":{"mode":"ClassificationConf"}}}},"SerializeStage":{"stage_name":"SerializeStage","SerializeStage":{"ss_configuration":{"SerializeConf":{"mode":"SerializeConf"}}}},"WriteToFileStage":{"stage_name":"WriteToFileStage","WriteToFileStage":{"wfs_configuration":{"WFSConf":{"mode":"WFSConf"}},"wfs_filename":"file2.txt","overwrite":false}},"CustomStage":{"stage_name":"CustomStage","custom":{"name":{"field_name":"name","field_value":"test"}}}}} + }} + ]}, + "device_operational_status": 1, + "device_drivers": ["smartnic"], + "device_endpoints": [] + } + ] +} diff --git a/src/nbi/tests/data/agent_probes_device.json b/src/nbi/tests/data/agent_probes_device.json new file mode 100644 index 000000000..e9d931528 --- /dev/null +++ b/src/nbi/tests/data/agent_probes_device.json @@ -0,0 +1,27 @@ +{ + + "contexts": [ + {"context_id": {"context_uuid": {"uuid": "admin"}}} + ], + "topologies": [ + {"topology_id": {"topology_uuid": {"uuid": "admin"}, "context_id": {"context_uuid": {"uuid": "admin"}}}} + ], + "devices": [ + { + "device_id": {"device_uuid": {"uuid": "smp-01"}}, + "device_type": "smartnic", + "device_config": {"config_rules": [ + {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "172.17.0.3"}}, + {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8000"}}, + {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { + "username": "admin", "password": "admin", "base_url": "/manage-probe", "timeout" : 120 + }}} + ]}, + "device_operational_status": 1, + "device_drivers": [12], + "device_endpoints": [] + } + + ] +} + \ No newline at end of file diff --git a/src/policy/Dockerfile b/src/policy/Dockerfile deleted file mode 120000 index eec732273..000000000 --- a/src/policy/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -src/main/docker/Dockerfile.multistage.jvm \ No newline at end of file diff --git a/src/policy/Dockerfile b/src/policy/Dockerfile new file mode 100644 index 000000000..2c6412d07 --- /dev/null +++ b/src/policy/Dockerfile @@ -0,0 +1,66 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +# Multi-stage Docker image build + +# Stage 1 +FROM maven:3-jdk-11 AS builder + +# Define working directory +WORKDIR /app + +# Copy every file in working directory, as defined in .dockerignore file +COPY ./pom.xml pom.xml +COPY ./src src/ +COPY ./target/generated-sources/ target/generated-sources/ +RUN mvn --errors --batch-mode package -Dmaven.test.skip=true + +# Stage 2 +FROM builder AS unit-test + +RUN mvn --errors --batch-mode -Pgenerate-consolidated-coverage verify + +# Stage 3 +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release + +ARG JAVA_PACKAGE=java-11-openjdk-headless +ARG RUN_JAVA_VERSION=1.3.8 +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +# Install java and the run-java script +# Also set up permissions for user `1001` +RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ + && microdnf update \ + && microdnf clean all \ + && mkdir /deployments \ + && chown 1001 /deployments \ + && chmod "g+rwX" /deployments \ + && chown 1001:root /deployments \ + && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ + && chown 1001 /deployments/run-java.sh \ + && chmod 540 /deployments/run-java.sh \ + && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security + +# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --from=builder --chown=1001 /app/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/*.jar /deployments/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/app/ /deployments/app/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +EXPOSE 6060 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java index 570a7fb9e..018a08bdf 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java @@ -2304,6 +2304,8 @@ public class Serializer { return ContextOuterClass.DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE; case IETF_ACTN: return ContextOuterClass.DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN; + case SMARTNIC: + return ContextOuterClass.DeviceDriverEnum.DEVICEDRIVER_SMARTNIC; case UNDEFINED: default: return ContextOuterClass.DeviceDriverEnum.DEVICEDRIVER_UNDEFINED; @@ -2333,6 +2335,8 @@ public class Serializer { return DeviceDriverEnum.FLEXSCALE; case DEVICEDRIVER_IETF_ACTN: return DeviceDriverEnum.IETF_ACTN; + case DEVICEDRIVER_SMARTNIC: + return DeviceDriverEnum.SMARTNIC; case DEVICEDRIVER_UNDEFINED: case UNRECOGNIZED: default: diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/context/model/DeviceDriverEnum.java b/src/policy/src/main/java/org/etsi/tfs/policy/context/model/DeviceDriverEnum.java index 72a1d7136..937752dc8 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/context/model/DeviceDriverEnum.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/context/model/DeviceDriverEnum.java @@ -27,5 +27,6 @@ public enum DeviceDriverEnum { IETF_L2VPN, GNMI_OPENCONFIG, FLEXSCALE, - IETF_ACTN + IETF_ACTN, + SMARTNIC } diff --git a/src/policy/src/main/proto/acl.proto b/src/policy/src/main/proto/acl.proto deleted file mode 120000 index 158ae78eb..000000000 --- a/src/policy/src/main/proto/acl.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/acl.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/acl.proto b/src/policy/src/main/proto/acl.proto new file mode 100644 index 000000000..3dba735dc --- /dev/null +++ b/src/policy/src/main/proto/acl.proto @@ -0,0 +1,69 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 acl; + +enum AclRuleTypeEnum { + ACLRULETYPE_UNDEFINED = 0; + ACLRULETYPE_IPV4 = 1; + ACLRULETYPE_IPV6 = 2; + ACLRULETYPE_L2 = 3; + ACLRULETYPE_MPLS = 4; + ACLRULETYPE_MIXED = 5; +} + +enum AclForwardActionEnum { + ACLFORWARDINGACTION_UNDEFINED = 0; + ACLFORWARDINGACTION_DROP = 1; + ACLFORWARDINGACTION_ACCEPT = 2; + ACLFORWARDINGACTION_REJECT = 3; +} + +enum AclLogActionEnum { + ACLLOGACTION_UNDEFINED = 0; + ACLLOGACTION_NOLOG = 1; + ACLLOGACTION_SYSLOG = 2; +} + +message AclMatch { + uint32 dscp = 1; + uint32 protocol = 2; + string src_address = 3; + string dst_address = 4; + uint32 src_port = 5; + uint32 dst_port = 6; + uint32 start_mpls_label = 7; + uint32 end_mpls_label = 8; +} + +message AclAction { + AclForwardActionEnum forward_action = 1; + AclLogActionEnum log_action = 2; +} + +message AclEntry { + uint32 sequence_id = 1; + string description = 2; + AclMatch match = 3; + AclAction action = 4; +} + +message AclRuleSet { + string name = 1; + AclRuleTypeEnum type = 2; + string description = 3; + string user_id = 4; + repeated AclEntry entries = 5; +} diff --git a/src/policy/src/main/proto/context.proto b/src/policy/src/main/proto/context.proto deleted file mode 120000 index 7f33c4bc7..000000000 --- a/src/policy/src/main/proto/context.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/context.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/context.proto b/src/policy/src/main/proto/context.proto new file mode 100644 index 000000000..fce1e71ad --- /dev/null +++ b/src/policy/src/main/proto/context.proto @@ -0,0 +1,615 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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; + +import "acl.proto"; +import "kpi_sample_types.proto"; + +service ContextService { + rpc ListContextIds (Empty ) returns ( ContextIdList ) {} + rpc ListContexts (Empty ) returns ( ContextList ) {} + rpc GetContext (ContextId ) returns ( Context ) {} + rpc SetContext (Context ) returns ( ContextId ) {} + rpc RemoveContext (ContextId ) returns ( Empty ) {} + rpc GetContextEvents (Empty ) returns (stream ContextEvent ) {} + + rpc ListTopologyIds (ContextId ) returns ( TopologyIdList ) {} + rpc ListTopologies (ContextId ) returns ( TopologyList ) {} + rpc GetTopology (TopologyId ) returns ( Topology ) {} + rpc GetTopologyDetails (TopologyId ) returns ( TopologyDetails ) {} + rpc SetTopology (Topology ) returns ( TopologyId ) {} + rpc RemoveTopology (TopologyId ) returns ( Empty ) {} + rpc GetTopologyEvents (Empty ) returns (stream TopologyEvent ) {} + + rpc ListDeviceIds (Empty ) returns ( DeviceIdList ) {} + rpc ListDevices (Empty ) returns ( DeviceList ) {} + rpc GetDevice (DeviceId ) returns ( Device ) {} + rpc SetDevice (Device ) returns ( DeviceId ) {} + rpc RemoveDevice (DeviceId ) returns ( Empty ) {} + rpc GetDeviceEvents (Empty ) returns (stream DeviceEvent ) {} + rpc SelectDevice (DeviceFilter ) returns ( DeviceList ) {} + rpc ListEndPointNames (EndPointIdList) returns ( EndPointNameList) {} + + rpc ListLinkIds (Empty ) returns ( LinkIdList ) {} + rpc ListLinks (Empty ) returns ( LinkList ) {} + rpc GetLink (LinkId ) returns ( Link ) {} + rpc SetLink (Link ) returns ( LinkId ) {} + rpc RemoveLink (LinkId ) returns ( Empty ) {} + rpc GetLinkEvents (Empty ) returns (stream LinkEvent ) {} + + rpc ListServiceIds (ContextId ) returns ( ServiceIdList ) {} + rpc ListServices (ContextId ) returns ( ServiceList ) {} + rpc GetService (ServiceId ) returns ( Service ) {} + rpc SetService (Service ) returns ( ServiceId ) {} + rpc UnsetService (Service ) returns ( ServiceId ) {} + rpc RemoveService (ServiceId ) returns ( Empty ) {} + rpc GetServiceEvents (Empty ) returns (stream ServiceEvent ) {} + rpc SelectService (ServiceFilter ) returns ( ServiceList ) {} + + rpc ListSliceIds (ContextId ) returns ( SliceIdList ) {} + rpc ListSlices (ContextId ) returns ( SliceList ) {} + rpc GetSlice (SliceId ) returns ( Slice ) {} + rpc SetSlice (Slice ) returns ( SliceId ) {} + rpc UnsetSlice (Slice ) returns ( SliceId ) {} + rpc RemoveSlice (SliceId ) returns ( Empty ) {} + rpc GetSliceEvents (Empty ) returns (stream SliceEvent ) {} + rpc SelectSlice (SliceFilter ) returns ( SliceList ) {} + + rpc ListConnectionIds (ServiceId ) returns ( ConnectionIdList) {} + rpc ListConnections (ServiceId ) returns ( ConnectionList ) {} + rpc GetConnection (ConnectionId ) returns ( Connection ) {} + rpc SetConnection (Connection ) returns ( ConnectionId ) {} + rpc RemoveConnection (ConnectionId ) returns ( Empty ) {} + rpc GetConnectionEvents(Empty ) returns (stream ConnectionEvent ) {} +} + +// ----- Generic ------------------------------------------------------------------------------------------------------- +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; +} + +// ----- Context ------------------------------------------------------------------------------------------------------- +message ContextId { + Uuid context_uuid = 1; +} + +message Context { + ContextId context_id = 1; + string name = 2; + repeated TopologyId topology_ids = 3; + repeated ServiceId service_ids = 4; + repeated SliceId slice_ids = 5; + TeraFlowController controller = 6; +} + +message ContextIdList { + repeated ContextId context_ids = 1; +} + +message ContextList { + repeated Context contexts = 1; +} + +message ContextEvent { + Event event = 1; + ContextId context_id = 2; +} + + +// ----- Topology ------------------------------------------------------------------------------------------------------ +message TopologyId { + ContextId context_id = 1; + Uuid topology_uuid = 2; +} + +message Topology { + TopologyId topology_id = 1; + string name = 2; + repeated DeviceId device_ids = 3; + repeated LinkId link_ids = 4; +} + +message TopologyDetails { + TopologyId topology_id = 1; + string name = 2; + repeated Device devices = 3; + repeated Link links = 4; +} + +message TopologyIdList { + repeated TopologyId topology_ids = 1; +} + +message TopologyList { + repeated Topology topologies = 1; +} + +message TopologyEvent { + Event event = 1; + TopologyId topology_id = 2; +} + + +// ----- Device -------------------------------------------------------------------------------------------------------- +message DeviceId { + Uuid device_uuid = 1; +} + +message Device { + DeviceId device_id = 1; + string name = 2; + string device_type = 3; + DeviceConfig device_config = 4; + DeviceOperationalStatusEnum device_operational_status = 5; + repeated DeviceDriverEnum device_drivers = 6; + repeated EndPoint device_endpoints = 7; + repeated Component components = 8; // Used for inventory + DeviceId controller_id = 9; // Identifier of node controlling the actual device +} + +message Component { //Defined previously to this section - Tested OK + Uuid component_uuid = 1; + string name = 2; + string type = 3; + + map<string, string> attributes = 4; // dict[attr.name => json.dumps(attr.value)] + string parent = 5; +} + +message DeviceConfig { + repeated ConfigRule config_rules = 1; +} + +enum DeviceDriverEnum { + DEVICEDRIVER_UNDEFINED = 0; // also used for emulated + DEVICEDRIVER_OPENCONFIG = 1; + DEVICEDRIVER_TRANSPORT_API = 2; + DEVICEDRIVER_P4 = 3; + DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4; + DEVICEDRIVER_ONF_TR_532 = 5; + DEVICEDRIVER_XR = 6; + DEVICEDRIVER_IETF_L2VPN = 7; + DEVICEDRIVER_GNMI_OPENCONFIG = 8; + DEVICEDRIVER_FLEXSCALE = 9; + DEVICEDRIVER_IETF_ACTN = 10; + DEVICEDRIVER_SMARTNIC = 11; +} + +enum DeviceOperationalStatusEnum { + DEVICEOPERATIONALSTATUS_UNDEFINED = 0; + DEVICEOPERATIONALSTATUS_DISABLED = 1; + DEVICEOPERATIONALSTATUS_ENABLED = 2; +} + +message DeviceIdList { + repeated DeviceId device_ids = 1; +} + +message DeviceList { + repeated Device devices = 1; +} + +message DeviceFilter { + DeviceIdList device_ids = 1; + bool include_endpoints = 2; + bool include_config_rules = 3; + bool include_components = 4; +} + +message DeviceEvent { + Event event = 1; + DeviceId device_id = 2; + DeviceConfig device_config = 3; +} + + +// ----- Link ---------------------------------------------------------------------------------------------------------- +message LinkId { + Uuid link_uuid = 1; +} + +message LinkAttributes { + float total_capacity_gbps = 1; + float used_capacity_gbps = 2; +} + +message Link { + LinkId link_id = 1; + string name = 2; + repeated EndPointId link_endpoint_ids = 3; + LinkAttributes attributes = 4; +} + +message LinkIdList { + repeated LinkId link_ids = 1; +} + +message LinkList { + repeated Link links = 1; +} + +message LinkEvent { + Event event = 1; + LinkId link_id = 2; +} + + +// ----- Service ------------------------------------------------------------------------------------------------------- +message ServiceId { + ContextId context_id = 1; + Uuid service_uuid = 2; +} + +message Service { + ServiceId service_id = 1; + string name = 2; + ServiceTypeEnum service_type = 3; + repeated EndPointId service_endpoint_ids = 4; + repeated Constraint service_constraints = 5; + ServiceStatus service_status = 6; + ServiceConfig service_config = 7; + Timestamp timestamp = 8; +} + +enum ServiceTypeEnum { + SERVICETYPE_UNKNOWN = 0; + SERVICETYPE_L3NM = 1; + SERVICETYPE_L2NM = 2; + SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; + SERVICETYPE_TE = 4; + SERVICETYPE_E2E = 5; +} + +enum ServiceStatusEnum { + SERVICESTATUS_UNDEFINED = 0; + SERVICESTATUS_PLANNED = 1; + SERVICESTATUS_ACTIVE = 2; + SERVICESTATUS_UPDATING = 3; + SERVICESTATUS_PENDING_REMOVAL = 4; + SERVICESTATUS_SLA_VIOLATED = 5; +} + +message ServiceStatus { + ServiceStatusEnum service_status = 1; +} + +message ServiceConfig { + repeated ConfigRule config_rules = 1; +} + +message ServiceIdList { + repeated ServiceId service_ids = 1; +} + +message ServiceList { + repeated Service services = 1; +} + +message ServiceFilter { + ServiceIdList service_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_config_rules = 4; +} + +message ServiceEvent { + Event event = 1; + ServiceId service_id = 2; +} + +// ----- Slice --------------------------------------------------------------------------------------------------------- +message SliceId { + ContextId context_id = 1; + Uuid slice_uuid = 2; +} + +message Slice { + SliceId slice_id = 1; + string name = 2; + repeated EndPointId slice_endpoint_ids = 3; + repeated Constraint slice_constraints = 4; + repeated ServiceId slice_service_ids = 5; + repeated SliceId slice_subslice_ids = 6; + SliceStatus slice_status = 7; + SliceConfig slice_config = 8; + SliceOwner slice_owner = 9; + Timestamp timestamp = 10; +} + +message SliceOwner { + Uuid owner_uuid = 1; + string owner_string = 2; +} + +enum SliceStatusEnum { + SLICESTATUS_UNDEFINED = 0; + SLICESTATUS_PLANNED = 1; + SLICESTATUS_INIT = 2; + SLICESTATUS_ACTIVE = 3; + SLICESTATUS_DEINIT = 4; + SLICESTATUS_SLA_VIOLATED = 5; +} + +message SliceStatus { + SliceStatusEnum slice_status = 1; +} + +message SliceConfig { + repeated ConfigRule config_rules = 1; +} + +message SliceIdList { + repeated SliceId slice_ids = 1; +} + +message SliceList { + repeated Slice slices = 1; +} + +message SliceFilter { + SliceIdList slice_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_service_ids = 4; + bool include_subslice_ids = 5; + bool include_config_rules = 6; +} + +message SliceEvent { + Event event = 1; + SliceId slice_id = 2; +} + +// ----- Connection ---------------------------------------------------------------------------------------------------- +message ConnectionId { + Uuid connection_uuid = 1; +} + +message ConnectionSettings_L0 { + string lsp_symbolic_name = 1; +} + +message ConnectionSettings_L2 { + string src_mac_address = 1; + string dst_mac_address = 2; + uint32 ether_type = 3; + uint32 vlan_id = 4; + uint32 mpls_label = 5; + uint32 mpls_traffic_class = 6; +} + +message ConnectionSettings_L3 { + string src_ip_address = 1; + string dst_ip_address = 2; + uint32 dscp = 3; + uint32 protocol = 4; + uint32 ttl = 5; +} + +message ConnectionSettings_L4 { + uint32 src_port = 1; + uint32 dst_port = 2; + uint32 tcp_flags = 3; + uint32 ttl = 4; +} + +message ConnectionSettings { + ConnectionSettings_L0 l0 = 1; + ConnectionSettings_L2 l2 = 2; + ConnectionSettings_L3 l3 = 3; + ConnectionSettings_L4 l4 = 4; +} + +message Connection { + ConnectionId connection_id = 1; + ServiceId service_id = 2; + repeated EndPointId path_hops_endpoint_ids = 3; + repeated ServiceId sub_service_ids = 4; + ConnectionSettings settings = 5; +} + +message ConnectionIdList { + repeated ConnectionId connection_ids = 1; +} + +message ConnectionList { + repeated Connection connections = 1; +} + +message ConnectionEvent { + Event event = 1; + ConnectionId connection_id = 2; +} + + +// ----- Endpoint ------------------------------------------------------------------------------------------------------ +message EndPointId { + TopologyId topology_id = 1; + DeviceId device_id = 2; + Uuid endpoint_uuid = 3; +} + +message EndPoint { + EndPointId endpoint_id = 1; + string name = 2; + string endpoint_type = 3; + repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; + Location endpoint_location = 5; +} + +message EndPointName { + EndPointId endpoint_id = 1; + string device_name = 2; + string endpoint_name = 3; + string endpoint_type = 4; +} + +message EndPointIdList { + repeated EndPointId endpoint_ids = 1; +} + +message EndPointNameList { + repeated EndPointName endpoint_names = 1; +} + + +// ----- Configuration ------------------------------------------------------------------------------------------------- +enum ConfigActionEnum { + CONFIGACTION_UNDEFINED = 0; + CONFIGACTION_SET = 1; + CONFIGACTION_DELETE = 2; +} + +message ConfigRule_Custom { + string resource_key = 1; + string resource_value = 2; +} + +message ConfigRule_ACL { + EndPointId endpoint_id = 1; + acl.AclRuleSet rule_set = 2; +} + +message ConfigRule { + ConfigActionEnum action = 1; + oneof config_rule { + ConfigRule_Custom custom = 2; + ConfigRule_ACL acl = 3; + } +} + + +// ----- Constraint ---------------------------------------------------------------------------------------------------- +enum ConstraintActionEnum { + CONSTRAINTACTION_UNDEFINED = 0; + CONSTRAINTACTION_SET = 1; + CONSTRAINTACTION_DELETE = 2; +} + +message Constraint_Custom { + string constraint_type = 1; + string constraint_value = 2; +} + +message Constraint_Schedule { + float start_timestamp = 1; + float duration_days = 2; +} + +message GPS_Position { + float latitude = 1; + float longitude = 2; +} + +message Location { + oneof location { + string region = 1; + GPS_Position gps_position = 2; + } +} + +message Constraint_EndPointLocation { + EndPointId endpoint_id = 1; + Location location = 2; +} + +message Constraint_EndPointPriority { + EndPointId endpoint_id = 1; + uint32 priority = 2; +} + +message Constraint_SLA_Latency { + float e2e_latency_ms = 1; +} + +message Constraint_SLA_Capacity { + float capacity_gbps = 1; +} + +message Constraint_SLA_Availability { + uint32 num_disjoint_paths = 1; + bool all_active = 2; + float availability = 3; // 0.0 .. 100.0 percentage of availability +} + +enum IsolationLevelEnum { + NO_ISOLATION = 0; + PHYSICAL_ISOLATION = 1; + LOGICAL_ISOLATION = 2; + PROCESS_ISOLATION = 3; + PHYSICAL_MEMORY_ISOLATION = 4; + PHYSICAL_NETWORK_ISOLATION = 5; + VIRTUAL_RESOURCE_ISOLATION = 6; + NETWORK_FUNCTIONS_ISOLATION = 7; + SERVICE_ISOLATION = 8; +} + +message Constraint_SLA_Isolation_level { + repeated IsolationLevelEnum isolation_level = 1; +} + +message Constraint_Exclusions { + bool is_permanent = 1; + repeated DeviceId device_ids = 2; + repeated EndPointId endpoint_ids = 3; + repeated LinkId link_ids = 4; +} + +message Constraint { + ConstraintActionEnum action = 1; + oneof constraint { + Constraint_Custom custom = 2; + Constraint_Schedule schedule = 3; + Constraint_EndPointLocation endpoint_location = 4; + Constraint_EndPointPriority endpoint_priority = 5; + Constraint_SLA_Capacity sla_capacity = 6; + Constraint_SLA_Latency sla_latency = 7; + Constraint_SLA_Availability sla_availability = 8; + Constraint_SLA_Isolation_level sla_isolation = 9; + Constraint_Exclusions exclusions = 10; + } +} + + +// ----- Miscellaneous ------------------------------------------------------------------------------------------------- +message TeraFlowController { + ContextId context_id = 1; + string ip_address = 2; + uint32 port = 3; +} + +message AuthenticationResult { + ContextId context_id = 1; + bool authenticated = 2; +} diff --git a/src/policy/src/main/proto/context_policy.proto b/src/policy/src/main/proto/context_policy.proto deleted file mode 120000 index d41593dde..000000000 --- a/src/policy/src/main/proto/context_policy.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/context_policy.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/context_policy.proto b/src/policy/src/main/proto/context_policy.proto new file mode 100644 index 000000000..f6dae4830 --- /dev/null +++ b/src/policy/src/main/proto/context_policy.proto @@ -0,0 +1,28 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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_policy; + +import "context.proto"; +import "policy.proto"; + +// created as a separate service to prevent import-loops in context and policy +service ContextPolicyService { + rpc ListPolicyRuleIds(context.Empty ) returns (policy.PolicyRuleIdList) {} + rpc ListPolicyRules (context.Empty ) returns (policy.PolicyRuleList ) {} + rpc GetPolicyRule (policy.PolicyRuleId ) returns (policy.PolicyRule ) {} + rpc SetPolicyRule (policy.PolicyRule ) returns (policy.PolicyRuleId ) {} + rpc RemovePolicyRule (policy.PolicyRuleId ) returns (context.Empty ) {} +} diff --git a/src/policy/src/main/proto/device.proto b/src/policy/src/main/proto/device.proto deleted file mode 120000 index ad6e7c47e..000000000 --- a/src/policy/src/main/proto/device.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/device.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/device.proto b/src/policy/src/main/proto/device.proto new file mode 100644 index 000000000..30e60079d --- /dev/null +++ b/src/policy/src/main/proto/device.proto @@ -0,0 +1,34 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 device; + +import "context.proto"; +import "monitoring.proto"; + +service DeviceService { + rpc AddDevice (context.Device ) returns (context.DeviceId ) {} + rpc ConfigureDevice (context.Device ) returns (context.DeviceId ) {} + rpc DeleteDevice (context.DeviceId ) returns (context.Empty ) {} + rpc GetInitialConfig(context.DeviceId ) returns (context.DeviceConfig) {} + rpc MonitorDeviceKpi(MonitoringSettings) returns (context.Empty ) {} +} + +message MonitoringSettings { + monitoring.KpiId kpi_id = 1; + monitoring.KpiDescriptor kpi_descriptor = 2; + float sampling_duration_s = 3; + float sampling_interval_s = 4; +} diff --git a/src/policy/src/main/proto/kpi_sample_types.proto b/src/policy/src/main/proto/kpi_sample_types.proto deleted file mode 120000 index 98e748bbf..000000000 --- a/src/policy/src/main/proto/kpi_sample_types.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/kpi_sample_types.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/kpi_sample_types.proto b/src/policy/src/main/proto/kpi_sample_types.proto new file mode 100644 index 000000000..5b234a4e3 --- /dev/null +++ b/src/policy/src/main/proto/kpi_sample_types.proto @@ -0,0 +1,42 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 kpi_sample_types; + +enum KpiSampleType { + KPISAMPLETYPE_UNKNOWN = 0; + + KPISAMPLETYPE_PACKETS_TRANSMITTED = 101; + KPISAMPLETYPE_PACKETS_RECEIVED = 102; + KPISAMPLETYPE_PACKETS_DROPPED = 103; + KPISAMPLETYPE_BYTES_TRANSMITTED = 201; + KPISAMPLETYPE_BYTES_RECEIVED = 202; + KPISAMPLETYPE_BYTES_DROPPED = 203; + + KPISAMPLETYPE_LINK_TOTAL_CAPACITY_GBPS = 301; + KPISAMPLETYPE_LINK_USED_CAPACITY_GBPS = 302; + + KPISAMPLETYPE_ML_CONFIDENCE = 401; //. can be used by both optical and L3 without any issue + + KPISAMPLETYPE_OPTICAL_SECURITY_STATUS = 501; //. can be used by both optical and L3 without any issue + + KPISAMPLETYPE_L3_UNIQUE_ATTACK_CONNS = 601; + KPISAMPLETYPE_L3_TOTAL_DROPPED_PACKTS = 602; + KPISAMPLETYPE_L3_UNIQUE_ATTACKERS = 603; + KPISAMPLETYPE_L3_UNIQUE_COMPROMISED_CLIENTS = 604; + KPISAMPLETYPE_L3_SECURITY_STATUS_CRYPTO = 605; + + KPISAMPLETYPE_SERVICE_LATENCY_MS = 701; +} diff --git a/src/policy/src/main/proto/monitoring.proto b/src/policy/src/main/proto/monitoring.proto deleted file mode 120000 index aceaa7328..000000000 --- a/src/policy/src/main/proto/monitoring.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/monitoring.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/monitoring.proto b/src/policy/src/main/proto/monitoring.proto new file mode 100644 index 000000000..45ba48b02 --- /dev/null +++ b/src/policy/src/main/proto/monitoring.proto @@ -0,0 +1,174 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 monitoring; + +import "context.proto"; +import "kpi_sample_types.proto"; + +service MonitoringService { + rpc SetKpi (KpiDescriptor ) returns (KpiId ) {} // Stable not final + rpc DeleteKpi (KpiId ) returns (context.Empty ) {} // Stable and final + rpc GetKpiDescriptor (KpiId ) returns (KpiDescriptor ) {} // Stable and final + rpc GetKpiDescriptorList (context.Empty ) returns (KpiDescriptorList ) {} // Stable and final + rpc IncludeKpi (Kpi ) returns (context.Empty ) {} // Stable and final + rpc MonitorKpi (MonitorKpiRequest ) returns (context.Empty ) {} // Stable and final + rpc QueryKpiData (KpiQuery ) returns (RawKpiTable ) {} // Not implemented + rpc SetKpiSubscription (SubsDescriptor ) returns (stream SubsResponse ) {} // Stable not final + rpc GetSubsDescriptor (SubscriptionID ) returns (SubsDescriptor ) {} // Stable and final + rpc GetSubscriptions (context.Empty ) returns (SubsList ) {} // Stable and final + rpc DeleteSubscription (SubscriptionID ) returns (context.Empty ) {} // Stable and final + rpc SetKpiAlarm (AlarmDescriptor ) returns (AlarmID ) {} // Stable not final + rpc GetAlarms (context.Empty ) returns (AlarmList ) {} // Stable and final + rpc GetAlarmDescriptor (AlarmID ) returns (AlarmDescriptor ) {} // Stable and final + rpc GetAlarmResponseStream(AlarmSubscription ) returns (stream AlarmResponse) {} // Not Stable not final + rpc DeleteAlarm (AlarmID ) returns (context.Empty ) {} // Stable and final + rpc GetStreamKpi (KpiId ) returns (stream Kpi ) {} // Stable not final + rpc GetInstantKpi (KpiId ) returns (Kpi ) {} // Stable not final +} + +message KpiDescriptor { + KpiId kpi_id = 1; + string kpi_description = 2; + repeated KpiId kpi_id_list = 3; + kpi_sample_types.KpiSampleType kpi_sample_type = 4; + context.DeviceId device_id = 5; + context.EndPointId endpoint_id = 6; + context.ServiceId service_id = 7; + context.SliceId slice_id = 8; + context.ConnectionId connection_id = 9; + context.LinkId link_id = 10; +} + +message MonitorKpiRequest { + KpiId kpi_id = 1; + float monitoring_window_s = 2; + float sampling_rate_s = 3; + // Pending add field to reflect Available Device Protocols +} + +message KpiQuery { + repeated KpiId kpi_ids = 1; + float monitoring_window_s = 2; + uint32 last_n_samples = 3; // used when you want something like "get the last N many samples + context.Timestamp start_timestamp = 4; // used when you want something like "get the samples since X date/time" + context.Timestamp end_timestamp = 5; // used when you want something like "get the samples until X date/time" +} + + +message RawKpi { // cell + context.Timestamp timestamp = 1; + KpiValue kpi_value = 2; +} + +message RawKpiList { // column + KpiId kpi_id = 1; + repeated RawKpi raw_kpis = 2; +} + +message RawKpiTable { // table + repeated RawKpiList raw_kpi_lists = 1; +} + +message KpiId { + context.Uuid kpi_id = 1; +} + +message Kpi { + KpiId kpi_id = 1; + context.Timestamp timestamp = 2; + KpiValue kpi_value = 3; +} + +message KpiValueRange { + KpiValue kpiMinValue = 1; + KpiValue kpiMaxValue = 2; + bool inRange = 3; // by default True + bool includeMinValue = 4; // False is outside the interval + bool includeMaxValue = 5; // False is outside the interval +} + +message KpiValue { + oneof value { + int32 int32Val = 1; + uint32 uint32Val = 2; + int64 int64Val = 3; + uint64 uint64Val = 4; + float floatVal = 5; + string stringVal = 6; + bool boolVal = 7; + } +} + + +message KpiList { + repeated Kpi kpi = 1; +} + +message KpiDescriptorList { + repeated KpiDescriptor kpi_descriptor_list = 1; +} + +message SubsDescriptor{ + SubscriptionID subs_id = 1; + KpiId kpi_id = 2; + float sampling_duration_s = 3; + float sampling_interval_s = 4; + context.Timestamp start_timestamp = 5; // used when you want something like "get the samples since X date/time" + context.Timestamp end_timestamp = 6; // used when you want something like "get the samples until X date/time" + // Pending add field to reflect Available Device Protocols +} + +message SubscriptionID { + context.Uuid subs_id = 1; +} + +message SubsResponse { + SubscriptionID subs_id = 1; + KpiList kpi_list = 2; +} + +message SubsList { + repeated SubsDescriptor subs_descriptor = 1; +} + +message AlarmDescriptor { + AlarmID alarm_id = 1; + string alarm_description = 2; + string name = 3; + KpiId kpi_id = 4; + KpiValueRange kpi_value_range = 5; + context.Timestamp timestamp = 6; +} + +message AlarmID{ + context.Uuid alarm_id = 1; +} + +message AlarmSubscription{ + AlarmID alarm_id = 1; + float subscription_timeout_s = 2; + float subscription_frequency_ms = 3; +} + +message AlarmResponse { + AlarmID alarm_id = 1; + string text = 2; + KpiList kpi_list = 3; +} + +message AlarmList { + repeated AlarmDescriptor alarm_descriptor = 1; +} diff --git a/src/policy/src/main/proto/policy.proto b/src/policy/src/main/proto/policy.proto deleted file mode 120000 index df455f961..000000000 --- a/src/policy/src/main/proto/policy.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/policy.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy.proto b/src/policy/src/main/proto/policy.proto new file mode 100644 index 000000000..a6f160150 --- /dev/null +++ b/src/policy/src/main/proto/policy.proto @@ -0,0 +1,113 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; + +import "context.proto"; +import "policy_condition.proto"; +import "policy_action.proto"; + +service PolicyService { + rpc PolicyAddService (PolicyRuleService) returns (PolicyRuleState) {} + rpc PolicyAddDevice (PolicyRuleDevice) returns (PolicyRuleState) {} + rpc PolicyUpdateService (PolicyRuleService) returns (PolicyRuleState) {} + rpc PolicyUpdateDevice (PolicyRuleDevice) returns (PolicyRuleState) {} + rpc PolicyDelete (PolicyRuleId) returns (PolicyRuleState) {} + rpc GetPolicyService (PolicyRuleId) returns (PolicyRuleService) {} + rpc GetPolicyDevice (PolicyRuleId) returns (PolicyRuleDevice) {} + rpc GetPolicyByServiceId (context.ServiceId) returns (PolicyRuleServiceList) {} +} + +enum PolicyRuleStateEnum { + POLICY_UNDEFINED = 0; // Undefined rule state + POLICY_FAILED = 1; // Rule failed + POLICY_INSERTED = 2; // Rule is just inserted + POLICY_VALIDATED = 3; // Rule content is correct + POLICY_PROVISIONED = 4; // Rule subscribed to Monitoring + POLICY_ACTIVE = 5; // Rule is currently active (alarm is just thrown by Monitoring) + POLICY_ENFORCED = 6; // Rule action is successfully enforced + POLICY_INEFFECTIVE = 7; // The applied rule action did not work as expected + POLICY_EFFECTIVE = 8; // The applied rule action did work as expected + POLICY_UPDATED = 9; // Operator requires a policy to change + POLICY_REMOVED = 10; // Operator requires to remove a policy +} + +message PolicyRuleId { + context.Uuid uuid = 1; +} + +message PolicyRuleState { + PolicyRuleStateEnum policyRuleState = 1; + string policyRuleStateMessage = 2; +} + +// Basic policy rule attributes +message PolicyRuleBasic { + PolicyRuleId policyRuleId = 1; + PolicyRuleState policyRuleState = 2; //policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. + uint32 priority = 3; + + // Event-Condition-Action (ECA) model + repeated PolicyRuleCondition conditionList = 4; // When these policy conditions are met, an event is automatically thrown + BooleanOperator booleanOperator = 5; // Evaluation operator to be used + repeated PolicyRuleAction actionList = 6; // One or more actions should be applied +} + +// Service-oriented policy rule +message PolicyRuleService { + // Basic policy rule attributes + PolicyRuleBasic policyRuleBasic = 1; + + // Affected service and (some of) its device(s) + context.ServiceId serviceId = 2; + repeated context.DeviceId deviceList = 3; // List of devices this service is traversing (not exhaustive) +} + +// Device-oriented policy rule +message PolicyRuleDevice { + // Basic policy rule attributes + PolicyRuleBasic policyRuleBasic = 1; + + // Affected device(s) + repeated context.DeviceId deviceList = 2; +} + +// Wrapper policy rule object +message PolicyRule { + oneof policy_rule { + PolicyRuleService service = 1; + PolicyRuleDevice device = 2; + } +} + +// A list of policy rule IDs +message PolicyRuleIdList { + repeated PolicyRuleId policyRuleIdList = 1; +} + +// A list of service-oriented policy rules +message PolicyRuleServiceList { + repeated PolicyRuleService policyRuleServiceList = 1; +} + +// A list of device-oriented policy rules +message PolicyRuleDeviceList { + repeated PolicyRuleDevice policyRuleDeviceList = 1; +} + +// A list of policy rules +message PolicyRuleList { + repeated PolicyRule policyRules = 1; +} diff --git a/src/policy/src/main/proto/policy_action.proto b/src/policy/src/main/proto/policy_action.proto deleted file mode 120000 index 63dcef3d2..000000000 --- a/src/policy/src/main/proto/policy_action.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/policy_action.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy_action.proto b/src/policy/src/main/proto/policy_action.proto new file mode 100644 index 000000000..d547e9779 --- /dev/null +++ b/src/policy/src/main/proto/policy_action.proto @@ -0,0 +1,42 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; + +// Action +message PolicyRuleAction { + PolicyRuleActionEnum action = 1; + repeated PolicyRuleActionConfig action_config = 2; +} + +enum PolicyRuleActionEnum { + POLICYRULE_ACTION_NO_ACTION = 0; + POLICYRULE_ACTION_SET_DEVICE_STATUS = 1; + POLICYRULE_ACTION_ADD_SERVICE_CONFIGRULE = 2; + POLICYRULE_ACTION_ADD_SERVICE_CONSTRAINT = 3; + POLICY_RULE_ACTION_CALL_SERVICE_RPC = 4; + POLICY_RULE_ACTION_RECALCULATE_PATH = 5; +} + +// Action configuration +message PolicyRuleActionConfig { + string action_key = 1; + string action_value = 2; +} + +// message PolicyRuleAction { +// PolicyRuleActionEnum action = 1; +// repeated string parameters = 2; +// } diff --git a/src/policy/src/main/proto/policy_condition.proto b/src/policy/src/main/proto/policy_condition.proto deleted file mode 120000 index 31f7d9d10..000000000 --- a/src/policy/src/main/proto/policy_condition.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/policy_condition.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy_condition.proto b/src/policy/src/main/proto/policy_condition.proto new file mode 100644 index 000000000..2037af93c --- /dev/null +++ b/src/policy/src/main/proto/policy_condition.proto @@ -0,0 +1,43 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; + +import "monitoring.proto"; + +// Condition +message PolicyRuleCondition { + monitoring.KpiId kpiId = 1; + NumericalOperator numericalOperator = 2; + monitoring.KpiValue kpiValue = 3; +} + +// Operator to be used when comparing Kpis with condition values +enum NumericalOperator { + POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0; // Kpi numerical operator undefined + POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1; // Kpi is equal with value + POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2; // Kpi is not equal with value + POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3; // Kpi is less than value + POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4; // Kpi is less than or equal with value + POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5; // Kpi is greater than value + POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; // Kpi is less than or equal with value +} + +// Operator to be used when evaluating each condition +enum BooleanOperator { + POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0; // Boolean operator undefined + POLICYRULE_CONDITION_BOOLEAN_AND = 1; // Boolean AND operator + POLICYRULE_CONDITION_BOOLEAN_OR = 2; // Boolean OR operator +} \ No newline at end of file diff --git a/src/policy/src/main/proto/service.proto b/src/policy/src/main/proto/service.proto deleted file mode 120000 index 5ca543da0..000000000 --- a/src/policy/src/main/proto/service.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/service.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/service.proto b/src/policy/src/main/proto/service.proto new file mode 100644 index 000000000..658859e3c --- /dev/null +++ b/src/policy/src/main/proto/service.proto @@ -0,0 +1,25 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 service; + +import "context.proto"; + +service ServiceService { + rpc CreateService (context.Service ) returns (context.ServiceId) {} + rpc UpdateService (context.Service ) returns (context.ServiceId) {} + rpc DeleteService (context.ServiceId) returns (context.Empty ) {} + rpc RecomputeConnections(context.Service ) returns (context.Empty ) {} +} diff --git a/src/service/service/service_handler_api/FilterFields.py b/src/service/service/service_handler_api/FilterFields.py index e771e24f1..e985fe292 100644 --- a/src/service/service/service_handler_api/FilterFields.py +++ b/src/service/service/service_handler_api/FilterFields.py @@ -40,6 +40,7 @@ DEVICE_DRIVER_VALUES = { DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG, DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE, DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN, + DeviceDriverEnum.DEVICEDRIVER_SMARTNIC } # Map allowed filter fields to allowed values per Filter field. If no restriction (free text) None is specified diff --git a/src/service/service/service_handlers/__init__.py b/src/service/service/service_handlers/__init__.py index eaf8f715a..61376c0d2 100644 --- a/src/service/service/service_handlers/__init__.py +++ b/src/service/service/service_handlers/__init__.py @@ -94,6 +94,12 @@ SERVICE_HANDLERS = [ FilterFieldEnum.DEVICE_DRIVER : [DeviceDriverEnum.DEVICEDRIVER_IETF_L2VPN], } ]), + # (SMARTNIC_ServiceHandler, [ + # { + # FilterFieldEnum.SERVICE_TYPE : ServiceTypeEnum.SERVICETYPE_L2NM, + # FilterFieldEnum.DEVICE_DRIVER : [DeviceDriverEnum.DEVICEDRIVER_SMARTNIC], + # } + # ]), (E2EOrchestratorServiceHandler, [ { FilterFieldEnum.SERVICE_TYPE : ServiceTypeEnum.SERVICETYPE_E2E, diff --git a/src/webui/service/device/forms.py b/src/webui/service/device/forms.py index 4c04bbfe1..af5ac4564 100644 --- a/src/webui/service/device/forms.py +++ b/src/webui/service/device/forms.py @@ -33,6 +33,7 @@ class AddDeviceForm(FlaskForm): device_drivers_gnmi_openconfig = BooleanField('GNMI OPENCONFIG') device_drivers_flexscale = BooleanField('FLEXSCALE') device_drivers_ietf_actn = BooleanField('IETF ACTN') + device_drivers_smartnic = BooleanField('SMARTNIC') device_config_address = StringField('connect/address',default='127.0.0.1',validators=[DataRequired(), Length(min=5)]) device_config_port = StringField('connect/port',default='0',validators=[DataRequired(), Length(min=1)]) diff --git a/src/webui/service/device/routes.py b/src/webui/service/device/routes.py index 8b8bc236a..8aaaafccf 100644 --- a/src/webui/service/device/routes.py +++ b/src/webui/service/device/routes.py @@ -127,6 +127,8 @@ def add(): device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_GNMI_OPENCONFIG) if form.device_drivers_flexscale.data: device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_FLEXSCALE) + if form.device_drivers_smartnic.data: + device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_SMARTNIC) if form.device_drivers_ietf_actn.data: device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN) device_obj.device_drivers.extend(device_drivers) # pylint: disable=no-member diff --git a/src/webui/service/templates/device/add.html b/src/webui/service/templates/device/add.html index c4d7f1685..484bc30bf 100644 --- a/src/webui/service/templates/device/add.html +++ b/src/webui/service/templates/device/add.html @@ -95,6 +95,7 @@ <br /> {{ form.device_drivers_flexscale }} {{ form.device_drivers_flexscale.label(class="col-sm-3 col-form-label") }} {{ form.device_drivers_ietf_actn }} {{ form.device_drivers_ietf_actn.label(class="col-sm-3 col-form-label") }} + {{ form.device_drivers_smartnic }} {{ form.device_drivers_smartnic_actn.label(class="col-sm-3 col-form-label") }} {% endif %} </div> </div> diff --git a/src/ztp/Dockerfile b/src/ztp/Dockerfile deleted file mode 120000 index eec732273..000000000 --- a/src/ztp/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -src/main/docker/Dockerfile.multistage.jvm \ No newline at end of file diff --git a/src/ztp/Dockerfile b/src/ztp/Dockerfile new file mode 100644 index 000000000..43fef96b4 --- /dev/null +++ b/src/ztp/Dockerfile @@ -0,0 +1,67 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + +# Multi-stage Docker image build + +# Stage 1 +FROM maven:3-jdk-11 AS builder + +# Define working directory +WORKDIR /app + +# Copy every file in working directory, as defined in .dockerignore file +COPY ./pom.xml pom.xml +COPY ./src src/ +COPY ./target/generated-sources/ target/generated-sources/ +RUN mvn --errors --batch-mode package -Dmaven.test.skip=true + +# Stage 2 +FROM builder AS unit-test + +RUN mvn --errors --batch-mode -Pgenerate-consolidated-coverage verify + +# Stage 3 +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release + +ARG JAVA_PACKAGE=java-11-openjdk-headless +ARG RUN_JAVA_VERSION=1.3.8 +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +# Install java and the run-java script +# Also set up permissions for user `1001` +RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ + && microdnf update \ + && microdnf clean all \ + && mkdir /deployments \ + && chown 1001 /deployments \ + && chmod "g+rwX" /deployments \ + && chown 1001:root /deployments \ + && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ + && chown 1001 /deployments/run-java.sh \ + && chmod 540 /deployments/run-java.sh \ + && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security + +# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --from=builder --chown=1001 /app/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/*.jar /deployments/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/app/ /deployments/app/ +COPY --from=builder --chown=1001 /app/target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +EXPOSE 5050 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] + diff --git a/src/ztp/src/main/proto/acl.proto b/src/ztp/src/main/proto/acl.proto deleted file mode 120000 index 158ae78eb..000000000 --- a/src/ztp/src/main/proto/acl.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/acl.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/acl.proto b/src/ztp/src/main/proto/acl.proto new file mode 100644 index 000000000..3dba735dc --- /dev/null +++ b/src/ztp/src/main/proto/acl.proto @@ -0,0 +1,69 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 acl; + +enum AclRuleTypeEnum { + ACLRULETYPE_UNDEFINED = 0; + ACLRULETYPE_IPV4 = 1; + ACLRULETYPE_IPV6 = 2; + ACLRULETYPE_L2 = 3; + ACLRULETYPE_MPLS = 4; + ACLRULETYPE_MIXED = 5; +} + +enum AclForwardActionEnum { + ACLFORWARDINGACTION_UNDEFINED = 0; + ACLFORWARDINGACTION_DROP = 1; + ACLFORWARDINGACTION_ACCEPT = 2; + ACLFORWARDINGACTION_REJECT = 3; +} + +enum AclLogActionEnum { + ACLLOGACTION_UNDEFINED = 0; + ACLLOGACTION_NOLOG = 1; + ACLLOGACTION_SYSLOG = 2; +} + +message AclMatch { + uint32 dscp = 1; + uint32 protocol = 2; + string src_address = 3; + string dst_address = 4; + uint32 src_port = 5; + uint32 dst_port = 6; + uint32 start_mpls_label = 7; + uint32 end_mpls_label = 8; +} + +message AclAction { + AclForwardActionEnum forward_action = 1; + AclLogActionEnum log_action = 2; +} + +message AclEntry { + uint32 sequence_id = 1; + string description = 2; + AclMatch match = 3; + AclAction action = 4; +} + +message AclRuleSet { + string name = 1; + AclRuleTypeEnum type = 2; + string description = 3; + string user_id = 4; + repeated AclEntry entries = 5; +} diff --git a/src/ztp/src/main/proto/context.proto b/src/ztp/src/main/proto/context.proto deleted file mode 120000 index 7f33c4bc7..000000000 --- a/src/ztp/src/main/proto/context.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/context.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/context.proto b/src/ztp/src/main/proto/context.proto new file mode 100644 index 000000000..fce1e71ad --- /dev/null +++ b/src/ztp/src/main/proto/context.proto @@ -0,0 +1,615 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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; + +import "acl.proto"; +import "kpi_sample_types.proto"; + +service ContextService { + rpc ListContextIds (Empty ) returns ( ContextIdList ) {} + rpc ListContexts (Empty ) returns ( ContextList ) {} + rpc GetContext (ContextId ) returns ( Context ) {} + rpc SetContext (Context ) returns ( ContextId ) {} + rpc RemoveContext (ContextId ) returns ( Empty ) {} + rpc GetContextEvents (Empty ) returns (stream ContextEvent ) {} + + rpc ListTopologyIds (ContextId ) returns ( TopologyIdList ) {} + rpc ListTopologies (ContextId ) returns ( TopologyList ) {} + rpc GetTopology (TopologyId ) returns ( Topology ) {} + rpc GetTopologyDetails (TopologyId ) returns ( TopologyDetails ) {} + rpc SetTopology (Topology ) returns ( TopologyId ) {} + rpc RemoveTopology (TopologyId ) returns ( Empty ) {} + rpc GetTopologyEvents (Empty ) returns (stream TopologyEvent ) {} + + rpc ListDeviceIds (Empty ) returns ( DeviceIdList ) {} + rpc ListDevices (Empty ) returns ( DeviceList ) {} + rpc GetDevice (DeviceId ) returns ( Device ) {} + rpc SetDevice (Device ) returns ( DeviceId ) {} + rpc RemoveDevice (DeviceId ) returns ( Empty ) {} + rpc GetDeviceEvents (Empty ) returns (stream DeviceEvent ) {} + rpc SelectDevice (DeviceFilter ) returns ( DeviceList ) {} + rpc ListEndPointNames (EndPointIdList) returns ( EndPointNameList) {} + + rpc ListLinkIds (Empty ) returns ( LinkIdList ) {} + rpc ListLinks (Empty ) returns ( LinkList ) {} + rpc GetLink (LinkId ) returns ( Link ) {} + rpc SetLink (Link ) returns ( LinkId ) {} + rpc RemoveLink (LinkId ) returns ( Empty ) {} + rpc GetLinkEvents (Empty ) returns (stream LinkEvent ) {} + + rpc ListServiceIds (ContextId ) returns ( ServiceIdList ) {} + rpc ListServices (ContextId ) returns ( ServiceList ) {} + rpc GetService (ServiceId ) returns ( Service ) {} + rpc SetService (Service ) returns ( ServiceId ) {} + rpc UnsetService (Service ) returns ( ServiceId ) {} + rpc RemoveService (ServiceId ) returns ( Empty ) {} + rpc GetServiceEvents (Empty ) returns (stream ServiceEvent ) {} + rpc SelectService (ServiceFilter ) returns ( ServiceList ) {} + + rpc ListSliceIds (ContextId ) returns ( SliceIdList ) {} + rpc ListSlices (ContextId ) returns ( SliceList ) {} + rpc GetSlice (SliceId ) returns ( Slice ) {} + rpc SetSlice (Slice ) returns ( SliceId ) {} + rpc UnsetSlice (Slice ) returns ( SliceId ) {} + rpc RemoveSlice (SliceId ) returns ( Empty ) {} + rpc GetSliceEvents (Empty ) returns (stream SliceEvent ) {} + rpc SelectSlice (SliceFilter ) returns ( SliceList ) {} + + rpc ListConnectionIds (ServiceId ) returns ( ConnectionIdList) {} + rpc ListConnections (ServiceId ) returns ( ConnectionList ) {} + rpc GetConnection (ConnectionId ) returns ( Connection ) {} + rpc SetConnection (Connection ) returns ( ConnectionId ) {} + rpc RemoveConnection (ConnectionId ) returns ( Empty ) {} + rpc GetConnectionEvents(Empty ) returns (stream ConnectionEvent ) {} +} + +// ----- Generic ------------------------------------------------------------------------------------------------------- +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; +} + +// ----- Context ------------------------------------------------------------------------------------------------------- +message ContextId { + Uuid context_uuid = 1; +} + +message Context { + ContextId context_id = 1; + string name = 2; + repeated TopologyId topology_ids = 3; + repeated ServiceId service_ids = 4; + repeated SliceId slice_ids = 5; + TeraFlowController controller = 6; +} + +message ContextIdList { + repeated ContextId context_ids = 1; +} + +message ContextList { + repeated Context contexts = 1; +} + +message ContextEvent { + Event event = 1; + ContextId context_id = 2; +} + + +// ----- Topology ------------------------------------------------------------------------------------------------------ +message TopologyId { + ContextId context_id = 1; + Uuid topology_uuid = 2; +} + +message Topology { + TopologyId topology_id = 1; + string name = 2; + repeated DeviceId device_ids = 3; + repeated LinkId link_ids = 4; +} + +message TopologyDetails { + TopologyId topology_id = 1; + string name = 2; + repeated Device devices = 3; + repeated Link links = 4; +} + +message TopologyIdList { + repeated TopologyId topology_ids = 1; +} + +message TopologyList { + repeated Topology topologies = 1; +} + +message TopologyEvent { + Event event = 1; + TopologyId topology_id = 2; +} + + +// ----- Device -------------------------------------------------------------------------------------------------------- +message DeviceId { + Uuid device_uuid = 1; +} + +message Device { + DeviceId device_id = 1; + string name = 2; + string device_type = 3; + DeviceConfig device_config = 4; + DeviceOperationalStatusEnum device_operational_status = 5; + repeated DeviceDriverEnum device_drivers = 6; + repeated EndPoint device_endpoints = 7; + repeated Component components = 8; // Used for inventory + DeviceId controller_id = 9; // Identifier of node controlling the actual device +} + +message Component { //Defined previously to this section - Tested OK + Uuid component_uuid = 1; + string name = 2; + string type = 3; + + map<string, string> attributes = 4; // dict[attr.name => json.dumps(attr.value)] + string parent = 5; +} + +message DeviceConfig { + repeated ConfigRule config_rules = 1; +} + +enum DeviceDriverEnum { + DEVICEDRIVER_UNDEFINED = 0; // also used for emulated + DEVICEDRIVER_OPENCONFIG = 1; + DEVICEDRIVER_TRANSPORT_API = 2; + DEVICEDRIVER_P4 = 3; + DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4; + DEVICEDRIVER_ONF_TR_532 = 5; + DEVICEDRIVER_XR = 6; + DEVICEDRIVER_IETF_L2VPN = 7; + DEVICEDRIVER_GNMI_OPENCONFIG = 8; + DEVICEDRIVER_FLEXSCALE = 9; + DEVICEDRIVER_IETF_ACTN = 10; + DEVICEDRIVER_SMARTNIC = 11; +} + +enum DeviceOperationalStatusEnum { + DEVICEOPERATIONALSTATUS_UNDEFINED = 0; + DEVICEOPERATIONALSTATUS_DISABLED = 1; + DEVICEOPERATIONALSTATUS_ENABLED = 2; +} + +message DeviceIdList { + repeated DeviceId device_ids = 1; +} + +message DeviceList { + repeated Device devices = 1; +} + +message DeviceFilter { + DeviceIdList device_ids = 1; + bool include_endpoints = 2; + bool include_config_rules = 3; + bool include_components = 4; +} + +message DeviceEvent { + Event event = 1; + DeviceId device_id = 2; + DeviceConfig device_config = 3; +} + + +// ----- Link ---------------------------------------------------------------------------------------------------------- +message LinkId { + Uuid link_uuid = 1; +} + +message LinkAttributes { + float total_capacity_gbps = 1; + float used_capacity_gbps = 2; +} + +message Link { + LinkId link_id = 1; + string name = 2; + repeated EndPointId link_endpoint_ids = 3; + LinkAttributes attributes = 4; +} + +message LinkIdList { + repeated LinkId link_ids = 1; +} + +message LinkList { + repeated Link links = 1; +} + +message LinkEvent { + Event event = 1; + LinkId link_id = 2; +} + + +// ----- Service ------------------------------------------------------------------------------------------------------- +message ServiceId { + ContextId context_id = 1; + Uuid service_uuid = 2; +} + +message Service { + ServiceId service_id = 1; + string name = 2; + ServiceTypeEnum service_type = 3; + repeated EndPointId service_endpoint_ids = 4; + repeated Constraint service_constraints = 5; + ServiceStatus service_status = 6; + ServiceConfig service_config = 7; + Timestamp timestamp = 8; +} + +enum ServiceTypeEnum { + SERVICETYPE_UNKNOWN = 0; + SERVICETYPE_L3NM = 1; + SERVICETYPE_L2NM = 2; + SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; + SERVICETYPE_TE = 4; + SERVICETYPE_E2E = 5; +} + +enum ServiceStatusEnum { + SERVICESTATUS_UNDEFINED = 0; + SERVICESTATUS_PLANNED = 1; + SERVICESTATUS_ACTIVE = 2; + SERVICESTATUS_UPDATING = 3; + SERVICESTATUS_PENDING_REMOVAL = 4; + SERVICESTATUS_SLA_VIOLATED = 5; +} + +message ServiceStatus { + ServiceStatusEnum service_status = 1; +} + +message ServiceConfig { + repeated ConfigRule config_rules = 1; +} + +message ServiceIdList { + repeated ServiceId service_ids = 1; +} + +message ServiceList { + repeated Service services = 1; +} + +message ServiceFilter { + ServiceIdList service_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_config_rules = 4; +} + +message ServiceEvent { + Event event = 1; + ServiceId service_id = 2; +} + +// ----- Slice --------------------------------------------------------------------------------------------------------- +message SliceId { + ContextId context_id = 1; + Uuid slice_uuid = 2; +} + +message Slice { + SliceId slice_id = 1; + string name = 2; + repeated EndPointId slice_endpoint_ids = 3; + repeated Constraint slice_constraints = 4; + repeated ServiceId slice_service_ids = 5; + repeated SliceId slice_subslice_ids = 6; + SliceStatus slice_status = 7; + SliceConfig slice_config = 8; + SliceOwner slice_owner = 9; + Timestamp timestamp = 10; +} + +message SliceOwner { + Uuid owner_uuid = 1; + string owner_string = 2; +} + +enum SliceStatusEnum { + SLICESTATUS_UNDEFINED = 0; + SLICESTATUS_PLANNED = 1; + SLICESTATUS_INIT = 2; + SLICESTATUS_ACTIVE = 3; + SLICESTATUS_DEINIT = 4; + SLICESTATUS_SLA_VIOLATED = 5; +} + +message SliceStatus { + SliceStatusEnum slice_status = 1; +} + +message SliceConfig { + repeated ConfigRule config_rules = 1; +} + +message SliceIdList { + repeated SliceId slice_ids = 1; +} + +message SliceList { + repeated Slice slices = 1; +} + +message SliceFilter { + SliceIdList slice_ids = 1; + bool include_endpoint_ids = 2; + bool include_constraints = 3; + bool include_service_ids = 4; + bool include_subslice_ids = 5; + bool include_config_rules = 6; +} + +message SliceEvent { + Event event = 1; + SliceId slice_id = 2; +} + +// ----- Connection ---------------------------------------------------------------------------------------------------- +message ConnectionId { + Uuid connection_uuid = 1; +} + +message ConnectionSettings_L0 { + string lsp_symbolic_name = 1; +} + +message ConnectionSettings_L2 { + string src_mac_address = 1; + string dst_mac_address = 2; + uint32 ether_type = 3; + uint32 vlan_id = 4; + uint32 mpls_label = 5; + uint32 mpls_traffic_class = 6; +} + +message ConnectionSettings_L3 { + string src_ip_address = 1; + string dst_ip_address = 2; + uint32 dscp = 3; + uint32 protocol = 4; + uint32 ttl = 5; +} + +message ConnectionSettings_L4 { + uint32 src_port = 1; + uint32 dst_port = 2; + uint32 tcp_flags = 3; + uint32 ttl = 4; +} + +message ConnectionSettings { + ConnectionSettings_L0 l0 = 1; + ConnectionSettings_L2 l2 = 2; + ConnectionSettings_L3 l3 = 3; + ConnectionSettings_L4 l4 = 4; +} + +message Connection { + ConnectionId connection_id = 1; + ServiceId service_id = 2; + repeated EndPointId path_hops_endpoint_ids = 3; + repeated ServiceId sub_service_ids = 4; + ConnectionSettings settings = 5; +} + +message ConnectionIdList { + repeated ConnectionId connection_ids = 1; +} + +message ConnectionList { + repeated Connection connections = 1; +} + +message ConnectionEvent { + Event event = 1; + ConnectionId connection_id = 2; +} + + +// ----- Endpoint ------------------------------------------------------------------------------------------------------ +message EndPointId { + TopologyId topology_id = 1; + DeviceId device_id = 2; + Uuid endpoint_uuid = 3; +} + +message EndPoint { + EndPointId endpoint_id = 1; + string name = 2; + string endpoint_type = 3; + repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; + Location endpoint_location = 5; +} + +message EndPointName { + EndPointId endpoint_id = 1; + string device_name = 2; + string endpoint_name = 3; + string endpoint_type = 4; +} + +message EndPointIdList { + repeated EndPointId endpoint_ids = 1; +} + +message EndPointNameList { + repeated EndPointName endpoint_names = 1; +} + + +// ----- Configuration ------------------------------------------------------------------------------------------------- +enum ConfigActionEnum { + CONFIGACTION_UNDEFINED = 0; + CONFIGACTION_SET = 1; + CONFIGACTION_DELETE = 2; +} + +message ConfigRule_Custom { + string resource_key = 1; + string resource_value = 2; +} + +message ConfigRule_ACL { + EndPointId endpoint_id = 1; + acl.AclRuleSet rule_set = 2; +} + +message ConfigRule { + ConfigActionEnum action = 1; + oneof config_rule { + ConfigRule_Custom custom = 2; + ConfigRule_ACL acl = 3; + } +} + + +// ----- Constraint ---------------------------------------------------------------------------------------------------- +enum ConstraintActionEnum { + CONSTRAINTACTION_UNDEFINED = 0; + CONSTRAINTACTION_SET = 1; + CONSTRAINTACTION_DELETE = 2; +} + +message Constraint_Custom { + string constraint_type = 1; + string constraint_value = 2; +} + +message Constraint_Schedule { + float start_timestamp = 1; + float duration_days = 2; +} + +message GPS_Position { + float latitude = 1; + float longitude = 2; +} + +message Location { + oneof location { + string region = 1; + GPS_Position gps_position = 2; + } +} + +message Constraint_EndPointLocation { + EndPointId endpoint_id = 1; + Location location = 2; +} + +message Constraint_EndPointPriority { + EndPointId endpoint_id = 1; + uint32 priority = 2; +} + +message Constraint_SLA_Latency { + float e2e_latency_ms = 1; +} + +message Constraint_SLA_Capacity { + float capacity_gbps = 1; +} + +message Constraint_SLA_Availability { + uint32 num_disjoint_paths = 1; + bool all_active = 2; + float availability = 3; // 0.0 .. 100.0 percentage of availability +} + +enum IsolationLevelEnum { + NO_ISOLATION = 0; + PHYSICAL_ISOLATION = 1; + LOGICAL_ISOLATION = 2; + PROCESS_ISOLATION = 3; + PHYSICAL_MEMORY_ISOLATION = 4; + PHYSICAL_NETWORK_ISOLATION = 5; + VIRTUAL_RESOURCE_ISOLATION = 6; + NETWORK_FUNCTIONS_ISOLATION = 7; + SERVICE_ISOLATION = 8; +} + +message Constraint_SLA_Isolation_level { + repeated IsolationLevelEnum isolation_level = 1; +} + +message Constraint_Exclusions { + bool is_permanent = 1; + repeated DeviceId device_ids = 2; + repeated EndPointId endpoint_ids = 3; + repeated LinkId link_ids = 4; +} + +message Constraint { + ConstraintActionEnum action = 1; + oneof constraint { + Constraint_Custom custom = 2; + Constraint_Schedule schedule = 3; + Constraint_EndPointLocation endpoint_location = 4; + Constraint_EndPointPriority endpoint_priority = 5; + Constraint_SLA_Capacity sla_capacity = 6; + Constraint_SLA_Latency sla_latency = 7; + Constraint_SLA_Availability sla_availability = 8; + Constraint_SLA_Isolation_level sla_isolation = 9; + Constraint_Exclusions exclusions = 10; + } +} + + +// ----- Miscellaneous ------------------------------------------------------------------------------------------------- +message TeraFlowController { + ContextId context_id = 1; + string ip_address = 2; + uint32 port = 3; +} + +message AuthenticationResult { + ContextId context_id = 1; + bool authenticated = 2; +} diff --git a/src/ztp/src/main/proto/device.proto b/src/ztp/src/main/proto/device.proto deleted file mode 120000 index ad6e7c47e..000000000 --- a/src/ztp/src/main/proto/device.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/device.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/device.proto b/src/ztp/src/main/proto/device.proto new file mode 100644 index 000000000..30e60079d --- /dev/null +++ b/src/ztp/src/main/proto/device.proto @@ -0,0 +1,34 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 device; + +import "context.proto"; +import "monitoring.proto"; + +service DeviceService { + rpc AddDevice (context.Device ) returns (context.DeviceId ) {} + rpc ConfigureDevice (context.Device ) returns (context.DeviceId ) {} + rpc DeleteDevice (context.DeviceId ) returns (context.Empty ) {} + rpc GetInitialConfig(context.DeviceId ) returns (context.DeviceConfig) {} + rpc MonitorDeviceKpi(MonitoringSettings) returns (context.Empty ) {} +} + +message MonitoringSettings { + monitoring.KpiId kpi_id = 1; + monitoring.KpiDescriptor kpi_descriptor = 2; + float sampling_duration_s = 3; + float sampling_interval_s = 4; +} diff --git a/src/ztp/src/main/proto/kpi_sample_types.proto b/src/ztp/src/main/proto/kpi_sample_types.proto deleted file mode 120000 index 98e748bbf..000000000 --- a/src/ztp/src/main/proto/kpi_sample_types.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/kpi_sample_types.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/kpi_sample_types.proto b/src/ztp/src/main/proto/kpi_sample_types.proto new file mode 100644 index 000000000..5b234a4e3 --- /dev/null +++ b/src/ztp/src/main/proto/kpi_sample_types.proto @@ -0,0 +1,42 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 kpi_sample_types; + +enum KpiSampleType { + KPISAMPLETYPE_UNKNOWN = 0; + + KPISAMPLETYPE_PACKETS_TRANSMITTED = 101; + KPISAMPLETYPE_PACKETS_RECEIVED = 102; + KPISAMPLETYPE_PACKETS_DROPPED = 103; + KPISAMPLETYPE_BYTES_TRANSMITTED = 201; + KPISAMPLETYPE_BYTES_RECEIVED = 202; + KPISAMPLETYPE_BYTES_DROPPED = 203; + + KPISAMPLETYPE_LINK_TOTAL_CAPACITY_GBPS = 301; + KPISAMPLETYPE_LINK_USED_CAPACITY_GBPS = 302; + + KPISAMPLETYPE_ML_CONFIDENCE = 401; //. can be used by both optical and L3 without any issue + + KPISAMPLETYPE_OPTICAL_SECURITY_STATUS = 501; //. can be used by both optical and L3 without any issue + + KPISAMPLETYPE_L3_UNIQUE_ATTACK_CONNS = 601; + KPISAMPLETYPE_L3_TOTAL_DROPPED_PACKTS = 602; + KPISAMPLETYPE_L3_UNIQUE_ATTACKERS = 603; + KPISAMPLETYPE_L3_UNIQUE_COMPROMISED_CLIENTS = 604; + KPISAMPLETYPE_L3_SECURITY_STATUS_CRYPTO = 605; + + KPISAMPLETYPE_SERVICE_LATENCY_MS = 701; +} diff --git a/src/ztp/src/main/proto/monitoring.proto b/src/ztp/src/main/proto/monitoring.proto deleted file mode 120000 index aceaa7328..000000000 --- a/src/ztp/src/main/proto/monitoring.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/monitoring.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/monitoring.proto b/src/ztp/src/main/proto/monitoring.proto new file mode 100644 index 000000000..45ba48b02 --- /dev/null +++ b/src/ztp/src/main/proto/monitoring.proto @@ -0,0 +1,174 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 monitoring; + +import "context.proto"; +import "kpi_sample_types.proto"; + +service MonitoringService { + rpc SetKpi (KpiDescriptor ) returns (KpiId ) {} // Stable not final + rpc DeleteKpi (KpiId ) returns (context.Empty ) {} // Stable and final + rpc GetKpiDescriptor (KpiId ) returns (KpiDescriptor ) {} // Stable and final + rpc GetKpiDescriptorList (context.Empty ) returns (KpiDescriptorList ) {} // Stable and final + rpc IncludeKpi (Kpi ) returns (context.Empty ) {} // Stable and final + rpc MonitorKpi (MonitorKpiRequest ) returns (context.Empty ) {} // Stable and final + rpc QueryKpiData (KpiQuery ) returns (RawKpiTable ) {} // Not implemented + rpc SetKpiSubscription (SubsDescriptor ) returns (stream SubsResponse ) {} // Stable not final + rpc GetSubsDescriptor (SubscriptionID ) returns (SubsDescriptor ) {} // Stable and final + rpc GetSubscriptions (context.Empty ) returns (SubsList ) {} // Stable and final + rpc DeleteSubscription (SubscriptionID ) returns (context.Empty ) {} // Stable and final + rpc SetKpiAlarm (AlarmDescriptor ) returns (AlarmID ) {} // Stable not final + rpc GetAlarms (context.Empty ) returns (AlarmList ) {} // Stable and final + rpc GetAlarmDescriptor (AlarmID ) returns (AlarmDescriptor ) {} // Stable and final + rpc GetAlarmResponseStream(AlarmSubscription ) returns (stream AlarmResponse) {} // Not Stable not final + rpc DeleteAlarm (AlarmID ) returns (context.Empty ) {} // Stable and final + rpc GetStreamKpi (KpiId ) returns (stream Kpi ) {} // Stable not final + rpc GetInstantKpi (KpiId ) returns (Kpi ) {} // Stable not final +} + +message KpiDescriptor { + KpiId kpi_id = 1; + string kpi_description = 2; + repeated KpiId kpi_id_list = 3; + kpi_sample_types.KpiSampleType kpi_sample_type = 4; + context.DeviceId device_id = 5; + context.EndPointId endpoint_id = 6; + context.ServiceId service_id = 7; + context.SliceId slice_id = 8; + context.ConnectionId connection_id = 9; + context.LinkId link_id = 10; +} + +message MonitorKpiRequest { + KpiId kpi_id = 1; + float monitoring_window_s = 2; + float sampling_rate_s = 3; + // Pending add field to reflect Available Device Protocols +} + +message KpiQuery { + repeated KpiId kpi_ids = 1; + float monitoring_window_s = 2; + uint32 last_n_samples = 3; // used when you want something like "get the last N many samples + context.Timestamp start_timestamp = 4; // used when you want something like "get the samples since X date/time" + context.Timestamp end_timestamp = 5; // used when you want something like "get the samples until X date/time" +} + + +message RawKpi { // cell + context.Timestamp timestamp = 1; + KpiValue kpi_value = 2; +} + +message RawKpiList { // column + KpiId kpi_id = 1; + repeated RawKpi raw_kpis = 2; +} + +message RawKpiTable { // table + repeated RawKpiList raw_kpi_lists = 1; +} + +message KpiId { + context.Uuid kpi_id = 1; +} + +message Kpi { + KpiId kpi_id = 1; + context.Timestamp timestamp = 2; + KpiValue kpi_value = 3; +} + +message KpiValueRange { + KpiValue kpiMinValue = 1; + KpiValue kpiMaxValue = 2; + bool inRange = 3; // by default True + bool includeMinValue = 4; // False is outside the interval + bool includeMaxValue = 5; // False is outside the interval +} + +message KpiValue { + oneof value { + int32 int32Val = 1; + uint32 uint32Val = 2; + int64 int64Val = 3; + uint64 uint64Val = 4; + float floatVal = 5; + string stringVal = 6; + bool boolVal = 7; + } +} + + +message KpiList { + repeated Kpi kpi = 1; +} + +message KpiDescriptorList { + repeated KpiDescriptor kpi_descriptor_list = 1; +} + +message SubsDescriptor{ + SubscriptionID subs_id = 1; + KpiId kpi_id = 2; + float sampling_duration_s = 3; + float sampling_interval_s = 4; + context.Timestamp start_timestamp = 5; // used when you want something like "get the samples since X date/time" + context.Timestamp end_timestamp = 6; // used when you want something like "get the samples until X date/time" + // Pending add field to reflect Available Device Protocols +} + +message SubscriptionID { + context.Uuid subs_id = 1; +} + +message SubsResponse { + SubscriptionID subs_id = 1; + KpiList kpi_list = 2; +} + +message SubsList { + repeated SubsDescriptor subs_descriptor = 1; +} + +message AlarmDescriptor { + AlarmID alarm_id = 1; + string alarm_description = 2; + string name = 3; + KpiId kpi_id = 4; + KpiValueRange kpi_value_range = 5; + context.Timestamp timestamp = 6; +} + +message AlarmID{ + context.Uuid alarm_id = 1; +} + +message AlarmSubscription{ + AlarmID alarm_id = 1; + float subscription_timeout_s = 2; + float subscription_frequency_ms = 3; +} + +message AlarmResponse { + AlarmID alarm_id = 1; + string text = 2; + KpiList kpi_list = 3; +} + +message AlarmList { + repeated AlarmDescriptor alarm_descriptor = 1; +} diff --git a/src/ztp/src/main/proto/ztp.proto b/src/ztp/src/main/proto/ztp.proto deleted file mode 120000 index 9183ce531..000000000 --- a/src/ztp/src/main/proto/ztp.proto +++ /dev/null @@ -1 +0,0 @@ -../../../../../proto/ztp.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/ztp.proto b/src/ztp/src/main/proto/ztp.proto new file mode 100644 index 000000000..5c895900d --- /dev/null +++ b/src/ztp/src/main/proto/ztp.proto @@ -0,0 +1,69 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 ztp; + +import "context.proto"; + +service ZtpService { + rpc ZtpGetDeviceRole(DeviceRoleId) returns (DeviceRole) {} + rpc ZtpGetDeviceRolesByDeviceId(context.DeviceId) returns (DeviceRoleList) {} + rpc ZtpAdd(DeviceRole) returns (DeviceRoleState) {} + rpc ZtpUpdate(DeviceRoleConfig) returns (DeviceRoleState) {} + rpc ZtpDelete(DeviceRole) returns (DeviceRoleState) {} + rpc ZtpDeleteAll(context.Empty) returns (DeviceDeletionResult) {} +} + +enum DeviceRoleType { + NONE = 0; + DEV_OPS = 1; + DEV_CONF = 2; + PIPELINE_CONF = 3; +} + +message DeviceRoleId { + context.Uuid devRoleId = 1; + context.DeviceId devId = 2; +} + +message DeviceRole { + DeviceRoleId devRoleId = 1; + DeviceRoleType devRoleType = 2; +} + +message DeviceRoleConfig { + DeviceRole devRole = 1; + context.DeviceConfig devConfig = 2; +} + +message DeviceRoleList { + repeated DeviceRole devRole = 1; +} + +message DeviceRoleState { + DeviceRoleId devRoleId = 1; + ZtpDeviceState devRoleState = 2; +} + +message DeviceDeletionResult { + repeated string deleted = 1; +} + +enum ZtpDeviceState { + ZTP_DEV_STATE_UNDEFINED = 0; + ZTP_DEV_STATE_CREATED = 1; + ZTP_DEV_STATE_UPDATED = 2; + ZTP_DEV_STATE_DELETED = 3; +} -- GitLab From 87b5aa6f30df31a03fbb7991a2bb51b027179e80 Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Fri, 22 Mar 2024 08:40:38 +0000 Subject: [PATCH 11/14] Update - Morpheus Client Extension --- src/common/tools/object_factory/Device.py | 5 +++-- .../drivers/smartnic/SmartnicDriver.py | 12 +++++++---- src/device/service/drivers/smartnic/Tools.py | 12 +++++++---- .../service/drivers/smartnic/__init__.py | 2 -- .../ietf-yang-types.yang | 0 .../openconfig-extensions.yang | 0 .../openconfig-inet-types.yang | 0 .../openconfig-probes-types.yang | 0 .../openconfig-probes.yang | 0 .../openconfig-types.yang | 0 .../probes-agent.yang | 0 .../references_probes_libraries.txt | 0 .../service/drivers/smartnic_probes/.gitkeep | 0 .../smartnics_probes_agent/.gitkeep | 0 .../nbi_plugins/agent_probes/Resources.py | 21 ++++++++++++------- .../nbi_plugins/agent_probes/Tools.py | 12 +++++++---- 16 files changed, 40 insertions(+), 24 deletions(-) rename src/device/service/drivers/{smartnic_probes => smartnic}/ietf-yang-types.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/openconfig-extensions.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/openconfig-inet-types.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/openconfig-probes-types.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/openconfig-probes.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/openconfig-types.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/probes-agent.yang (100%) rename src/device/service/drivers/{smartnic_probes => smartnic}/references_probes_libraries.txt (100%) delete mode 100644 src/device/service/drivers/smartnic_probes/.gitkeep delete mode 100644 src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index b3182e302..5a7ff398a 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy +import copy, logging from typing import Dict, List, Optional, Tuple from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import DeviceDriverEnum, DeviceOperationalStatusEnum from common.tools.object_factory.ConfigRule import json_config_rule_set +LOGGER = logging.getLogger(__name__) DEVICE_DISABLED = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED DEVICE_EMUDC_TYPE = DeviceTypeEnum.EMULATED_DATACENTER.value @@ -62,13 +63,13 @@ def json_device( ): result = { 'device_id' : json_device_id(device_uuid), + 'name' : name, 'device_type' : device_type, 'device_config' : {'config_rules': copy.deepcopy(config_rules)}, 'device_operational_status': status, 'device_drivers' : copy.deepcopy(drivers), 'device_endpoints' : copy.deepcopy(endpoints), } - if name is not None: result['name'] = name return result def json_device_emulated_packet_router_disabled( diff --git a/src/device/service/drivers/smartnic/SmartnicDriver.py b/src/device/service/drivers/smartnic/SmartnicDriver.py index 4bad52db4..f827bbbff 100644 --- a/src/device/service/drivers/smartnic/SmartnicDriver.py +++ b/src/device/service/drivers/smartnic/SmartnicDriver.py @@ -20,8 +20,11 @@ from common.type_checkers.Checkers import chk_string, chk_type from device.service.driver_api._Driver import _Driver from . import ALL_RESOURCE_KEYS from .Tools import create_connectivity_service, find_key, config_getter, delete_connectivity_service +from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string + LOGGER = logging.getLogger(__name__) +from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_SERVICES, RESOURCE_INTERFACES DRIVER_NAME = 'smartnic' METRICS_POOL = MetricsPool('Device', 'Driver', labels={'driver': DRIVER_NAME}) @@ -75,8 +78,9 @@ class SmartnicDriver(_Driver): for i, resource_key in enumerate(resource_keys): str_resource_name = 'resource_key[#{:d}]'.format(i) chk_string(str_resource_name, resource_key, allow_empty=False) - results.extend(config_getter( - self.__tapi_root, resource_key, timeout=self.__timeout)) + if resource_key == RESOURCE_ENDPOINTS: + results.extend(config_getter( + self.__tapi_root, resource_key, timeout=self.__timeout)) return results @metered_subclass_method(METRICS_POOL) @@ -87,9 +91,9 @@ class SmartnicDriver(_Driver): with self.__lock: for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) - config_rules = find_key(resource, 'config_rules') + #config_rules = find_key(resource, 'config_rules') data = create_connectivity_service( - self.__tapi_root, config_rules, timeout=self.__timeout) + self.__tapi_root, resource[1], timeout=self.__timeout) results.extend(data) return results diff --git a/src/device/service/drivers/smartnic/Tools.py b/src/device/service/drivers/smartnic/Tools.py index 54961bbdd..bd155441c 100644 --- a/src/device/service/drivers/smartnic/Tools.py +++ b/src/device/service/drivers/smartnic/Tools.py @@ -50,6 +50,11 @@ def config_getter( result = [] try: response = requests.get(url, timeout=timeout, verify=False) + data = response.json() + for item in data: + tupla = ('/endpoints/endpoint', item) + result.append(tupla) + return result except requests.exceptions.Timeout: LOGGER.exception('Timeout connecting {:s}'.format(url)) return result @@ -57,7 +62,6 @@ def config_getter( LOGGER.exception('Exception retrieving {:s}'.format(resource_key)) result.append((resource_key, e)) return result - return response # try: # context = json.loads(response.content) @@ -72,13 +76,13 @@ def create_connectivity_service( root_url, config_rules, timeout : Optional[int] = None, auth : Optional[HTTPBasicAuth] = None ): - url = '{:s}/configure'.format(root_url) + url = '{:s}/manage-probe/configure'.format(root_url) headers = {'content-type': 'application/json'} results = [] try: LOGGER.info('Configuring Smartnic rules') response = requests.post( - url=url, data=json.dumps(config_rules), timeout=timeout, headers=headers, verify=False) + url=url, data=config_rules, timeout=timeout, headers=headers, verify=False) LOGGER.info('SmartNIC Probes response: {:s}'.format(str(response))) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Exception creating ConfigRule') @@ -92,7 +96,7 @@ def create_connectivity_service( def delete_connectivity_service(root_url, config_rules, timeout : Optional[int] = None, auth : Optional[HTTPBasicAuth] = None ): - url = '{:s}/configure'.format(root_url) + url = '{:s}/manage-probe/configure'.format(root_url) results = [] try: response = requests.delete(url=url, timeout=timeout, verify=False) diff --git a/src/device/service/drivers/smartnic/__init__.py b/src/device/service/drivers/smartnic/__init__.py index bc88d00fa..b3626c633 100644 --- a/src/device/service/drivers/smartnic/__init__.py +++ b/src/device/service/drivers/smartnic/__init__.py @@ -14,7 +14,5 @@ from device.service.driver_api._Driver import RESOURCE_ENDPOINTS, RESOURCE_SERVICES, RESOURCE_INTERFACES ALL_RESOURCE_KEYS = [ - RESOURCE_ENDPOINTS, - RESOURCE_SERVICES, RESOURCE_INTERFACES ] diff --git a/src/device/service/drivers/smartnic_probes/ietf-yang-types.yang b/src/device/service/drivers/smartnic/ietf-yang-types.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/ietf-yang-types.yang rename to src/device/service/drivers/smartnic/ietf-yang-types.yang diff --git a/src/device/service/drivers/smartnic_probes/openconfig-extensions.yang b/src/device/service/drivers/smartnic/openconfig-extensions.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/openconfig-extensions.yang rename to src/device/service/drivers/smartnic/openconfig-extensions.yang diff --git a/src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang b/src/device/service/drivers/smartnic/openconfig-inet-types.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/openconfig-inet-types.yang rename to src/device/service/drivers/smartnic/openconfig-inet-types.yang diff --git a/src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang b/src/device/service/drivers/smartnic/openconfig-probes-types.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/openconfig-probes-types.yang rename to src/device/service/drivers/smartnic/openconfig-probes-types.yang diff --git a/src/device/service/drivers/smartnic_probes/openconfig-probes.yang b/src/device/service/drivers/smartnic/openconfig-probes.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/openconfig-probes.yang rename to src/device/service/drivers/smartnic/openconfig-probes.yang diff --git a/src/device/service/drivers/smartnic_probes/openconfig-types.yang b/src/device/service/drivers/smartnic/openconfig-types.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/openconfig-types.yang rename to src/device/service/drivers/smartnic/openconfig-types.yang diff --git a/src/device/service/drivers/smartnic_probes/probes-agent.yang b/src/device/service/drivers/smartnic/probes-agent.yang similarity index 100% rename from src/device/service/drivers/smartnic_probes/probes-agent.yang rename to src/device/service/drivers/smartnic/probes-agent.yang diff --git a/src/device/service/drivers/smartnic_probes/references_probes_libraries.txt b/src/device/service/drivers/smartnic/references_probes_libraries.txt similarity index 100% rename from src/device/service/drivers/smartnic_probes/references_probes_libraries.txt rename to src/device/service/drivers/smartnic/references_probes_libraries.txt diff --git a/src/device/service/drivers/smartnic_probes/.gitkeep b/src/device/service/drivers/smartnic_probes/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep b/src/device/service/drivers/smartnic_probes/smartnics_probes_agent/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py index 2b0a537cc..daafd79ab 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py @@ -181,10 +181,10 @@ class Device(_Resource): return format_grpc_to_json(self.device_client.AddDevice(grpc_device( device_uuid = device['device_id']['device_uuid']['uuid'], device_type = device['device_type'], - config_rules = device['device_config']['config_rules'], status = device['device_operational_status'], - drivers = device['device_drivers'], - endpoints = device['device_endpoints'] + endpoints = device['device_endpoints'], + config_rules = device['device_config']['config_rules'], + drivers = device['device_drivers'] ))) def put(self, device_uuid : str): # pylint: disable=unused-argument @@ -192,12 +192,17 @@ class Device(_Resource): return format_grpc_to_json(self.device_client.ConfigureDevice(grpc_device( device_uuid = device['device_id']['device_uuid']['uuid'], device_type = device['device_type'], - device_config = device['device_config']['config_rules'], - device_operational_status = device['device_operational_status'], - device_drivers = device['device_drivers'], - device_endpoints = device['device_endpoints'] + status = device['device_operational_status'], + endpoints = device['device_endpoints'], + config_rules = device['device_config']['config_rules'], + drivers = device['device_drivers'] + ))) + + def delete(self, device_uuid : str): + device = request.get_json()['devices'][0] + return format_grpc_to_json(self.device_client.DeleteDevice(grpc_device( + device_uuid = device['device_id']['device_uuid']['uuid'] ))) - class LinkIds(_Resource): def get(self): diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py index 17b6dcdfd..6cffbb5cc 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging from flask.json import jsonify from common.proto.context_pb2 import ( ConnectionId, ContextId, DeviceDriverEnum, Device, DeviceId, DeviceOperationalStatusEnum, LinkId, ServiceId, SliceId, TopologyId, Service, ServiceStatusEnum ) from common.proto.policy_pb2 import PolicyRuleId -from common.tools.grpc.Tools import grpc_message_to_json +from common.proto.context_pb2 import ConfigActionEnum +from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from common.tools.object_factory.Connection import json_connection_id from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.ConfigRule import json_config_rule @@ -30,6 +32,8 @@ from common.tools.object_factory.Service import json_service_id, json_service from common.tools.object_factory.Slice import json_slice_id from common.tools.object_factory.Topology import json_topology_id +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.DEBUG) def format_grpc_to_json(grpc_reply): return jsonify(grpc_message_to_json(grpc_reply)) @@ -44,8 +48,9 @@ def grpc_device_id(device_uuid): return DeviceId(**json_device_id(device_uuid)) def grpc_device( - device_uuid, device_type, config_rules=None, status=None, drivers=None, endpoints=None + device_uuid, device_type, status, endpoints=None, config_rules=None, drivers=None ): + json_config_rules = [ json_config_rule( config_rule['action'], @@ -68,8 +73,7 @@ def grpc_device( for endpoint in endpoints ] if endpoints else [] return Device(**json_device( - device_uuid, device_type, json_config_rules, json_status, - json_drivers, json_endpoints)) + device_uuid, device_type, json_status, None, json_endpoints, json_config_rules, json_drivers)) def grpc_link_id(link_uuid): return LinkId(**json_link_id(link_uuid)) -- GitLab From 9bdfc3c75bdb2dc7ad493272565436150cfb4f34 Mon Sep 17 00:00:00 2001 From: carcel <jose.carcel@atos.net> Date: Fri, 22 Mar 2024 09:40:51 +0000 Subject: [PATCH 12/14] Update - Morpheus Client Extension --- src/device/service/drivers/smartnic/SmartnicDriver.py | 4 ++-- src/device/service/drivers/smartnic/Tools.py | 2 +- .../rest_server/nbi_plugins/agent_probes/Resources.py | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/device/service/drivers/smartnic/SmartnicDriver.py b/src/device/service/drivers/smartnic/SmartnicDriver.py index f827bbbff..35d05edde 100644 --- a/src/device/service/drivers/smartnic/SmartnicDriver.py +++ b/src/device/service/drivers/smartnic/SmartnicDriver.py @@ -104,9 +104,9 @@ class SmartnicDriver(_Driver): with self.__lock: for resource in resources: LOGGER.info('resource = {:s}'.format(str(resource))) - config_rules = find_key(resource, 'config_rules') + #config_rules = find_key(resource, 'config_rules') results.extend(delete_connectivity_service( - self.__tapi_root, config_rules, timeout=self.__timeout)) + self.__tapi_root, resource[1], timeout=self.__timeout)) return results @metered_subclass_method(METRICS_POOL) diff --git a/src/device/service/drivers/smartnic/Tools.py b/src/device/service/drivers/smartnic/Tools.py index bd155441c..13345b618 100644 --- a/src/device/service/drivers/smartnic/Tools.py +++ b/src/device/service/drivers/smartnic/Tools.py @@ -99,7 +99,7 @@ def delete_connectivity_service(root_url, config_rules, timeout : Optional[int] url = '{:s}/manage-probe/configure'.format(root_url) results = [] try: - response = requests.delete(url=url, timeout=timeout, verify=False) + response = requests.delete(url=url, data=config_rules, timeout=timeout, verify=False) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Exception deleting ConfigRule') results.append(e) diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py index daafd79ab..50e8e77af 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py @@ -201,7 +201,12 @@ class Device(_Resource): def delete(self, device_uuid : str): device = request.get_json()['devices'][0] return format_grpc_to_json(self.device_client.DeleteDevice(grpc_device( - device_uuid = device['device_id']['device_uuid']['uuid'] + device_uuid = device['device_id']['device_uuid']['uuid'], + device_type = device['device_type'], + status = device['device_operational_status'], + endpoints = device['device_endpoints'], + config_rules = device['device_config']['config_rules'], + drivers = device['device_drivers'] ))) class LinkIds(_Resource): -- GitLab From 1a2ad3f91f2b8404b9f60f808a8a6677ce8b769d Mon Sep 17 00:00:00 2001 From: jimenezquesa <manuel.jimenez@eviden.com> Date: Thu, 10 Apr 2025 10:57:52 +0200 Subject: [PATCH 13/14] Code cleanup --- proto/context.proto | 2 +- proto/nfv_client.proto | 51 -- proto/nos_client.proto | 33 - src/common/tools/object_factory/Device.py | 6 +- src/device/service/drivers/__init__.py | 2 +- .../drivers/smartnic/probes-agent.yang | 14 + .../nbi_plugins/agent_probes/Resources.py | 180 +---- .../nbi_plugins/agent_probes/Tools.py | 73 +-- .../nbi_plugins/agent_probes/__init__.py | 41 +- src/nbi/tests/data/agent_probes_device.json | 1 - src/policy/Dockerfile | 67 +- src/policy/src/main/proto/acl.proto | 70 +- src/policy/src/main/proto/context.proto | 616 +----------------- .../src/main/proto/context_policy.proto | 29 +- src/policy/src/main/proto/device.proto | 35 +- .../src/main/proto/kpi_sample_types.proto | 43 +- src/policy/src/main/proto/monitoring.proto | 175 +---- src/policy/src/main/proto/policy.proto | 114 +--- src/policy/src/main/proto/policy_action.proto | 43 +- .../src/main/proto/policy_condition.proto | 44 +- src/policy/src/main/proto/service.proto | 26 +- src/ztp/Dockerfile | 68 +- src/ztp/src/main/proto/acl.proto | 70 +- src/ztp/src/main/proto/context.proto | 616 +----------------- src/ztp/src/main/proto/device.proto | 35 +- src/ztp/src/main/proto/kpi_sample_types.proto | 43 +- src/ztp/src/main/proto/monitoring.proto | 175 +---- src/ztp/src/main/proto/ztp.proto | 70 +- 28 files changed, 42 insertions(+), 2700 deletions(-) delete mode 100644 proto/nfv_client.proto delete mode 100644 proto/nos_client.proto mode change 100644 => 120000 src/policy/Dockerfile mode change 100644 => 120000 src/policy/src/main/proto/acl.proto mode change 100644 => 120000 src/policy/src/main/proto/context.proto mode change 100644 => 120000 src/policy/src/main/proto/context_policy.proto mode change 100644 => 120000 src/policy/src/main/proto/device.proto mode change 100644 => 120000 src/policy/src/main/proto/kpi_sample_types.proto mode change 100644 => 120000 src/policy/src/main/proto/monitoring.proto mode change 100644 => 120000 src/policy/src/main/proto/policy.proto mode change 100644 => 120000 src/policy/src/main/proto/policy_action.proto mode change 100644 => 120000 src/policy/src/main/proto/policy_condition.proto mode change 100644 => 120000 src/policy/src/main/proto/service.proto mode change 100644 => 120000 src/ztp/Dockerfile mode change 100644 => 120000 src/ztp/src/main/proto/acl.proto mode change 100644 => 120000 src/ztp/src/main/proto/context.proto mode change 100644 => 120000 src/ztp/src/main/proto/device.proto mode change 100644 => 120000 src/ztp/src/main/proto/kpi_sample_types.proto mode change 100644 => 120000 src/ztp/src/main/proto/monitoring.proto mode change 100644 => 120000 src/ztp/src/main/proto/ztp.proto diff --git a/proto/context.proto b/proto/context.proto index b6b55c15f..d22dcdc43 100644 --- a/proto/context.proto +++ b/proto/context.proto @@ -497,7 +497,7 @@ message EndPointId { message EndPoint { EndPointId endpoint_id = 1; string name = 2; - string endpoint_type = 3; // == 'smartnics' + string endpoint_type = 3; repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; Location endpoint_location = 5; map<string, google.protobuf.Any> capabilities = 6; diff --git a/proto/nfv_client.proto b/proto/nfv_client.proto deleted file mode 100644 index d903e7907..000000000 --- a/proto/nfv_client.proto +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 nfv_client; - -import "context.proto"; - -message Nsd { - string nsd_name = 1; - string config_params=2; -} - -message Ns { - string ns_id=1; - string ns_name=2; - string nsd_name=3; - string vim_account=4; - string config_params=5; - string status = 6; - string status_message = 7; -} - -message NsList { - repeated Ns ns = 1; -} - -message NsdList { - repeated Nsd nsd = 1; -} - -service nfv_client { - rpc GetNsList (context.Empty) returns (NsList) {} - rpc GetNsdList (context.Empty) returns (NsdList) {} - rpc CreateNs (Ns) returns (Ns) {} - rpc UpdateNs (Ns) returns (Ns) {} - rpc DeleteNs (Ns) returns (context.Empty) {} -} - - diff --git a/proto/nos_client.proto b/proto/nos_client.proto deleted file mode 100644 index e0e35a648..000000000 --- a/proto/nos_client.proto +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 nos_client; - -message NOS_SW { - string ztp_device_sw_url = 1; - bytes ztp_device_sw_file = 2; -} - -message Config_Script { - string config_script_url = 1; - bytes config_script_file = 2; -} - -service nos_client { - rpc GetNOSFile (NOS_SW) returns (NOS_SW) {} - rpc GetConfigScriptFile (Config_Script) returns (Config_Script) {} -} - - diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index bb5c85634..3d09d7156 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy, logging +import copy from typing import Dict, List, Optional, Tuple from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import DeviceDriverEnum, DeviceOperationalStatusEnum from common.tools.object_factory.ConfigRule import json_config_rule_set -LOGGER = logging.getLogger(__name__) DEVICE_DISABLED = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED DEVICE_EMUDC_TYPE = DeviceTypeEnum.EMULATED_DATACENTER.value @@ -53,7 +52,6 @@ DEVICE_IETF_ACTN_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN] DEVICE_SMARTNIC_TYPE = DeviceTypeEnum.SMARTNIC.value DEVICE_SMARTNIC_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_SMARTNIC] - def json_device_id(device_uuid : str): return {'device_uuid': {'uuid': device_uuid}} @@ -63,13 +61,13 @@ def json_device( ): result = { 'device_id' : json_device_id(device_uuid), - 'name' : name, 'device_type' : device_type, 'device_config' : {'config_rules': copy.deepcopy(config_rules)}, 'device_operational_status': status, 'device_drivers' : copy.deepcopy(drivers), 'device_endpoints' : copy.deepcopy(endpoints), } + if name is not None: result['name'] = name return result def json_device_emulated_packet_router_disabled( diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py index 3c1baf5df..ccb348c05 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -167,7 +167,7 @@ if LOAD_ALL_DEVICE_DRIVERS: DRIVERS.append( (SmartnicDriver, [ { - # Real P4 Switch, specifying P4 Driver => use P4Driver + # Real SmartNics device => use SmartNicsDriver FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.SMARTNIC, FilterFieldEnum.DRIVER : DeviceDriverEnum.DEVICEDRIVER_SMARTNIC, } diff --git a/src/device/service/drivers/smartnic/probes-agent.yang b/src/device/service/drivers/smartnic/probes-agent.yang index 897d2f129..0ed81170a 100644 --- a/src/device/service/drivers/smartnic/probes-agent.yang +++ b/src/device/service/drivers/smartnic/probes-agent.yang @@ -1,3 +1,17 @@ +// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. + module probes-agent { namespace "urn:probes-agent"; diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py index 50e8e77af..3c3184323 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py @@ -12,162 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json -from flask.json import jsonify from flask_restful import Resource, request from common.proto.context_pb2 import Empty -from common.tools.grpc.Tools import grpc_message_to_json from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient -from service.client.ServiceClient import ServiceClient -from .Tools import ( - format_grpc_to_json, grpc_connection_id, grpc_context_id, grpc_device, grpc_device_id, grpc_link_id, grpc_policy_rule_id, - grpc_service_id, grpc_service, grpc_slice_id, grpc_topology_id) +from .Tools import format_grpc_to_json, grpc_device, grpc_device_id class _Resource(Resource): def __init__(self) -> None: super().__init__() self.client = ContextClient() self.device_client = DeviceClient() - self.service_client = ServiceClient() - -class ContextIds(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListContextIds(Empty())) - -class Contexts(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListContexts(Empty())) - -class DummyContexts(_Resource): - def get(self): - contexts = grpc_message_to_json(self.client.ListContexts(Empty()), use_integers_for_enums=True)['contexts'] - devices = grpc_message_to_json(self.client.ListDevices(Empty()), use_integers_for_enums=True)['devices'] - links = grpc_message_to_json(self.client.ListLinks(Empty()), use_integers_for_enums=True)['links'] - - topologies = list() - slices = list() - services = list() - connections = list() - - for context in contexts: - context_uuid = context['context_id']['context_uuid']['uuid'] - context_id = grpc_context_id(context_uuid) - - topologies.extend(grpc_message_to_json( - self.client.ListTopologies(context_id), - use_integers_for_enums=True - )['topologies']) - - slices.extend(grpc_message_to_json( - self.client.ListSlices(context_id), - use_integers_for_enums=True - )['slices']) - - context_services = grpc_message_to_json( - self.client.ListServices(context_id), - use_integers_for_enums=True - )['services'] - services.extend(context_services) - - for service in context_services: - service_uuid = service['service_id']['service_uuid']['uuid'] - service_id = grpc_service_id(context_uuid, service_uuid) - connections.extend(grpc_message_to_json( - self.client.ListConnections(service_id), - use_integers_for_enums=True - )['connections']) - - for device in devices: - for config_rule in device['device_config']['config_rules']: - if 'custom' not in config_rule: continue - resource_value = config_rule['custom']['resource_value'] - if not isinstance(resource_value, str): continue - try: - resource_value = json.loads(resource_value) - except: # pylint: disable=bare-except - pass - config_rule['custom']['resource_value'] = resource_value - - dummy_context = {'dummy_mode': True} - if len(contexts ) > 0: dummy_context['contexts' ] = contexts - if len(topologies ) > 0: dummy_context['topologies' ] = topologies - if len(devices ) > 0: dummy_context['devices' ] = devices - if len(links ) > 0: dummy_context['links' ] = links - if len(slices ) > 0: dummy_context['slices' ] = slices - if len(services ) > 0: dummy_context['services' ] = services - if len(connections) > 0: dummy_context['connections'] = connections - return jsonify(dummy_context) - -class Context(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.GetContext(grpc_context_id(context_uuid))) - -class TopologyIds(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListTopologyIds(grpc_context_id(context_uuid))) - -class Topologies(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListTopologies(grpc_context_id(context_uuid))) - -class Topology(_Resource): - def get(self, context_uuid : str, topology_uuid : str): - return format_grpc_to_json(self.client.GetTopology(grpc_topology_id(context_uuid, topology_uuid))) - -class ServiceIds(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListServiceIds(grpc_context_id(context_uuid))) - -class Services(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListServices(grpc_context_id(context_uuid))) - -class Service(_Resource): - def get(self, context_uuid : str, service_uuid : str): - return format_grpc_to_json(self.client.GetService(grpc_service_id(context_uuid, service_uuid))) - - def post(self, context_uuid : str, service_uuid : str): # pylint: disable=unused-argument - service = request.get_json()['services'][0] - return format_grpc_to_json(self.service_client.CreateService(grpc_service( - service_uuid = service['service_id']['service_uuid']['uuid'], - service_type = service['service_type'], - context_uuid = service['service_id']['context_id']['context_uuid']['uuid'], - ))) - - def put(self, context_uuid : str, service_uuid : str): # pylint: disable=unused-argument - service = request.get_json()['services'][0] - return format_grpc_to_json(self.service_client.UpdateService(grpc_service( - service_uuid = service['service_id']['service_uuid']['uuid'], - service_type = service['service_type'], - context_uuid = service['service_id']['context_id']['context_uuid']['uuid'], - status = service['service_status']['service_status'], - endpoint_ids = service['service_endpoint_ids'], - constraints = service['service_constraints'], - config_rules = service['service_config']['config_rules'] - ))) - - def delete(self, context_uuid : str, service_uuid : str): - return format_grpc_to_json(self.service_client.DeleteService(grpc_service_id( - context_uuid, service_uuid, - ))) - -class SliceIds(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListSliceIds(grpc_context_id(context_uuid))) - -class Slices(_Resource): - def get(self, context_uuid : str): - return format_grpc_to_json(self.client.ListSlices(grpc_context_id(context_uuid))) - -class Slice(_Resource): - def get(self, context_uuid : str, slice_uuid : str): - return format_grpc_to_json(self.client.GetSlice(grpc_slice_id(context_uuid, slice_uuid))) class DeviceIds(_Resource): def get(self): return format_grpc_to_json(self.client.ListDeviceIds(Empty())) - + class Devices(_Resource): def get(self): return format_grpc_to_json(self.client.ListDevices(Empty())) @@ -208,39 +68,3 @@ class Device(_Resource): config_rules = device['device_config']['config_rules'], drivers = device['device_drivers'] ))) - -class LinkIds(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListLinkIds(Empty())) - -class Links(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListLinks(Empty())) - -class Link(_Resource): - def get(self, link_uuid : str): - return format_grpc_to_json(self.client.GetLink(grpc_link_id(link_uuid))) - -class ConnectionIds(_Resource): - def get(self, context_uuid : str, service_uuid : str): - return format_grpc_to_json(self.client.ListConnectionIds(grpc_service_id(context_uuid, service_uuid))) - -class Connections(_Resource): - def get(self, context_uuid : str, service_uuid : str): - return format_grpc_to_json(self.client.ListConnections(grpc_service_id(context_uuid, service_uuid))) - -class Connection(_Resource): - def get(self, connection_uuid : str): - return format_grpc_to_json(self.client.GetConnection(grpc_connection_id(connection_uuid))) - -class PolicyRuleIds(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListPolicyRuleIds(Empty())) - -class PolicyRules(_Resource): - def get(self): - return format_grpc_to_json(self.client.ListPolicyRules(Empty())) - -class PolicyRule(_Resource): - def get(self, policy_rule_uuid : str): - return format_grpc_to_json(self.client.GetPolicyRule(grpc_policy_rule_id(policy_rule_uuid))) diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py index 6cffbb5cc..27a2780bb 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py @@ -12,45 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging from flask.json import jsonify from common.proto.context_pb2 import ( - ConnectionId, ContextId, DeviceDriverEnum, Device, DeviceId, DeviceOperationalStatusEnum, LinkId, ServiceId, SliceId, TopologyId, Service, ServiceStatusEnum + DeviceDriverEnum, Device, DeviceId, DeviceOperationalStatusEnum ) -from common.proto.policy_pb2 import PolicyRuleId -from common.proto.context_pb2 import ConfigActionEnum -from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string -from common.tools.object_factory.Connection import json_connection_id -from common.tools.object_factory.Context import json_context_id +from common.tools.grpc.Tools import grpc_message_to_json from common.tools.object_factory.ConfigRule import json_config_rule -from common.tools.object_factory.Constraint import json_constraint_custom -from common.tools.object_factory.EndPoint import json_endpoint_id, json_endpoint +from common.tools.object_factory.EndPoint import json_endpoint from common.tools.object_factory.Device import json_device_id, json_device -from common.tools.object_factory.Link import json_link_id -from common.tools.object_factory.PolicyRule import json_policyrule_id -from common.tools.object_factory.Service import json_service_id, json_service -from common.tools.object_factory.Slice import json_slice_id -from common.tools.object_factory.Topology import json_topology_id - -LOGGER = logging.getLogger(__name__) -LOGGER.setLevel(logging.DEBUG) def format_grpc_to_json(grpc_reply): return jsonify(grpc_message_to_json(grpc_reply)) -def grpc_connection_id(connection_uuid): - return ConnectionId(**json_connection_id(connection_uuid)) - -def grpc_context_id(context_uuid): - return ContextId(**json_context_id(context_uuid)) - def grpc_device_id(device_uuid): return DeviceId(**json_device_id(device_uuid)) def grpc_device( device_uuid, device_type, status, endpoints=None, config_rules=None, drivers=None ): - json_config_rules = [ json_config_rule( config_rule['action'], @@ -74,49 +53,3 @@ def grpc_device( ] if endpoints else [] return Device(**json_device( device_uuid, device_type, json_status, None, json_endpoints, json_config_rules, json_drivers)) - -def grpc_link_id(link_uuid): - return LinkId(**json_link_id(link_uuid)) - -def grpc_service_id(context_uuid, service_uuid): - return ServiceId(**json_service_id(service_uuid, context_id=json_context_id(context_uuid))) - -def grpc_service( - service_uuid, service_type, context_uuid, status=None, endpoint_ids=None, constraints=None, config_rules=None -): - json_context = json_context_id(context_uuid) - json_status = status if status else ServiceStatusEnum.SERVICESTATUS_PLANNED - json_endpoints_ids = [ - json_endpoint_id( - json_device_id(endpoint_id['device_id']['device_uuid']['uuid']), - endpoint_id['endpoint_uuid']['uuid'] - ) - for endpoint_id in endpoint_ids - ] if endpoint_ids else [] - json_constraints = [ - json_constraint_custom( - constraint['custom']['constraint_type'], - constraint['custom']['constraint_value'] - ) - for constraint in constraints - ] if constraints else [] - json_config_rules = [ - json_config_rule( - config_rule['action'], - config_rule['custom']['resource_key'], - config_rule['custom']['resource_value'] - ) - for config_rule in config_rules - ] if config_rules else [] - return Service(**json_service( - service_uuid, service_type, json_context, json_status, - json_endpoints_ids, json_constraints, json_config_rules)) - -def grpc_slice_id(context_uuid, slice_uuid): - return SliceId(**json_slice_id(slice_uuid, context_id=json_context_id(context_uuid))) - -def grpc_topology_id(context_uuid, topology_uuid): - return TopologyId(**json_topology_id(topology_uuid, context_id=json_context_id(context_uuid))) - -def grpc_policy_rule_id(policy_rule_uuid): - return PolicyRuleId(**json_policyrule_id(policy_rule_uuid)) diff --git a/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py b/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py index 0b85500fc..f28a2ad56 100644 --- a/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py @@ -13,55 +13,16 @@ # limitations under the License. from nbi.service.rest_server.RestServer import RestServer -from .Resources import ( - Connection, ConnectionIds, Connections, - Context, ContextIds, Contexts, - Device, DeviceIds, Devices, - DummyContexts, - Link, LinkIds, Links, - PolicyRule, PolicyRuleIds, PolicyRules, - Service, ServiceIds, Services, - Slice, SliceIds, Slices, - Topologies, Topology, TopologyIds -) +from .Resources import Device, DeviceIds, Devices URL_PREFIX = '/agent-probes' # Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type. RESOURCES = [ # (endpoint_name, resource_class, resource_url) - # ('api.context_ids', ContextIds, '/context_ids'), - # ('api.contexts', Contexts, '/contexts'), - # ('api.dummy_contexts', DummyContexts, '/dummy_contexts'), - # ('api.context', Context, '/context/<path:context_uuid>'), - - # ('api.topology_ids', TopologyIds, '/context/<path:context_uuid>/topology_ids'), - # ('api.topologies', Topologies, '/context/<path:context_uuid>/topologies'), - # ('api.topology', Topology, '/context/<path:context_uuid>/topology/<path:topology_uuid>'), - - # ('api.service_ids', ServiceIds, '/context/<path:context_uuid>/service_ids'), - # ('api.services', Services, '/context/<path:context_uuid>/services'), - # ('api.service', Service, '/context/<path:context_uuid>/service/<path:service_uuid>'), - - # ('api.slice_ids', SliceIds, '/context/<path:context_uuid>/slice_ids'), - # ('api.slices', Slices, '/context/<path:context_uuid>/slices'), - # ('api.slice', Slice, '/context/<path:context_uuid>/slice/<path:slice_uuid>'), - ('api.smartnic.device_ids', DeviceIds, '/device_ids'), ('api.smartnic.devices', Devices, '/devices'), ('api.smartnic.device', Device, '/device/<path:device_uuid>'), - - # ('api.link_ids', LinkIds, '/link_ids'), - # ('api.links', Links, '/links'), - # ('api.link', Link, '/link/<path:link_uuid>'), - - # ('api.connection_ids', ConnectionIds, '/context/<path:context_uuid>/service/<path:service_uuid>/connection_ids'), - # ('api.connections', Connections, '/context/<path:context_uuid>/service/<path:service_uuid>/connections'), - # ('api.connection', Connection, '/connection/<path:connection_uuid>'), - - # ('api.policyrule_ids', PolicyRuleIds, '/policyrule_ids'), - # ('api.policyrules', PolicyRules, '/policyrules'), - # ('api.policyrule', PolicyRule, '/policyrule/<path:policyrule_uuid>'), ] def register_agent_probes(rest_server : RestServer): diff --git a/src/nbi/tests/data/agent_probes_device.json b/src/nbi/tests/data/agent_probes_device.json index e9d931528..6170e88a1 100644 --- a/src/nbi/tests/data/agent_probes_device.json +++ b/src/nbi/tests/data/agent_probes_device.json @@ -24,4 +24,3 @@ ] } - \ No newline at end of file diff --git a/src/policy/Dockerfile b/src/policy/Dockerfile deleted file mode 100644 index 2c6412d07..000000000 --- a/src/policy/Dockerfile +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. - -# Multi-stage Docker image build - -# Stage 1 -FROM maven:3-jdk-11 AS builder - -# Define working directory -WORKDIR /app - -# Copy every file in working directory, as defined in .dockerignore file -COPY ./pom.xml pom.xml -COPY ./src src/ -COPY ./target/generated-sources/ target/generated-sources/ -RUN mvn --errors --batch-mode package -Dmaven.test.skip=true - -# Stage 2 -FROM builder AS unit-test - -RUN mvn --errors --batch-mode -Pgenerate-consolidated-coverage verify - -# Stage 3 -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release - -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' -# Install java and the run-java script -# Also set up permissions for user `1001` -RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ - && microdnf update \ - && microdnf clean all \ - && mkdir /deployments \ - && chown 1001 /deployments \ - && chmod "g+rwX" /deployments \ - && chown 1001:root /deployments \ - && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ - && chown 1001 /deployments/run-java.sh \ - && chmod 540 /deployments/run-java.sh \ - && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security - -# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --from=builder --chown=1001 /app/target/quarkus-app/lib/ /deployments/lib/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/*.jar /deployments/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/app/ /deployments/app/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/quarkus/ /deployments/quarkus/ - -EXPOSE 8080 -EXPOSE 6060 -USER 1001 - -ENTRYPOINT [ "/deployments/run-java.sh" ] diff --git a/src/policy/Dockerfile b/src/policy/Dockerfile new file mode 120000 index 000000000..eec732273 --- /dev/null +++ b/src/policy/Dockerfile @@ -0,0 +1 @@ +src/main/docker/Dockerfile.multistage.jvm \ No newline at end of file diff --git a/src/policy/src/main/proto/acl.proto b/src/policy/src/main/proto/acl.proto deleted file mode 100644 index 3dba735dc..000000000 --- a/src/policy/src/main/proto/acl.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 acl; - -enum AclRuleTypeEnum { - ACLRULETYPE_UNDEFINED = 0; - ACLRULETYPE_IPV4 = 1; - ACLRULETYPE_IPV6 = 2; - ACLRULETYPE_L2 = 3; - ACLRULETYPE_MPLS = 4; - ACLRULETYPE_MIXED = 5; -} - -enum AclForwardActionEnum { - ACLFORWARDINGACTION_UNDEFINED = 0; - ACLFORWARDINGACTION_DROP = 1; - ACLFORWARDINGACTION_ACCEPT = 2; - ACLFORWARDINGACTION_REJECT = 3; -} - -enum AclLogActionEnum { - ACLLOGACTION_UNDEFINED = 0; - ACLLOGACTION_NOLOG = 1; - ACLLOGACTION_SYSLOG = 2; -} - -message AclMatch { - uint32 dscp = 1; - uint32 protocol = 2; - string src_address = 3; - string dst_address = 4; - uint32 src_port = 5; - uint32 dst_port = 6; - uint32 start_mpls_label = 7; - uint32 end_mpls_label = 8; -} - -message AclAction { - AclForwardActionEnum forward_action = 1; - AclLogActionEnum log_action = 2; -} - -message AclEntry { - uint32 sequence_id = 1; - string description = 2; - AclMatch match = 3; - AclAction action = 4; -} - -message AclRuleSet { - string name = 1; - AclRuleTypeEnum type = 2; - string description = 3; - string user_id = 4; - repeated AclEntry entries = 5; -} diff --git a/src/policy/src/main/proto/acl.proto b/src/policy/src/main/proto/acl.proto new file mode 120000 index 000000000..158ae78eb --- /dev/null +++ b/src/policy/src/main/proto/acl.proto @@ -0,0 +1 @@ +../../../../../proto/acl.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/context.proto b/src/policy/src/main/proto/context.proto deleted file mode 100644 index fce1e71ad..000000000 --- a/src/policy/src/main/proto/context.proto +++ /dev/null @@ -1,615 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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; - -import "acl.proto"; -import "kpi_sample_types.proto"; - -service ContextService { - rpc ListContextIds (Empty ) returns ( ContextIdList ) {} - rpc ListContexts (Empty ) returns ( ContextList ) {} - rpc GetContext (ContextId ) returns ( Context ) {} - rpc SetContext (Context ) returns ( ContextId ) {} - rpc RemoveContext (ContextId ) returns ( Empty ) {} - rpc GetContextEvents (Empty ) returns (stream ContextEvent ) {} - - rpc ListTopologyIds (ContextId ) returns ( TopologyIdList ) {} - rpc ListTopologies (ContextId ) returns ( TopologyList ) {} - rpc GetTopology (TopologyId ) returns ( Topology ) {} - rpc GetTopologyDetails (TopologyId ) returns ( TopologyDetails ) {} - rpc SetTopology (Topology ) returns ( TopologyId ) {} - rpc RemoveTopology (TopologyId ) returns ( Empty ) {} - rpc GetTopologyEvents (Empty ) returns (stream TopologyEvent ) {} - - rpc ListDeviceIds (Empty ) returns ( DeviceIdList ) {} - rpc ListDevices (Empty ) returns ( DeviceList ) {} - rpc GetDevice (DeviceId ) returns ( Device ) {} - rpc SetDevice (Device ) returns ( DeviceId ) {} - rpc RemoveDevice (DeviceId ) returns ( Empty ) {} - rpc GetDeviceEvents (Empty ) returns (stream DeviceEvent ) {} - rpc SelectDevice (DeviceFilter ) returns ( DeviceList ) {} - rpc ListEndPointNames (EndPointIdList) returns ( EndPointNameList) {} - - rpc ListLinkIds (Empty ) returns ( LinkIdList ) {} - rpc ListLinks (Empty ) returns ( LinkList ) {} - rpc GetLink (LinkId ) returns ( Link ) {} - rpc SetLink (Link ) returns ( LinkId ) {} - rpc RemoveLink (LinkId ) returns ( Empty ) {} - rpc GetLinkEvents (Empty ) returns (stream LinkEvent ) {} - - rpc ListServiceIds (ContextId ) returns ( ServiceIdList ) {} - rpc ListServices (ContextId ) returns ( ServiceList ) {} - rpc GetService (ServiceId ) returns ( Service ) {} - rpc SetService (Service ) returns ( ServiceId ) {} - rpc UnsetService (Service ) returns ( ServiceId ) {} - rpc RemoveService (ServiceId ) returns ( Empty ) {} - rpc GetServiceEvents (Empty ) returns (stream ServiceEvent ) {} - rpc SelectService (ServiceFilter ) returns ( ServiceList ) {} - - rpc ListSliceIds (ContextId ) returns ( SliceIdList ) {} - rpc ListSlices (ContextId ) returns ( SliceList ) {} - rpc GetSlice (SliceId ) returns ( Slice ) {} - rpc SetSlice (Slice ) returns ( SliceId ) {} - rpc UnsetSlice (Slice ) returns ( SliceId ) {} - rpc RemoveSlice (SliceId ) returns ( Empty ) {} - rpc GetSliceEvents (Empty ) returns (stream SliceEvent ) {} - rpc SelectSlice (SliceFilter ) returns ( SliceList ) {} - - rpc ListConnectionIds (ServiceId ) returns ( ConnectionIdList) {} - rpc ListConnections (ServiceId ) returns ( ConnectionList ) {} - rpc GetConnection (ConnectionId ) returns ( Connection ) {} - rpc SetConnection (Connection ) returns ( ConnectionId ) {} - rpc RemoveConnection (ConnectionId ) returns ( Empty ) {} - rpc GetConnectionEvents(Empty ) returns (stream ConnectionEvent ) {} -} - -// ----- Generic ------------------------------------------------------------------------------------------------------- -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; -} - -// ----- Context ------------------------------------------------------------------------------------------------------- -message ContextId { - Uuid context_uuid = 1; -} - -message Context { - ContextId context_id = 1; - string name = 2; - repeated TopologyId topology_ids = 3; - repeated ServiceId service_ids = 4; - repeated SliceId slice_ids = 5; - TeraFlowController controller = 6; -} - -message ContextIdList { - repeated ContextId context_ids = 1; -} - -message ContextList { - repeated Context contexts = 1; -} - -message ContextEvent { - Event event = 1; - ContextId context_id = 2; -} - - -// ----- Topology ------------------------------------------------------------------------------------------------------ -message TopologyId { - ContextId context_id = 1; - Uuid topology_uuid = 2; -} - -message Topology { - TopologyId topology_id = 1; - string name = 2; - repeated DeviceId device_ids = 3; - repeated LinkId link_ids = 4; -} - -message TopologyDetails { - TopologyId topology_id = 1; - string name = 2; - repeated Device devices = 3; - repeated Link links = 4; -} - -message TopologyIdList { - repeated TopologyId topology_ids = 1; -} - -message TopologyList { - repeated Topology topologies = 1; -} - -message TopologyEvent { - Event event = 1; - TopologyId topology_id = 2; -} - - -// ----- Device -------------------------------------------------------------------------------------------------------- -message DeviceId { - Uuid device_uuid = 1; -} - -message Device { - DeviceId device_id = 1; - string name = 2; - string device_type = 3; - DeviceConfig device_config = 4; - DeviceOperationalStatusEnum device_operational_status = 5; - repeated DeviceDriverEnum device_drivers = 6; - repeated EndPoint device_endpoints = 7; - repeated Component components = 8; // Used for inventory - DeviceId controller_id = 9; // Identifier of node controlling the actual device -} - -message Component { //Defined previously to this section - Tested OK - Uuid component_uuid = 1; - string name = 2; - string type = 3; - - map<string, string> attributes = 4; // dict[attr.name => json.dumps(attr.value)] - string parent = 5; -} - -message DeviceConfig { - repeated ConfigRule config_rules = 1; -} - -enum DeviceDriverEnum { - DEVICEDRIVER_UNDEFINED = 0; // also used for emulated - DEVICEDRIVER_OPENCONFIG = 1; - DEVICEDRIVER_TRANSPORT_API = 2; - DEVICEDRIVER_P4 = 3; - DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4; - DEVICEDRIVER_ONF_TR_532 = 5; - DEVICEDRIVER_XR = 6; - DEVICEDRIVER_IETF_L2VPN = 7; - DEVICEDRIVER_GNMI_OPENCONFIG = 8; - DEVICEDRIVER_FLEXSCALE = 9; - DEVICEDRIVER_IETF_ACTN = 10; - DEVICEDRIVER_SMARTNIC = 11; -} - -enum DeviceOperationalStatusEnum { - DEVICEOPERATIONALSTATUS_UNDEFINED = 0; - DEVICEOPERATIONALSTATUS_DISABLED = 1; - DEVICEOPERATIONALSTATUS_ENABLED = 2; -} - -message DeviceIdList { - repeated DeviceId device_ids = 1; -} - -message DeviceList { - repeated Device devices = 1; -} - -message DeviceFilter { - DeviceIdList device_ids = 1; - bool include_endpoints = 2; - bool include_config_rules = 3; - bool include_components = 4; -} - -message DeviceEvent { - Event event = 1; - DeviceId device_id = 2; - DeviceConfig device_config = 3; -} - - -// ----- Link ---------------------------------------------------------------------------------------------------------- -message LinkId { - Uuid link_uuid = 1; -} - -message LinkAttributes { - float total_capacity_gbps = 1; - float used_capacity_gbps = 2; -} - -message Link { - LinkId link_id = 1; - string name = 2; - repeated EndPointId link_endpoint_ids = 3; - LinkAttributes attributes = 4; -} - -message LinkIdList { - repeated LinkId link_ids = 1; -} - -message LinkList { - repeated Link links = 1; -} - -message LinkEvent { - Event event = 1; - LinkId link_id = 2; -} - - -// ----- Service ------------------------------------------------------------------------------------------------------- -message ServiceId { - ContextId context_id = 1; - Uuid service_uuid = 2; -} - -message Service { - ServiceId service_id = 1; - string name = 2; - ServiceTypeEnum service_type = 3; - repeated EndPointId service_endpoint_ids = 4; - repeated Constraint service_constraints = 5; - ServiceStatus service_status = 6; - ServiceConfig service_config = 7; - Timestamp timestamp = 8; -} - -enum ServiceTypeEnum { - SERVICETYPE_UNKNOWN = 0; - SERVICETYPE_L3NM = 1; - SERVICETYPE_L2NM = 2; - SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; - SERVICETYPE_TE = 4; - SERVICETYPE_E2E = 5; -} - -enum ServiceStatusEnum { - SERVICESTATUS_UNDEFINED = 0; - SERVICESTATUS_PLANNED = 1; - SERVICESTATUS_ACTIVE = 2; - SERVICESTATUS_UPDATING = 3; - SERVICESTATUS_PENDING_REMOVAL = 4; - SERVICESTATUS_SLA_VIOLATED = 5; -} - -message ServiceStatus { - ServiceStatusEnum service_status = 1; -} - -message ServiceConfig { - repeated ConfigRule config_rules = 1; -} - -message ServiceIdList { - repeated ServiceId service_ids = 1; -} - -message ServiceList { - repeated Service services = 1; -} - -message ServiceFilter { - ServiceIdList service_ids = 1; - bool include_endpoint_ids = 2; - bool include_constraints = 3; - bool include_config_rules = 4; -} - -message ServiceEvent { - Event event = 1; - ServiceId service_id = 2; -} - -// ----- Slice --------------------------------------------------------------------------------------------------------- -message SliceId { - ContextId context_id = 1; - Uuid slice_uuid = 2; -} - -message Slice { - SliceId slice_id = 1; - string name = 2; - repeated EndPointId slice_endpoint_ids = 3; - repeated Constraint slice_constraints = 4; - repeated ServiceId slice_service_ids = 5; - repeated SliceId slice_subslice_ids = 6; - SliceStatus slice_status = 7; - SliceConfig slice_config = 8; - SliceOwner slice_owner = 9; - Timestamp timestamp = 10; -} - -message SliceOwner { - Uuid owner_uuid = 1; - string owner_string = 2; -} - -enum SliceStatusEnum { - SLICESTATUS_UNDEFINED = 0; - SLICESTATUS_PLANNED = 1; - SLICESTATUS_INIT = 2; - SLICESTATUS_ACTIVE = 3; - SLICESTATUS_DEINIT = 4; - SLICESTATUS_SLA_VIOLATED = 5; -} - -message SliceStatus { - SliceStatusEnum slice_status = 1; -} - -message SliceConfig { - repeated ConfigRule config_rules = 1; -} - -message SliceIdList { - repeated SliceId slice_ids = 1; -} - -message SliceList { - repeated Slice slices = 1; -} - -message SliceFilter { - SliceIdList slice_ids = 1; - bool include_endpoint_ids = 2; - bool include_constraints = 3; - bool include_service_ids = 4; - bool include_subslice_ids = 5; - bool include_config_rules = 6; -} - -message SliceEvent { - Event event = 1; - SliceId slice_id = 2; -} - -// ----- Connection ---------------------------------------------------------------------------------------------------- -message ConnectionId { - Uuid connection_uuid = 1; -} - -message ConnectionSettings_L0 { - string lsp_symbolic_name = 1; -} - -message ConnectionSettings_L2 { - string src_mac_address = 1; - string dst_mac_address = 2; - uint32 ether_type = 3; - uint32 vlan_id = 4; - uint32 mpls_label = 5; - uint32 mpls_traffic_class = 6; -} - -message ConnectionSettings_L3 { - string src_ip_address = 1; - string dst_ip_address = 2; - uint32 dscp = 3; - uint32 protocol = 4; - uint32 ttl = 5; -} - -message ConnectionSettings_L4 { - uint32 src_port = 1; - uint32 dst_port = 2; - uint32 tcp_flags = 3; - uint32 ttl = 4; -} - -message ConnectionSettings { - ConnectionSettings_L0 l0 = 1; - ConnectionSettings_L2 l2 = 2; - ConnectionSettings_L3 l3 = 3; - ConnectionSettings_L4 l4 = 4; -} - -message Connection { - ConnectionId connection_id = 1; - ServiceId service_id = 2; - repeated EndPointId path_hops_endpoint_ids = 3; - repeated ServiceId sub_service_ids = 4; - ConnectionSettings settings = 5; -} - -message ConnectionIdList { - repeated ConnectionId connection_ids = 1; -} - -message ConnectionList { - repeated Connection connections = 1; -} - -message ConnectionEvent { - Event event = 1; - ConnectionId connection_id = 2; -} - - -// ----- Endpoint ------------------------------------------------------------------------------------------------------ -message EndPointId { - TopologyId topology_id = 1; - DeviceId device_id = 2; - Uuid endpoint_uuid = 3; -} - -message EndPoint { - EndPointId endpoint_id = 1; - string name = 2; - string endpoint_type = 3; - repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; - Location endpoint_location = 5; -} - -message EndPointName { - EndPointId endpoint_id = 1; - string device_name = 2; - string endpoint_name = 3; - string endpoint_type = 4; -} - -message EndPointIdList { - repeated EndPointId endpoint_ids = 1; -} - -message EndPointNameList { - repeated EndPointName endpoint_names = 1; -} - - -// ----- Configuration ------------------------------------------------------------------------------------------------- -enum ConfigActionEnum { - CONFIGACTION_UNDEFINED = 0; - CONFIGACTION_SET = 1; - CONFIGACTION_DELETE = 2; -} - -message ConfigRule_Custom { - string resource_key = 1; - string resource_value = 2; -} - -message ConfigRule_ACL { - EndPointId endpoint_id = 1; - acl.AclRuleSet rule_set = 2; -} - -message ConfigRule { - ConfigActionEnum action = 1; - oneof config_rule { - ConfigRule_Custom custom = 2; - ConfigRule_ACL acl = 3; - } -} - - -// ----- Constraint ---------------------------------------------------------------------------------------------------- -enum ConstraintActionEnum { - CONSTRAINTACTION_UNDEFINED = 0; - CONSTRAINTACTION_SET = 1; - CONSTRAINTACTION_DELETE = 2; -} - -message Constraint_Custom { - string constraint_type = 1; - string constraint_value = 2; -} - -message Constraint_Schedule { - float start_timestamp = 1; - float duration_days = 2; -} - -message GPS_Position { - float latitude = 1; - float longitude = 2; -} - -message Location { - oneof location { - string region = 1; - GPS_Position gps_position = 2; - } -} - -message Constraint_EndPointLocation { - EndPointId endpoint_id = 1; - Location location = 2; -} - -message Constraint_EndPointPriority { - EndPointId endpoint_id = 1; - uint32 priority = 2; -} - -message Constraint_SLA_Latency { - float e2e_latency_ms = 1; -} - -message Constraint_SLA_Capacity { - float capacity_gbps = 1; -} - -message Constraint_SLA_Availability { - uint32 num_disjoint_paths = 1; - bool all_active = 2; - float availability = 3; // 0.0 .. 100.0 percentage of availability -} - -enum IsolationLevelEnum { - NO_ISOLATION = 0; - PHYSICAL_ISOLATION = 1; - LOGICAL_ISOLATION = 2; - PROCESS_ISOLATION = 3; - PHYSICAL_MEMORY_ISOLATION = 4; - PHYSICAL_NETWORK_ISOLATION = 5; - VIRTUAL_RESOURCE_ISOLATION = 6; - NETWORK_FUNCTIONS_ISOLATION = 7; - SERVICE_ISOLATION = 8; -} - -message Constraint_SLA_Isolation_level { - repeated IsolationLevelEnum isolation_level = 1; -} - -message Constraint_Exclusions { - bool is_permanent = 1; - repeated DeviceId device_ids = 2; - repeated EndPointId endpoint_ids = 3; - repeated LinkId link_ids = 4; -} - -message Constraint { - ConstraintActionEnum action = 1; - oneof constraint { - Constraint_Custom custom = 2; - Constraint_Schedule schedule = 3; - Constraint_EndPointLocation endpoint_location = 4; - Constraint_EndPointPriority endpoint_priority = 5; - Constraint_SLA_Capacity sla_capacity = 6; - Constraint_SLA_Latency sla_latency = 7; - Constraint_SLA_Availability sla_availability = 8; - Constraint_SLA_Isolation_level sla_isolation = 9; - Constraint_Exclusions exclusions = 10; - } -} - - -// ----- Miscellaneous ------------------------------------------------------------------------------------------------- -message TeraFlowController { - ContextId context_id = 1; - string ip_address = 2; - uint32 port = 3; -} - -message AuthenticationResult { - ContextId context_id = 1; - bool authenticated = 2; -} diff --git a/src/policy/src/main/proto/context.proto b/src/policy/src/main/proto/context.proto new file mode 120000 index 000000000..7f33c4bc7 --- /dev/null +++ b/src/policy/src/main/proto/context.proto @@ -0,0 +1 @@ +../../../../../proto/context.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/context_policy.proto b/src/policy/src/main/proto/context_policy.proto deleted file mode 100644 index f6dae4830..000000000 --- a/src/policy/src/main/proto/context_policy.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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_policy; - -import "context.proto"; -import "policy.proto"; - -// created as a separate service to prevent import-loops in context and policy -service ContextPolicyService { - rpc ListPolicyRuleIds(context.Empty ) returns (policy.PolicyRuleIdList) {} - rpc ListPolicyRules (context.Empty ) returns (policy.PolicyRuleList ) {} - rpc GetPolicyRule (policy.PolicyRuleId ) returns (policy.PolicyRule ) {} - rpc SetPolicyRule (policy.PolicyRule ) returns (policy.PolicyRuleId ) {} - rpc RemovePolicyRule (policy.PolicyRuleId ) returns (context.Empty ) {} -} diff --git a/src/policy/src/main/proto/context_policy.proto b/src/policy/src/main/proto/context_policy.proto new file mode 120000 index 000000000..d41593dde --- /dev/null +++ b/src/policy/src/main/proto/context_policy.proto @@ -0,0 +1 @@ +../../../../../proto/context_policy.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/device.proto b/src/policy/src/main/proto/device.proto deleted file mode 100644 index 30e60079d..000000000 --- a/src/policy/src/main/proto/device.proto +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 device; - -import "context.proto"; -import "monitoring.proto"; - -service DeviceService { - rpc AddDevice (context.Device ) returns (context.DeviceId ) {} - rpc ConfigureDevice (context.Device ) returns (context.DeviceId ) {} - rpc DeleteDevice (context.DeviceId ) returns (context.Empty ) {} - rpc GetInitialConfig(context.DeviceId ) returns (context.DeviceConfig) {} - rpc MonitorDeviceKpi(MonitoringSettings) returns (context.Empty ) {} -} - -message MonitoringSettings { - monitoring.KpiId kpi_id = 1; - monitoring.KpiDescriptor kpi_descriptor = 2; - float sampling_duration_s = 3; - float sampling_interval_s = 4; -} diff --git a/src/policy/src/main/proto/device.proto b/src/policy/src/main/proto/device.proto new file mode 120000 index 000000000..ad6e7c47e --- /dev/null +++ b/src/policy/src/main/proto/device.proto @@ -0,0 +1 @@ +../../../../../proto/device.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/kpi_sample_types.proto b/src/policy/src/main/proto/kpi_sample_types.proto deleted file mode 100644 index 5b234a4e3..000000000 --- a/src/policy/src/main/proto/kpi_sample_types.proto +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 kpi_sample_types; - -enum KpiSampleType { - KPISAMPLETYPE_UNKNOWN = 0; - - KPISAMPLETYPE_PACKETS_TRANSMITTED = 101; - KPISAMPLETYPE_PACKETS_RECEIVED = 102; - KPISAMPLETYPE_PACKETS_DROPPED = 103; - KPISAMPLETYPE_BYTES_TRANSMITTED = 201; - KPISAMPLETYPE_BYTES_RECEIVED = 202; - KPISAMPLETYPE_BYTES_DROPPED = 203; - - KPISAMPLETYPE_LINK_TOTAL_CAPACITY_GBPS = 301; - KPISAMPLETYPE_LINK_USED_CAPACITY_GBPS = 302; - - KPISAMPLETYPE_ML_CONFIDENCE = 401; //. can be used by both optical and L3 without any issue - - KPISAMPLETYPE_OPTICAL_SECURITY_STATUS = 501; //. can be used by both optical and L3 without any issue - - KPISAMPLETYPE_L3_UNIQUE_ATTACK_CONNS = 601; - KPISAMPLETYPE_L3_TOTAL_DROPPED_PACKTS = 602; - KPISAMPLETYPE_L3_UNIQUE_ATTACKERS = 603; - KPISAMPLETYPE_L3_UNIQUE_COMPROMISED_CLIENTS = 604; - KPISAMPLETYPE_L3_SECURITY_STATUS_CRYPTO = 605; - - KPISAMPLETYPE_SERVICE_LATENCY_MS = 701; -} diff --git a/src/policy/src/main/proto/kpi_sample_types.proto b/src/policy/src/main/proto/kpi_sample_types.proto new file mode 120000 index 000000000..98e748bbf --- /dev/null +++ b/src/policy/src/main/proto/kpi_sample_types.proto @@ -0,0 +1 @@ +../../../../../proto/kpi_sample_types.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/monitoring.proto b/src/policy/src/main/proto/monitoring.proto deleted file mode 100644 index 45ba48b02..000000000 --- a/src/policy/src/main/proto/monitoring.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 monitoring; - -import "context.proto"; -import "kpi_sample_types.proto"; - -service MonitoringService { - rpc SetKpi (KpiDescriptor ) returns (KpiId ) {} // Stable not final - rpc DeleteKpi (KpiId ) returns (context.Empty ) {} // Stable and final - rpc GetKpiDescriptor (KpiId ) returns (KpiDescriptor ) {} // Stable and final - rpc GetKpiDescriptorList (context.Empty ) returns (KpiDescriptorList ) {} // Stable and final - rpc IncludeKpi (Kpi ) returns (context.Empty ) {} // Stable and final - rpc MonitorKpi (MonitorKpiRequest ) returns (context.Empty ) {} // Stable and final - rpc QueryKpiData (KpiQuery ) returns (RawKpiTable ) {} // Not implemented - rpc SetKpiSubscription (SubsDescriptor ) returns (stream SubsResponse ) {} // Stable not final - rpc GetSubsDescriptor (SubscriptionID ) returns (SubsDescriptor ) {} // Stable and final - rpc GetSubscriptions (context.Empty ) returns (SubsList ) {} // Stable and final - rpc DeleteSubscription (SubscriptionID ) returns (context.Empty ) {} // Stable and final - rpc SetKpiAlarm (AlarmDescriptor ) returns (AlarmID ) {} // Stable not final - rpc GetAlarms (context.Empty ) returns (AlarmList ) {} // Stable and final - rpc GetAlarmDescriptor (AlarmID ) returns (AlarmDescriptor ) {} // Stable and final - rpc GetAlarmResponseStream(AlarmSubscription ) returns (stream AlarmResponse) {} // Not Stable not final - rpc DeleteAlarm (AlarmID ) returns (context.Empty ) {} // Stable and final - rpc GetStreamKpi (KpiId ) returns (stream Kpi ) {} // Stable not final - rpc GetInstantKpi (KpiId ) returns (Kpi ) {} // Stable not final -} - -message KpiDescriptor { - KpiId kpi_id = 1; - string kpi_description = 2; - repeated KpiId kpi_id_list = 3; - kpi_sample_types.KpiSampleType kpi_sample_type = 4; - context.DeviceId device_id = 5; - context.EndPointId endpoint_id = 6; - context.ServiceId service_id = 7; - context.SliceId slice_id = 8; - context.ConnectionId connection_id = 9; - context.LinkId link_id = 10; -} - -message MonitorKpiRequest { - KpiId kpi_id = 1; - float monitoring_window_s = 2; - float sampling_rate_s = 3; - // Pending add field to reflect Available Device Protocols -} - -message KpiQuery { - repeated KpiId kpi_ids = 1; - float monitoring_window_s = 2; - uint32 last_n_samples = 3; // used when you want something like "get the last N many samples - context.Timestamp start_timestamp = 4; // used when you want something like "get the samples since X date/time" - context.Timestamp end_timestamp = 5; // used when you want something like "get the samples until X date/time" -} - - -message RawKpi { // cell - context.Timestamp timestamp = 1; - KpiValue kpi_value = 2; -} - -message RawKpiList { // column - KpiId kpi_id = 1; - repeated RawKpi raw_kpis = 2; -} - -message RawKpiTable { // table - repeated RawKpiList raw_kpi_lists = 1; -} - -message KpiId { - context.Uuid kpi_id = 1; -} - -message Kpi { - KpiId kpi_id = 1; - context.Timestamp timestamp = 2; - KpiValue kpi_value = 3; -} - -message KpiValueRange { - KpiValue kpiMinValue = 1; - KpiValue kpiMaxValue = 2; - bool inRange = 3; // by default True - bool includeMinValue = 4; // False is outside the interval - bool includeMaxValue = 5; // False is outside the interval -} - -message KpiValue { - oneof value { - int32 int32Val = 1; - uint32 uint32Val = 2; - int64 int64Val = 3; - uint64 uint64Val = 4; - float floatVal = 5; - string stringVal = 6; - bool boolVal = 7; - } -} - - -message KpiList { - repeated Kpi kpi = 1; -} - -message KpiDescriptorList { - repeated KpiDescriptor kpi_descriptor_list = 1; -} - -message SubsDescriptor{ - SubscriptionID subs_id = 1; - KpiId kpi_id = 2; - float sampling_duration_s = 3; - float sampling_interval_s = 4; - context.Timestamp start_timestamp = 5; // used when you want something like "get the samples since X date/time" - context.Timestamp end_timestamp = 6; // used when you want something like "get the samples until X date/time" - // Pending add field to reflect Available Device Protocols -} - -message SubscriptionID { - context.Uuid subs_id = 1; -} - -message SubsResponse { - SubscriptionID subs_id = 1; - KpiList kpi_list = 2; -} - -message SubsList { - repeated SubsDescriptor subs_descriptor = 1; -} - -message AlarmDescriptor { - AlarmID alarm_id = 1; - string alarm_description = 2; - string name = 3; - KpiId kpi_id = 4; - KpiValueRange kpi_value_range = 5; - context.Timestamp timestamp = 6; -} - -message AlarmID{ - context.Uuid alarm_id = 1; -} - -message AlarmSubscription{ - AlarmID alarm_id = 1; - float subscription_timeout_s = 2; - float subscription_frequency_ms = 3; -} - -message AlarmResponse { - AlarmID alarm_id = 1; - string text = 2; - KpiList kpi_list = 3; -} - -message AlarmList { - repeated AlarmDescriptor alarm_descriptor = 1; -} diff --git a/src/policy/src/main/proto/monitoring.proto b/src/policy/src/main/proto/monitoring.proto new file mode 120000 index 000000000..aceaa7328 --- /dev/null +++ b/src/policy/src/main/proto/monitoring.proto @@ -0,0 +1 @@ +../../../../../proto/monitoring.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy.proto b/src/policy/src/main/proto/policy.proto deleted file mode 100644 index a6f160150..000000000 --- a/src/policy/src/main/proto/policy.proto +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; - -import "context.proto"; -import "policy_condition.proto"; -import "policy_action.proto"; - -service PolicyService { - rpc PolicyAddService (PolicyRuleService) returns (PolicyRuleState) {} - rpc PolicyAddDevice (PolicyRuleDevice) returns (PolicyRuleState) {} - rpc PolicyUpdateService (PolicyRuleService) returns (PolicyRuleState) {} - rpc PolicyUpdateDevice (PolicyRuleDevice) returns (PolicyRuleState) {} - rpc PolicyDelete (PolicyRuleId) returns (PolicyRuleState) {} - rpc GetPolicyService (PolicyRuleId) returns (PolicyRuleService) {} - rpc GetPolicyDevice (PolicyRuleId) returns (PolicyRuleDevice) {} - rpc GetPolicyByServiceId (context.ServiceId) returns (PolicyRuleServiceList) {} -} - -enum PolicyRuleStateEnum { - POLICY_UNDEFINED = 0; // Undefined rule state - POLICY_FAILED = 1; // Rule failed - POLICY_INSERTED = 2; // Rule is just inserted - POLICY_VALIDATED = 3; // Rule content is correct - POLICY_PROVISIONED = 4; // Rule subscribed to Monitoring - POLICY_ACTIVE = 5; // Rule is currently active (alarm is just thrown by Monitoring) - POLICY_ENFORCED = 6; // Rule action is successfully enforced - POLICY_INEFFECTIVE = 7; // The applied rule action did not work as expected - POLICY_EFFECTIVE = 8; // The applied rule action did work as expected - POLICY_UPDATED = 9; // Operator requires a policy to change - POLICY_REMOVED = 10; // Operator requires to remove a policy -} - -message PolicyRuleId { - context.Uuid uuid = 1; -} - -message PolicyRuleState { - PolicyRuleStateEnum policyRuleState = 1; - string policyRuleStateMessage = 2; -} - -// Basic policy rule attributes -message PolicyRuleBasic { - PolicyRuleId policyRuleId = 1; - PolicyRuleState policyRuleState = 2; //policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. - uint32 priority = 3; - - // Event-Condition-Action (ECA) model - repeated PolicyRuleCondition conditionList = 4; // When these policy conditions are met, an event is automatically thrown - BooleanOperator booleanOperator = 5; // Evaluation operator to be used - repeated PolicyRuleAction actionList = 6; // One or more actions should be applied -} - -// Service-oriented policy rule -message PolicyRuleService { - // Basic policy rule attributes - PolicyRuleBasic policyRuleBasic = 1; - - // Affected service and (some of) its device(s) - context.ServiceId serviceId = 2; - repeated context.DeviceId deviceList = 3; // List of devices this service is traversing (not exhaustive) -} - -// Device-oriented policy rule -message PolicyRuleDevice { - // Basic policy rule attributes - PolicyRuleBasic policyRuleBasic = 1; - - // Affected device(s) - repeated context.DeviceId deviceList = 2; -} - -// Wrapper policy rule object -message PolicyRule { - oneof policy_rule { - PolicyRuleService service = 1; - PolicyRuleDevice device = 2; - } -} - -// A list of policy rule IDs -message PolicyRuleIdList { - repeated PolicyRuleId policyRuleIdList = 1; -} - -// A list of service-oriented policy rules -message PolicyRuleServiceList { - repeated PolicyRuleService policyRuleServiceList = 1; -} - -// A list of device-oriented policy rules -message PolicyRuleDeviceList { - repeated PolicyRuleDevice policyRuleDeviceList = 1; -} - -// A list of policy rules -message PolicyRuleList { - repeated PolicyRule policyRules = 1; -} diff --git a/src/policy/src/main/proto/policy.proto b/src/policy/src/main/proto/policy.proto new file mode 120000 index 000000000..df455f961 --- /dev/null +++ b/src/policy/src/main/proto/policy.proto @@ -0,0 +1 @@ +../../../../../proto/policy.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy_action.proto b/src/policy/src/main/proto/policy_action.proto deleted file mode 100644 index d547e9779..000000000 --- a/src/policy/src/main/proto/policy_action.proto +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; - -// Action -message PolicyRuleAction { - PolicyRuleActionEnum action = 1; - repeated PolicyRuleActionConfig action_config = 2; -} - -enum PolicyRuleActionEnum { - POLICYRULE_ACTION_NO_ACTION = 0; - POLICYRULE_ACTION_SET_DEVICE_STATUS = 1; - POLICYRULE_ACTION_ADD_SERVICE_CONFIGRULE = 2; - POLICYRULE_ACTION_ADD_SERVICE_CONSTRAINT = 3; - POLICY_RULE_ACTION_CALL_SERVICE_RPC = 4; - POLICY_RULE_ACTION_RECALCULATE_PATH = 5; -} - -// Action configuration -message PolicyRuleActionConfig { - string action_key = 1; - string action_value = 2; -} - -// message PolicyRuleAction { -// PolicyRuleActionEnum action = 1; -// repeated string parameters = 2; -// } diff --git a/src/policy/src/main/proto/policy_action.proto b/src/policy/src/main/proto/policy_action.proto new file mode 120000 index 000000000..63dcef3d2 --- /dev/null +++ b/src/policy/src/main/proto/policy_action.proto @@ -0,0 +1 @@ +../../../../../proto/policy_action.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/policy_condition.proto b/src/policy/src/main/proto/policy_condition.proto deleted file mode 100644 index 2037af93c..000000000 --- a/src/policy/src/main/proto/policy_condition.proto +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 policy; - -import "monitoring.proto"; - -// Condition -message PolicyRuleCondition { - monitoring.KpiId kpiId = 1; - NumericalOperator numericalOperator = 2; - monitoring.KpiValue kpiValue = 3; -} - -// Operator to be used when comparing Kpis with condition values -enum NumericalOperator { - POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0; // Kpi numerical operator undefined - POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1; // Kpi is equal with value - POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2; // Kpi is not equal with value - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3; // Kpi is less than value - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4; // Kpi is less than or equal with value - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5; // Kpi is greater than value - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; // Kpi is less than or equal with value -} - -// Operator to be used when evaluating each condition -enum BooleanOperator { - POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0; // Boolean operator undefined - POLICYRULE_CONDITION_BOOLEAN_AND = 1; // Boolean AND operator - POLICYRULE_CONDITION_BOOLEAN_OR = 2; // Boolean OR operator -} \ No newline at end of file diff --git a/src/policy/src/main/proto/policy_condition.proto b/src/policy/src/main/proto/policy_condition.proto new file mode 120000 index 000000000..31f7d9d10 --- /dev/null +++ b/src/policy/src/main/proto/policy_condition.proto @@ -0,0 +1 @@ +../../../../../proto/policy_condition.proto \ No newline at end of file diff --git a/src/policy/src/main/proto/service.proto b/src/policy/src/main/proto/service.proto deleted file mode 100644 index 658859e3c..000000000 --- a/src/policy/src/main/proto/service.proto +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 service; - -import "context.proto"; - -service ServiceService { - rpc CreateService (context.Service ) returns (context.ServiceId) {} - rpc UpdateService (context.Service ) returns (context.ServiceId) {} - rpc DeleteService (context.ServiceId) returns (context.Empty ) {} - rpc RecomputeConnections(context.Service ) returns (context.Empty ) {} -} diff --git a/src/policy/src/main/proto/service.proto b/src/policy/src/main/proto/service.proto new file mode 120000 index 000000000..5ca543da0 --- /dev/null +++ b/src/policy/src/main/proto/service.proto @@ -0,0 +1 @@ +../../../../../proto/service.proto \ No newline at end of file diff --git a/src/ztp/Dockerfile b/src/ztp/Dockerfile deleted file mode 100644 index 43fef96b4..000000000 --- a/src/ztp/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. - -# Multi-stage Docker image build - -# Stage 1 -FROM maven:3-jdk-11 AS builder - -# Define working directory -WORKDIR /app - -# Copy every file in working directory, as defined in .dockerignore file -COPY ./pom.xml pom.xml -COPY ./src src/ -COPY ./target/generated-sources/ target/generated-sources/ -RUN mvn --errors --batch-mode package -Dmaven.test.skip=true - -# Stage 2 -FROM builder AS unit-test - -RUN mvn --errors --batch-mode -Pgenerate-consolidated-coverage verify - -# Stage 3 -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4 AS release - -ARG JAVA_PACKAGE=java-11-openjdk-headless -ARG RUN_JAVA_VERSION=1.3.8 -ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' -# Install java and the run-java script -# Also set up permissions for user `1001` -RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ - && microdnf update \ - && microdnf clean all \ - && mkdir /deployments \ - && chown 1001 /deployments \ - && chmod "g+rwX" /deployments \ - && chown 1001:root /deployments \ - && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ - && chown 1001 /deployments/run-java.sh \ - && chmod 540 /deployments/run-java.sh \ - && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security - -# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --from=builder --chown=1001 /app/target/quarkus-app/lib/ /deployments/lib/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/*.jar /deployments/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/app/ /deployments/app/ -COPY --from=builder --chown=1001 /app/target/quarkus-app/quarkus/ /deployments/quarkus/ - -EXPOSE 8080 -EXPOSE 5050 -USER 1001 - -ENTRYPOINT [ "/deployments/run-java.sh" ] - diff --git a/src/ztp/Dockerfile b/src/ztp/Dockerfile new file mode 120000 index 000000000..eec732273 --- /dev/null +++ b/src/ztp/Dockerfile @@ -0,0 +1 @@ +src/main/docker/Dockerfile.multistage.jvm \ No newline at end of file diff --git a/src/ztp/src/main/proto/acl.proto b/src/ztp/src/main/proto/acl.proto deleted file mode 100644 index 3dba735dc..000000000 --- a/src/ztp/src/main/proto/acl.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 acl; - -enum AclRuleTypeEnum { - ACLRULETYPE_UNDEFINED = 0; - ACLRULETYPE_IPV4 = 1; - ACLRULETYPE_IPV6 = 2; - ACLRULETYPE_L2 = 3; - ACLRULETYPE_MPLS = 4; - ACLRULETYPE_MIXED = 5; -} - -enum AclForwardActionEnum { - ACLFORWARDINGACTION_UNDEFINED = 0; - ACLFORWARDINGACTION_DROP = 1; - ACLFORWARDINGACTION_ACCEPT = 2; - ACLFORWARDINGACTION_REJECT = 3; -} - -enum AclLogActionEnum { - ACLLOGACTION_UNDEFINED = 0; - ACLLOGACTION_NOLOG = 1; - ACLLOGACTION_SYSLOG = 2; -} - -message AclMatch { - uint32 dscp = 1; - uint32 protocol = 2; - string src_address = 3; - string dst_address = 4; - uint32 src_port = 5; - uint32 dst_port = 6; - uint32 start_mpls_label = 7; - uint32 end_mpls_label = 8; -} - -message AclAction { - AclForwardActionEnum forward_action = 1; - AclLogActionEnum log_action = 2; -} - -message AclEntry { - uint32 sequence_id = 1; - string description = 2; - AclMatch match = 3; - AclAction action = 4; -} - -message AclRuleSet { - string name = 1; - AclRuleTypeEnum type = 2; - string description = 3; - string user_id = 4; - repeated AclEntry entries = 5; -} diff --git a/src/ztp/src/main/proto/acl.proto b/src/ztp/src/main/proto/acl.proto new file mode 120000 index 000000000..158ae78eb --- /dev/null +++ b/src/ztp/src/main/proto/acl.proto @@ -0,0 +1 @@ +../../../../../proto/acl.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/context.proto b/src/ztp/src/main/proto/context.proto deleted file mode 100644 index fce1e71ad..000000000 --- a/src/ztp/src/main/proto/context.proto +++ /dev/null @@ -1,615 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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; - -import "acl.proto"; -import "kpi_sample_types.proto"; - -service ContextService { - rpc ListContextIds (Empty ) returns ( ContextIdList ) {} - rpc ListContexts (Empty ) returns ( ContextList ) {} - rpc GetContext (ContextId ) returns ( Context ) {} - rpc SetContext (Context ) returns ( ContextId ) {} - rpc RemoveContext (ContextId ) returns ( Empty ) {} - rpc GetContextEvents (Empty ) returns (stream ContextEvent ) {} - - rpc ListTopologyIds (ContextId ) returns ( TopologyIdList ) {} - rpc ListTopologies (ContextId ) returns ( TopologyList ) {} - rpc GetTopology (TopologyId ) returns ( Topology ) {} - rpc GetTopologyDetails (TopologyId ) returns ( TopologyDetails ) {} - rpc SetTopology (Topology ) returns ( TopologyId ) {} - rpc RemoveTopology (TopologyId ) returns ( Empty ) {} - rpc GetTopologyEvents (Empty ) returns (stream TopologyEvent ) {} - - rpc ListDeviceIds (Empty ) returns ( DeviceIdList ) {} - rpc ListDevices (Empty ) returns ( DeviceList ) {} - rpc GetDevice (DeviceId ) returns ( Device ) {} - rpc SetDevice (Device ) returns ( DeviceId ) {} - rpc RemoveDevice (DeviceId ) returns ( Empty ) {} - rpc GetDeviceEvents (Empty ) returns (stream DeviceEvent ) {} - rpc SelectDevice (DeviceFilter ) returns ( DeviceList ) {} - rpc ListEndPointNames (EndPointIdList) returns ( EndPointNameList) {} - - rpc ListLinkIds (Empty ) returns ( LinkIdList ) {} - rpc ListLinks (Empty ) returns ( LinkList ) {} - rpc GetLink (LinkId ) returns ( Link ) {} - rpc SetLink (Link ) returns ( LinkId ) {} - rpc RemoveLink (LinkId ) returns ( Empty ) {} - rpc GetLinkEvents (Empty ) returns (stream LinkEvent ) {} - - rpc ListServiceIds (ContextId ) returns ( ServiceIdList ) {} - rpc ListServices (ContextId ) returns ( ServiceList ) {} - rpc GetService (ServiceId ) returns ( Service ) {} - rpc SetService (Service ) returns ( ServiceId ) {} - rpc UnsetService (Service ) returns ( ServiceId ) {} - rpc RemoveService (ServiceId ) returns ( Empty ) {} - rpc GetServiceEvents (Empty ) returns (stream ServiceEvent ) {} - rpc SelectService (ServiceFilter ) returns ( ServiceList ) {} - - rpc ListSliceIds (ContextId ) returns ( SliceIdList ) {} - rpc ListSlices (ContextId ) returns ( SliceList ) {} - rpc GetSlice (SliceId ) returns ( Slice ) {} - rpc SetSlice (Slice ) returns ( SliceId ) {} - rpc UnsetSlice (Slice ) returns ( SliceId ) {} - rpc RemoveSlice (SliceId ) returns ( Empty ) {} - rpc GetSliceEvents (Empty ) returns (stream SliceEvent ) {} - rpc SelectSlice (SliceFilter ) returns ( SliceList ) {} - - rpc ListConnectionIds (ServiceId ) returns ( ConnectionIdList) {} - rpc ListConnections (ServiceId ) returns ( ConnectionList ) {} - rpc GetConnection (ConnectionId ) returns ( Connection ) {} - rpc SetConnection (Connection ) returns ( ConnectionId ) {} - rpc RemoveConnection (ConnectionId ) returns ( Empty ) {} - rpc GetConnectionEvents(Empty ) returns (stream ConnectionEvent ) {} -} - -// ----- Generic ------------------------------------------------------------------------------------------------------- -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; -} - -// ----- Context ------------------------------------------------------------------------------------------------------- -message ContextId { - Uuid context_uuid = 1; -} - -message Context { - ContextId context_id = 1; - string name = 2; - repeated TopologyId topology_ids = 3; - repeated ServiceId service_ids = 4; - repeated SliceId slice_ids = 5; - TeraFlowController controller = 6; -} - -message ContextIdList { - repeated ContextId context_ids = 1; -} - -message ContextList { - repeated Context contexts = 1; -} - -message ContextEvent { - Event event = 1; - ContextId context_id = 2; -} - - -// ----- Topology ------------------------------------------------------------------------------------------------------ -message TopologyId { - ContextId context_id = 1; - Uuid topology_uuid = 2; -} - -message Topology { - TopologyId topology_id = 1; - string name = 2; - repeated DeviceId device_ids = 3; - repeated LinkId link_ids = 4; -} - -message TopologyDetails { - TopologyId topology_id = 1; - string name = 2; - repeated Device devices = 3; - repeated Link links = 4; -} - -message TopologyIdList { - repeated TopologyId topology_ids = 1; -} - -message TopologyList { - repeated Topology topologies = 1; -} - -message TopologyEvent { - Event event = 1; - TopologyId topology_id = 2; -} - - -// ----- Device -------------------------------------------------------------------------------------------------------- -message DeviceId { - Uuid device_uuid = 1; -} - -message Device { - DeviceId device_id = 1; - string name = 2; - string device_type = 3; - DeviceConfig device_config = 4; - DeviceOperationalStatusEnum device_operational_status = 5; - repeated DeviceDriverEnum device_drivers = 6; - repeated EndPoint device_endpoints = 7; - repeated Component components = 8; // Used for inventory - DeviceId controller_id = 9; // Identifier of node controlling the actual device -} - -message Component { //Defined previously to this section - Tested OK - Uuid component_uuid = 1; - string name = 2; - string type = 3; - - map<string, string> attributes = 4; // dict[attr.name => json.dumps(attr.value)] - string parent = 5; -} - -message DeviceConfig { - repeated ConfigRule config_rules = 1; -} - -enum DeviceDriverEnum { - DEVICEDRIVER_UNDEFINED = 0; // also used for emulated - DEVICEDRIVER_OPENCONFIG = 1; - DEVICEDRIVER_TRANSPORT_API = 2; - DEVICEDRIVER_P4 = 3; - DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4; - DEVICEDRIVER_ONF_TR_532 = 5; - DEVICEDRIVER_XR = 6; - DEVICEDRIVER_IETF_L2VPN = 7; - DEVICEDRIVER_GNMI_OPENCONFIG = 8; - DEVICEDRIVER_FLEXSCALE = 9; - DEVICEDRIVER_IETF_ACTN = 10; - DEVICEDRIVER_SMARTNIC = 11; -} - -enum DeviceOperationalStatusEnum { - DEVICEOPERATIONALSTATUS_UNDEFINED = 0; - DEVICEOPERATIONALSTATUS_DISABLED = 1; - DEVICEOPERATIONALSTATUS_ENABLED = 2; -} - -message DeviceIdList { - repeated DeviceId device_ids = 1; -} - -message DeviceList { - repeated Device devices = 1; -} - -message DeviceFilter { - DeviceIdList device_ids = 1; - bool include_endpoints = 2; - bool include_config_rules = 3; - bool include_components = 4; -} - -message DeviceEvent { - Event event = 1; - DeviceId device_id = 2; - DeviceConfig device_config = 3; -} - - -// ----- Link ---------------------------------------------------------------------------------------------------------- -message LinkId { - Uuid link_uuid = 1; -} - -message LinkAttributes { - float total_capacity_gbps = 1; - float used_capacity_gbps = 2; -} - -message Link { - LinkId link_id = 1; - string name = 2; - repeated EndPointId link_endpoint_ids = 3; - LinkAttributes attributes = 4; -} - -message LinkIdList { - repeated LinkId link_ids = 1; -} - -message LinkList { - repeated Link links = 1; -} - -message LinkEvent { - Event event = 1; - LinkId link_id = 2; -} - - -// ----- Service ------------------------------------------------------------------------------------------------------- -message ServiceId { - ContextId context_id = 1; - Uuid service_uuid = 2; -} - -message Service { - ServiceId service_id = 1; - string name = 2; - ServiceTypeEnum service_type = 3; - repeated EndPointId service_endpoint_ids = 4; - repeated Constraint service_constraints = 5; - ServiceStatus service_status = 6; - ServiceConfig service_config = 7; - Timestamp timestamp = 8; -} - -enum ServiceTypeEnum { - SERVICETYPE_UNKNOWN = 0; - SERVICETYPE_L3NM = 1; - SERVICETYPE_L2NM = 2; - SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3; - SERVICETYPE_TE = 4; - SERVICETYPE_E2E = 5; -} - -enum ServiceStatusEnum { - SERVICESTATUS_UNDEFINED = 0; - SERVICESTATUS_PLANNED = 1; - SERVICESTATUS_ACTIVE = 2; - SERVICESTATUS_UPDATING = 3; - SERVICESTATUS_PENDING_REMOVAL = 4; - SERVICESTATUS_SLA_VIOLATED = 5; -} - -message ServiceStatus { - ServiceStatusEnum service_status = 1; -} - -message ServiceConfig { - repeated ConfigRule config_rules = 1; -} - -message ServiceIdList { - repeated ServiceId service_ids = 1; -} - -message ServiceList { - repeated Service services = 1; -} - -message ServiceFilter { - ServiceIdList service_ids = 1; - bool include_endpoint_ids = 2; - bool include_constraints = 3; - bool include_config_rules = 4; -} - -message ServiceEvent { - Event event = 1; - ServiceId service_id = 2; -} - -// ----- Slice --------------------------------------------------------------------------------------------------------- -message SliceId { - ContextId context_id = 1; - Uuid slice_uuid = 2; -} - -message Slice { - SliceId slice_id = 1; - string name = 2; - repeated EndPointId slice_endpoint_ids = 3; - repeated Constraint slice_constraints = 4; - repeated ServiceId slice_service_ids = 5; - repeated SliceId slice_subslice_ids = 6; - SliceStatus slice_status = 7; - SliceConfig slice_config = 8; - SliceOwner slice_owner = 9; - Timestamp timestamp = 10; -} - -message SliceOwner { - Uuid owner_uuid = 1; - string owner_string = 2; -} - -enum SliceStatusEnum { - SLICESTATUS_UNDEFINED = 0; - SLICESTATUS_PLANNED = 1; - SLICESTATUS_INIT = 2; - SLICESTATUS_ACTIVE = 3; - SLICESTATUS_DEINIT = 4; - SLICESTATUS_SLA_VIOLATED = 5; -} - -message SliceStatus { - SliceStatusEnum slice_status = 1; -} - -message SliceConfig { - repeated ConfigRule config_rules = 1; -} - -message SliceIdList { - repeated SliceId slice_ids = 1; -} - -message SliceList { - repeated Slice slices = 1; -} - -message SliceFilter { - SliceIdList slice_ids = 1; - bool include_endpoint_ids = 2; - bool include_constraints = 3; - bool include_service_ids = 4; - bool include_subslice_ids = 5; - bool include_config_rules = 6; -} - -message SliceEvent { - Event event = 1; - SliceId slice_id = 2; -} - -// ----- Connection ---------------------------------------------------------------------------------------------------- -message ConnectionId { - Uuid connection_uuid = 1; -} - -message ConnectionSettings_L0 { - string lsp_symbolic_name = 1; -} - -message ConnectionSettings_L2 { - string src_mac_address = 1; - string dst_mac_address = 2; - uint32 ether_type = 3; - uint32 vlan_id = 4; - uint32 mpls_label = 5; - uint32 mpls_traffic_class = 6; -} - -message ConnectionSettings_L3 { - string src_ip_address = 1; - string dst_ip_address = 2; - uint32 dscp = 3; - uint32 protocol = 4; - uint32 ttl = 5; -} - -message ConnectionSettings_L4 { - uint32 src_port = 1; - uint32 dst_port = 2; - uint32 tcp_flags = 3; - uint32 ttl = 4; -} - -message ConnectionSettings { - ConnectionSettings_L0 l0 = 1; - ConnectionSettings_L2 l2 = 2; - ConnectionSettings_L3 l3 = 3; - ConnectionSettings_L4 l4 = 4; -} - -message Connection { - ConnectionId connection_id = 1; - ServiceId service_id = 2; - repeated EndPointId path_hops_endpoint_ids = 3; - repeated ServiceId sub_service_ids = 4; - ConnectionSettings settings = 5; -} - -message ConnectionIdList { - repeated ConnectionId connection_ids = 1; -} - -message ConnectionList { - repeated Connection connections = 1; -} - -message ConnectionEvent { - Event event = 1; - ConnectionId connection_id = 2; -} - - -// ----- Endpoint ------------------------------------------------------------------------------------------------------ -message EndPointId { - TopologyId topology_id = 1; - DeviceId device_id = 2; - Uuid endpoint_uuid = 3; -} - -message EndPoint { - EndPointId endpoint_id = 1; - string name = 2; - string endpoint_type = 3; - repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; - Location endpoint_location = 5; -} - -message EndPointName { - EndPointId endpoint_id = 1; - string device_name = 2; - string endpoint_name = 3; - string endpoint_type = 4; -} - -message EndPointIdList { - repeated EndPointId endpoint_ids = 1; -} - -message EndPointNameList { - repeated EndPointName endpoint_names = 1; -} - - -// ----- Configuration ------------------------------------------------------------------------------------------------- -enum ConfigActionEnum { - CONFIGACTION_UNDEFINED = 0; - CONFIGACTION_SET = 1; - CONFIGACTION_DELETE = 2; -} - -message ConfigRule_Custom { - string resource_key = 1; - string resource_value = 2; -} - -message ConfigRule_ACL { - EndPointId endpoint_id = 1; - acl.AclRuleSet rule_set = 2; -} - -message ConfigRule { - ConfigActionEnum action = 1; - oneof config_rule { - ConfigRule_Custom custom = 2; - ConfigRule_ACL acl = 3; - } -} - - -// ----- Constraint ---------------------------------------------------------------------------------------------------- -enum ConstraintActionEnum { - CONSTRAINTACTION_UNDEFINED = 0; - CONSTRAINTACTION_SET = 1; - CONSTRAINTACTION_DELETE = 2; -} - -message Constraint_Custom { - string constraint_type = 1; - string constraint_value = 2; -} - -message Constraint_Schedule { - float start_timestamp = 1; - float duration_days = 2; -} - -message GPS_Position { - float latitude = 1; - float longitude = 2; -} - -message Location { - oneof location { - string region = 1; - GPS_Position gps_position = 2; - } -} - -message Constraint_EndPointLocation { - EndPointId endpoint_id = 1; - Location location = 2; -} - -message Constraint_EndPointPriority { - EndPointId endpoint_id = 1; - uint32 priority = 2; -} - -message Constraint_SLA_Latency { - float e2e_latency_ms = 1; -} - -message Constraint_SLA_Capacity { - float capacity_gbps = 1; -} - -message Constraint_SLA_Availability { - uint32 num_disjoint_paths = 1; - bool all_active = 2; - float availability = 3; // 0.0 .. 100.0 percentage of availability -} - -enum IsolationLevelEnum { - NO_ISOLATION = 0; - PHYSICAL_ISOLATION = 1; - LOGICAL_ISOLATION = 2; - PROCESS_ISOLATION = 3; - PHYSICAL_MEMORY_ISOLATION = 4; - PHYSICAL_NETWORK_ISOLATION = 5; - VIRTUAL_RESOURCE_ISOLATION = 6; - NETWORK_FUNCTIONS_ISOLATION = 7; - SERVICE_ISOLATION = 8; -} - -message Constraint_SLA_Isolation_level { - repeated IsolationLevelEnum isolation_level = 1; -} - -message Constraint_Exclusions { - bool is_permanent = 1; - repeated DeviceId device_ids = 2; - repeated EndPointId endpoint_ids = 3; - repeated LinkId link_ids = 4; -} - -message Constraint { - ConstraintActionEnum action = 1; - oneof constraint { - Constraint_Custom custom = 2; - Constraint_Schedule schedule = 3; - Constraint_EndPointLocation endpoint_location = 4; - Constraint_EndPointPriority endpoint_priority = 5; - Constraint_SLA_Capacity sla_capacity = 6; - Constraint_SLA_Latency sla_latency = 7; - Constraint_SLA_Availability sla_availability = 8; - Constraint_SLA_Isolation_level sla_isolation = 9; - Constraint_Exclusions exclusions = 10; - } -} - - -// ----- Miscellaneous ------------------------------------------------------------------------------------------------- -message TeraFlowController { - ContextId context_id = 1; - string ip_address = 2; - uint32 port = 3; -} - -message AuthenticationResult { - ContextId context_id = 1; - bool authenticated = 2; -} diff --git a/src/ztp/src/main/proto/context.proto b/src/ztp/src/main/proto/context.proto new file mode 120000 index 000000000..7f33c4bc7 --- /dev/null +++ b/src/ztp/src/main/proto/context.proto @@ -0,0 +1 @@ +../../../../../proto/context.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/device.proto b/src/ztp/src/main/proto/device.proto deleted file mode 100644 index 30e60079d..000000000 --- a/src/ztp/src/main/proto/device.proto +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 device; - -import "context.proto"; -import "monitoring.proto"; - -service DeviceService { - rpc AddDevice (context.Device ) returns (context.DeviceId ) {} - rpc ConfigureDevice (context.Device ) returns (context.DeviceId ) {} - rpc DeleteDevice (context.DeviceId ) returns (context.Empty ) {} - rpc GetInitialConfig(context.DeviceId ) returns (context.DeviceConfig) {} - rpc MonitorDeviceKpi(MonitoringSettings) returns (context.Empty ) {} -} - -message MonitoringSettings { - monitoring.KpiId kpi_id = 1; - monitoring.KpiDescriptor kpi_descriptor = 2; - float sampling_duration_s = 3; - float sampling_interval_s = 4; -} diff --git a/src/ztp/src/main/proto/device.proto b/src/ztp/src/main/proto/device.proto new file mode 120000 index 000000000..ad6e7c47e --- /dev/null +++ b/src/ztp/src/main/proto/device.proto @@ -0,0 +1 @@ +../../../../../proto/device.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/kpi_sample_types.proto b/src/ztp/src/main/proto/kpi_sample_types.proto deleted file mode 100644 index 5b234a4e3..000000000 --- a/src/ztp/src/main/proto/kpi_sample_types.proto +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 kpi_sample_types; - -enum KpiSampleType { - KPISAMPLETYPE_UNKNOWN = 0; - - KPISAMPLETYPE_PACKETS_TRANSMITTED = 101; - KPISAMPLETYPE_PACKETS_RECEIVED = 102; - KPISAMPLETYPE_PACKETS_DROPPED = 103; - KPISAMPLETYPE_BYTES_TRANSMITTED = 201; - KPISAMPLETYPE_BYTES_RECEIVED = 202; - KPISAMPLETYPE_BYTES_DROPPED = 203; - - KPISAMPLETYPE_LINK_TOTAL_CAPACITY_GBPS = 301; - KPISAMPLETYPE_LINK_USED_CAPACITY_GBPS = 302; - - KPISAMPLETYPE_ML_CONFIDENCE = 401; //. can be used by both optical and L3 without any issue - - KPISAMPLETYPE_OPTICAL_SECURITY_STATUS = 501; //. can be used by both optical and L3 without any issue - - KPISAMPLETYPE_L3_UNIQUE_ATTACK_CONNS = 601; - KPISAMPLETYPE_L3_TOTAL_DROPPED_PACKTS = 602; - KPISAMPLETYPE_L3_UNIQUE_ATTACKERS = 603; - KPISAMPLETYPE_L3_UNIQUE_COMPROMISED_CLIENTS = 604; - KPISAMPLETYPE_L3_SECURITY_STATUS_CRYPTO = 605; - - KPISAMPLETYPE_SERVICE_LATENCY_MS = 701; -} diff --git a/src/ztp/src/main/proto/kpi_sample_types.proto b/src/ztp/src/main/proto/kpi_sample_types.proto new file mode 120000 index 000000000..98e748bbf --- /dev/null +++ b/src/ztp/src/main/proto/kpi_sample_types.proto @@ -0,0 +1 @@ +../../../../../proto/kpi_sample_types.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/monitoring.proto b/src/ztp/src/main/proto/monitoring.proto deleted file mode 100644 index 45ba48b02..000000000 --- a/src/ztp/src/main/proto/monitoring.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 monitoring; - -import "context.proto"; -import "kpi_sample_types.proto"; - -service MonitoringService { - rpc SetKpi (KpiDescriptor ) returns (KpiId ) {} // Stable not final - rpc DeleteKpi (KpiId ) returns (context.Empty ) {} // Stable and final - rpc GetKpiDescriptor (KpiId ) returns (KpiDescriptor ) {} // Stable and final - rpc GetKpiDescriptorList (context.Empty ) returns (KpiDescriptorList ) {} // Stable and final - rpc IncludeKpi (Kpi ) returns (context.Empty ) {} // Stable and final - rpc MonitorKpi (MonitorKpiRequest ) returns (context.Empty ) {} // Stable and final - rpc QueryKpiData (KpiQuery ) returns (RawKpiTable ) {} // Not implemented - rpc SetKpiSubscription (SubsDescriptor ) returns (stream SubsResponse ) {} // Stable not final - rpc GetSubsDescriptor (SubscriptionID ) returns (SubsDescriptor ) {} // Stable and final - rpc GetSubscriptions (context.Empty ) returns (SubsList ) {} // Stable and final - rpc DeleteSubscription (SubscriptionID ) returns (context.Empty ) {} // Stable and final - rpc SetKpiAlarm (AlarmDescriptor ) returns (AlarmID ) {} // Stable not final - rpc GetAlarms (context.Empty ) returns (AlarmList ) {} // Stable and final - rpc GetAlarmDescriptor (AlarmID ) returns (AlarmDescriptor ) {} // Stable and final - rpc GetAlarmResponseStream(AlarmSubscription ) returns (stream AlarmResponse) {} // Not Stable not final - rpc DeleteAlarm (AlarmID ) returns (context.Empty ) {} // Stable and final - rpc GetStreamKpi (KpiId ) returns (stream Kpi ) {} // Stable not final - rpc GetInstantKpi (KpiId ) returns (Kpi ) {} // Stable not final -} - -message KpiDescriptor { - KpiId kpi_id = 1; - string kpi_description = 2; - repeated KpiId kpi_id_list = 3; - kpi_sample_types.KpiSampleType kpi_sample_type = 4; - context.DeviceId device_id = 5; - context.EndPointId endpoint_id = 6; - context.ServiceId service_id = 7; - context.SliceId slice_id = 8; - context.ConnectionId connection_id = 9; - context.LinkId link_id = 10; -} - -message MonitorKpiRequest { - KpiId kpi_id = 1; - float monitoring_window_s = 2; - float sampling_rate_s = 3; - // Pending add field to reflect Available Device Protocols -} - -message KpiQuery { - repeated KpiId kpi_ids = 1; - float monitoring_window_s = 2; - uint32 last_n_samples = 3; // used when you want something like "get the last N many samples - context.Timestamp start_timestamp = 4; // used when you want something like "get the samples since X date/time" - context.Timestamp end_timestamp = 5; // used when you want something like "get the samples until X date/time" -} - - -message RawKpi { // cell - context.Timestamp timestamp = 1; - KpiValue kpi_value = 2; -} - -message RawKpiList { // column - KpiId kpi_id = 1; - repeated RawKpi raw_kpis = 2; -} - -message RawKpiTable { // table - repeated RawKpiList raw_kpi_lists = 1; -} - -message KpiId { - context.Uuid kpi_id = 1; -} - -message Kpi { - KpiId kpi_id = 1; - context.Timestamp timestamp = 2; - KpiValue kpi_value = 3; -} - -message KpiValueRange { - KpiValue kpiMinValue = 1; - KpiValue kpiMaxValue = 2; - bool inRange = 3; // by default True - bool includeMinValue = 4; // False is outside the interval - bool includeMaxValue = 5; // False is outside the interval -} - -message KpiValue { - oneof value { - int32 int32Val = 1; - uint32 uint32Val = 2; - int64 int64Val = 3; - uint64 uint64Val = 4; - float floatVal = 5; - string stringVal = 6; - bool boolVal = 7; - } -} - - -message KpiList { - repeated Kpi kpi = 1; -} - -message KpiDescriptorList { - repeated KpiDescriptor kpi_descriptor_list = 1; -} - -message SubsDescriptor{ - SubscriptionID subs_id = 1; - KpiId kpi_id = 2; - float sampling_duration_s = 3; - float sampling_interval_s = 4; - context.Timestamp start_timestamp = 5; // used when you want something like "get the samples since X date/time" - context.Timestamp end_timestamp = 6; // used when you want something like "get the samples until X date/time" - // Pending add field to reflect Available Device Protocols -} - -message SubscriptionID { - context.Uuid subs_id = 1; -} - -message SubsResponse { - SubscriptionID subs_id = 1; - KpiList kpi_list = 2; -} - -message SubsList { - repeated SubsDescriptor subs_descriptor = 1; -} - -message AlarmDescriptor { - AlarmID alarm_id = 1; - string alarm_description = 2; - string name = 3; - KpiId kpi_id = 4; - KpiValueRange kpi_value_range = 5; - context.Timestamp timestamp = 6; -} - -message AlarmID{ - context.Uuid alarm_id = 1; -} - -message AlarmSubscription{ - AlarmID alarm_id = 1; - float subscription_timeout_s = 2; - float subscription_frequency_ms = 3; -} - -message AlarmResponse { - AlarmID alarm_id = 1; - string text = 2; - KpiList kpi_list = 3; -} - -message AlarmList { - repeated AlarmDescriptor alarm_descriptor = 1; -} diff --git a/src/ztp/src/main/proto/monitoring.proto b/src/ztp/src/main/proto/monitoring.proto new file mode 120000 index 000000000..aceaa7328 --- /dev/null +++ b/src/ztp/src/main/proto/monitoring.proto @@ -0,0 +1 @@ +../../../../../proto/monitoring.proto \ No newline at end of file diff --git a/src/ztp/src/main/proto/ztp.proto b/src/ztp/src/main/proto/ztp.proto deleted file mode 100644 index 5c895900d..000000000 --- a/src/ztp/src/main/proto/ztp.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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 ztp; - -import "context.proto"; - -service ZtpService { - rpc ZtpGetDeviceRole(DeviceRoleId) returns (DeviceRole) {} - rpc ZtpGetDeviceRolesByDeviceId(context.DeviceId) returns (DeviceRoleList) {} - rpc ZtpAdd(DeviceRole) returns (DeviceRoleState) {} - rpc ZtpUpdate(DeviceRoleConfig) returns (DeviceRoleState) {} - rpc ZtpDelete(DeviceRole) returns (DeviceRoleState) {} - rpc ZtpDeleteAll(context.Empty) returns (DeviceDeletionResult) {} -} - -enum DeviceRoleType { - NONE = 0; - DEV_OPS = 1; - DEV_CONF = 2; - PIPELINE_CONF = 3; -} - -message DeviceRoleId { - context.Uuid devRoleId = 1; - context.DeviceId devId = 2; -} - -message DeviceRole { - DeviceRoleId devRoleId = 1; - DeviceRoleType devRoleType = 2; -} - -message DeviceRoleConfig { - DeviceRole devRole = 1; - context.DeviceConfig devConfig = 2; -} - -message DeviceRoleList { - repeated DeviceRole devRole = 1; -} - -message DeviceRoleState { - DeviceRoleId devRoleId = 1; - ZtpDeviceState devRoleState = 2; -} - -message DeviceDeletionResult { - repeated string deleted = 1; -} - -enum ZtpDeviceState { - ZTP_DEV_STATE_UNDEFINED = 0; - ZTP_DEV_STATE_CREATED = 1; - ZTP_DEV_STATE_UPDATED = 2; - ZTP_DEV_STATE_DELETED = 3; -} diff --git a/src/ztp/src/main/proto/ztp.proto b/src/ztp/src/main/proto/ztp.proto new file mode 120000 index 000000000..9183ce531 --- /dev/null +++ b/src/ztp/src/main/proto/ztp.proto @@ -0,0 +1 @@ +../../../../../proto/ztp.proto \ No newline at end of file -- GitLab From 3786a02f8976fa80a9c2b71ef9955fc009258cdc Mon Sep 17 00:00:00 2001 From: jimenezquesa <manuel.jimenez@eviden.com> Date: Thu, 10 Apr 2025 11:02:45 +0200 Subject: [PATCH 14/14] Remove ztp_device.yang --- src/ztp/src/ztp-agent/ztp_device.yang | 46 --------------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/ztp/src/ztp-agent/ztp_device.yang diff --git a/src/ztp/src/ztp-agent/ztp_device.yang b/src/ztp/src/ztp-agent/ztp_device.yang deleted file mode 100644 index f506d6413..000000000 --- a/src/ztp/src/ztp-agent/ztp_device.yang +++ /dev/null @@ -1,46 +0,0 @@ -module ztp_device { - - yang-version "1"; - - namespace "urn:ztp_nos"; - prefix "ztp_nos"; - organization "EVIDEN"; - contact "jose.carcel@eviden.com"; - description "Basic example of data model for modelling NOS ZTP Device"; - - revision "2023-08-03" { - description "Basic example of data model for modelling NOS ZTP Device"; - reference ""; - } - - grouping config{ - leaf ztp_device_sw_url{ - type string; - } - leaf config_script_url{ - type string; - } - leaf ip_range { - type string; // check IP regular expression - } - } - - typedef state { - type enumeration{ - enum "UNDEF"; - enum "INIT_HW"; - enum "INIT_SW"; - enum "CONFIGURED"; - enum "RUNNING"; - enum "UPDATING"; - enum "MIGRATING"; - enum "DELETED"; - } - } - - grouping state { - leaf ztp_device_state { - type state; - } - } -} \ No newline at end of file -- GitLab