diff --git a/manifests/nginx_ingress_http.yaml b/manifests/nginx_ingress_http.yaml index 5b77ed052f26eb28cb07ebecf70e163aeba9d642..ded6ff3ebc01e812eac99814f5992a5f151d3b44 100644 --- a/manifests/nginx_ingress_http.yaml +++ b/manifests/nginx_ingress_http.yaml @@ -69,3 +69,10 @@ spec: name: nbiservice port: number: 8080 + - path: /()(agent-probes/.*) + pathType: Prefix + backend: + service: + name: nbiservice + port: + number: 8080 diff --git a/proto/any.proto b/proto/any.proto new file mode 100644 index 0000000000000000000000000000000000000000..eff44e5099da27f7fb1ef14bb34902ccf4250b89 --- /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 01e096233e364be8ad4e3810e7619e8f522e66e6..d22dcdc4395e625e672e50af3c4024f195b0201c 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"; @@ -226,6 +227,7 @@ enum DeviceDriverEnum { DEVICEDRIVER_IETF_L3VPN = 13; DEVICEDRIVER_IETF_SLICE = 14; DEVICEDRIVER_NCE = 15; + DEVICEDRIVER_SMARTNIC = 16; } enum DeviceOperationalStatusEnum { @@ -498,6 +500,7 @@ message EndPoint { string endpoint_type = 3; repeated kpi_sample_types.KpiSampleType kpi_sample_types = 4; Location endpoint_location = 5; + map<string, google.protobuf.Any> capabilities = 6; } message EndPointName { diff --git a/proto/context_ext_smartnics.proto b/proto/context_ext_smartnics.proto new file mode 100644 index 0000000000000000000000000000000000000000..fe834b4938ab7a0da9d871089fbda86297ed7b35 --- /dev/null +++ b/proto/context_ext_smartnics.proto @@ -0,0 +1,99 @@ +// 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/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 (A30) + +syntax = "proto3"; +package context_ext_smartnics; + +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; + DpuCoreArchitectureEnum architecture = 2; + uint64 l2_cache_size_mb = 3; + uint64 l3_cache_size_mb = 4; +} + +message DPU_Memory { + string RamMemoryType = 1; + string eMMCMemoryType = 2; + uint64 RamMemorySizeGB = 3; + uint64 eMMCMemorySizeGB = 4; +} + +message GPU { + string model = 1; + string architecture = 2; + string 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/src/common/DeviceTypes.py b/src/common/DeviceTypes.py index 9a982d1eb71e8b139d2a86fe1a774154239c7147..9b269999322f02b7c3f16fc1a7df00fa8272e2af 100644 --- a/src/common/DeviceTypes.py +++ b/src/common/DeviceTypes.py @@ -48,6 +48,7 @@ class DeviceTypeEnum(Enum): PACKET_ROUTER = 'packet-router' PACKET_SWITCH = 'packet-switch' XR_CONSTELLATION = 'xr-constellation' + SMARTNIC = 'smartnic' QKD_NODE = 'qkd-node' OPEN_ROADM = 'openroadm' diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index 61393a7e7b9a16a21ef332880374702ca6125edd..3d09d7156783e4a7e44510900dd55d2d684b299f 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -49,6 +49,8 @@ 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 +150,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 70f5c4220252a3515eab017c1c332af99b082813..9fb48bcde48962c66a6dc1b9675dbad4f3298445 100644 --- a/src/common/type_checkers/Assertions.py +++ b/src/common/type_checkers/Assertions.py @@ -50,6 +50,7 @@ def validate_device_driver_enum(message): 'DEVICEDRIVER_IETF_ACTN', 'DEVICEDRIVER_OC', 'DEVICEDRIVER_QKD', + 'DEVICEDRIVER_SMARTNIC', ] def validate_device_operational_status_enum(message): @@ -57,7 +58,7 @@ def validate_device_operational_status_enum(message): assert message in [ 'DEVICEOPERATIONALSTATUS_UNDEFINED', 'DEVICEOPERATIONALSTATUS_DISABLED', - 'DEVICEOPERATIONALSTATUS_ENABLED' + 'DEVICEOPERATIONALSTATUS_ENABLED', ] def validate_isolation_level_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 c882d6d552060b1b165aa7f036b3d37bb90baca9..67c83cbf264f7cdbb4ce8676d65c7fc9b1e86dcc 100644 --- a/src/context/data/sql_hash_join_full_scan_tests.sql +++ b/src/context/data/sql_hash_join_full_scan_tests.sql @@ -23,7 +23,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 fe0d83fb1886a42526b1c71304b7e3ecc2b0b7d7..f6e128355c557624d6a66d6b147beda5777f74fa 100644 --- a/src/context/service/database/models/enums/DeviceDriver.py +++ b/src/context/service/database/models/enums/DeviceDriver.py @@ -38,6 +38,7 @@ class ORM_DeviceDriverEnum(enum.Enum): IETF_SLICE = DeviceDriverEnum.DEVICEDRIVER_IETF_SLICE OC = DeviceDriverEnum.DEVICEDRIVER_OC QKD = DeviceDriverEnum.DEVICEDRIVER_QKD + 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 e3102cdf523a4e0b551873bb8f0c423db00aebf0..ccb348c05c17708b4acc62d140f70396cc7cd4a6 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -161,6 +161,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 SmartNics device => use SmartNicsDriver + 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/TfsApiClient.py b/src/device/service/drivers/ietf_l2vpn/TfsApiClient.py index c51e2d6bf165d1b9caf41b05e367e43eb3ffebb5..948800dddad183c9b8e2733639bd6fedbac86a31 100644 --- a/src/device/service/drivers/ietf_l2vpn/TfsApiClient.py +++ b/src/device/service/drivers/ietf_l2vpn/TfsApiClient.py @@ -47,6 +47,7 @@ MAPPING_DRIVER = { 'DEVICEDRIVER_OPTICAL_TFS' : 9, 'DEVICEDRIVER_IETF_ACTN' : 10, 'DEVICEDRIVER_OC' : 11, + 'DEVICEDRIVER_SMARTNIC' : 16, } 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 0000000000000000000000000000000000000000..35d05edde272910206f2e69a10d612c26e468a51 --- /dev/null +++ b/src/device/service/drivers/smartnic/SmartnicDriver.py @@ -0,0 +1,126 @@ +# 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 +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}) + +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) + if resource_key == RESOURCE_ENDPOINTS: + 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, resource[1], 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, resource[1], 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 0000000000000000000000000000000000000000..13345b61849bcbd9c408f249e676aeea2a822902 --- /dev/null +++ b/src/device/service/drivers/smartnic/Tools.py @@ -0,0 +1,178 @@ +# 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) + 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 + except Exception as e: # pylint: disable=broad-except + LOGGER.exception('Exception retrieving {:s}'.format(resource_key)) + result.append((resource_key, e)) + return result + + # 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}/manage-probe/configure'.format(root_url) + headers = {'content-type': 'application/json'} + results = [] + try: + LOGGER.info('Configuring Smartnic rules') + response = requests.post( + 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') + 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}/manage-probe/configure'.format(root_url) + results = [] + try: + 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) + 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 0000000000000000000000000000000000000000..b3626c633b35a793de8fde7a69b95dae0cda511f --- /dev/null +++ b/src/device/service/drivers/smartnic/__init__.py @@ -0,0 +1,18 @@ +# 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_INTERFACES +] diff --git a/src/device/service/drivers/smartnic/ietf-yang-types.yang b/src/device/service/drivers/smartnic/ietf-yang-types.yang new file mode 100644 index 0000000000000000000000000000000000000000..371a091d14f590771c02452629f159fb8c9a76bc --- /dev/null +++ b/src/device/service/drivers/smartnic/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/openconfig-extensions.yang b/src/device/service/drivers/smartnic/openconfig-extensions.yang new file mode 100644 index 0000000000000000000000000000000000000000..2e0fd9f075b235e90ebc58a5f56072cbaceccb56 --- /dev/null +++ b/src/device/service/drivers/smartnic/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/openconfig-inet-types.yang b/src/device/service/drivers/smartnic/openconfig-inet-types.yang new file mode 100644 index 0000000000000000000000000000000000000000..3d3ed425e895c94fb6af9a8caf2bfda19657b246 --- /dev/null +++ b/src/device/service/drivers/smartnic/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/openconfig-probes-types.yang b/src/device/service/drivers/smartnic/openconfig-probes-types.yang new file mode 100644 index 0000000000000000000000000000000000000000..c5e13f37061c952b1602e967d11267087b8eaafa --- /dev/null +++ b/src/device/service/drivers/smartnic/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/openconfig-probes.yang b/src/device/service/drivers/smartnic/openconfig-probes.yang new file mode 100644 index 0000000000000000000000000000000000000000..27b7e4c0d7f21a71beb69dc92e82a857dc65003d --- /dev/null +++ b/src/device/service/drivers/smartnic/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/openconfig-types.yang b/src/device/service/drivers/smartnic/openconfig-types.yang new file mode 100644 index 0000000000000000000000000000000000000000..89e32d515da02dea27c95021a1c62f5700d1d493 --- /dev/null +++ b/src/device/service/drivers/smartnic/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-agent.yang b/src/device/service/drivers/smartnic/probes-agent.yang new file mode 100644 index 0000000000000000000000000000000000000000..0ed81170a631cb9a7ec74b0557179447f9487588 --- /dev/null +++ b/src/device/service/drivers/smartnic/probes-agent.yang @@ -0,0 +1,163 @@ +// 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"; +prefix "probes-agent"; + +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; + enum morpheus_pipeline; + } + } +} + +augment '/oc-probes:probes/oc-probes:probe/oc-probes:tests/oc-probes:test/oc-probes:config' { + uses morpheus_pipelines; +} + +typedef files{ + type enumeration { + enum "auto"; + enum "csv"; + enum "json"; + } +} + +grouping prob{ + leaf value { + type string; // e.g. "probs" + 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 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 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/references_probes_libraries.txt b/src/device/service/drivers/smartnic/references_probes_libraries.txt new file mode 100644 index 0000000000000000000000000000000000000000..7628b7c2fd98c0eb4564251aa2a3b78e9a9a7b04 --- /dev/null +++ b/src/device/service/drivers/smartnic/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 diff --git a/src/nbi/service/__main__.py b/src/nbi/service/__main__.py index 1d470f4eac30795e2272c9145baf947f3c982ba5..3cfa1badb24e8b4c25171704e9a97db0ebed3fa6 100644 --- a/src/nbi/service/__main__.py +++ b/src/nbi/service/__main__.py @@ -22,6 +22,7 @@ from common.Settings import ( ) 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.etsi_bwm import register_etsi_bwm_api from .rest_server.nbi_plugins.ietf_hardware import register_ietf_hardware from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn @@ -71,6 +72,7 @@ def main(): grpc_service.start() rest_server = RestServer() + register_agent_probes(rest_server) register_etsi_bwm_api(rest_server) register_ietf_hardware(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 0000000000000000000000000000000000000000..3c3184323da4f94f4660bb888024019e8fa649da --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Resources.py @@ -0,0 +1,70 @@ +# 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_restful import Resource, request +from common.proto.context_pb2 import Empty +from context.client.ContextClient import ContextClient +from device.client.DeviceClient import DeviceClient +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() + +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'], + status = device['device_operational_status'], + 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 + 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'], + 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'], + 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'] + ))) 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 0000000000000000000000000000000000000000..27a2780bb2d8008618ba906675d6a908f803c0f4 --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/Tools.py @@ -0,0 +1,55 @@ +# 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 ( + DeviceDriverEnum, Device, DeviceId, DeviceOperationalStatusEnum +) +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.EndPoint import json_endpoint +from common.tools.object_factory.Device import json_device_id, json_device + +def format_grpc_to_json(grpc_reply): + return jsonify(grpc_message_to_json(grpc_reply)) + +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'], + 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_status, None, json_endpoints, json_config_rules, json_drivers)) 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 0000000000000000000000000000000000000000..f28a2ad566360bc130efe3a81a08d7770540ec9a --- /dev/null +++ b/src/nbi/service/rest_server/nbi_plugins/agent_probes/__init__.py @@ -0,0 +1,30 @@ +# 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 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.smartnic.device_ids', DeviceIds, '/device_ids'), + ('api.smartnic.devices', Devices, '/devices'), + ('api.smartnic.device', Device, '/device/<path:device_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 0000000000000000000000000000000000000000..dbbf953ad92e85170409ff8fa0bb2601eff8222f --- /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 0000000000000000000000000000000000000000..6170e88a1dbf3cf01d3c9c347064aa85ce282044 --- /dev/null +++ b/src/nbi/tests/data/agent_probes_device.json @@ -0,0 +1,26 @@ +{ + + "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": [] + } + + ] +} diff --git a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py index dfcd1156b78cebee7da84033cbc9943aaabdb14d..7cd419c6be3896c034abf43a8abe45fccbad1733 100644 --- a/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py +++ b/src/pathcomp/frontend/service/algorithms/tools/ComputeSubServices.py @@ -45,24 +45,41 @@ # ], [UUID('c2e57966-5d82-4705-a5fe-44cf6487219e')]) # ] -import logging, queue, uuid +import logging, queue +from dataclasses import dataclass, field from typing import Dict, List, Optional, Tuple from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import Device, ServiceTypeEnum +from common.tools.context_queries.Slice import get_uuid_from_string from .ResourceGroups import IGNORED_DEVICE_TYPES, REMOTEDOMAIN_DEVICE_TYPES, get_resource_classification from .ServiceTypes import get_service_type LOGGER = logging.getLogger(__name__) +@dataclass +class ConnectionEntry: + uuid: str = '' + service_type : ServiceTypeEnum = ServiceTypeEnum.SERVICETYPE_UNKNOWN + path_hops : List[Dict] = field(default_factory=list) + dependencies : List['ConnectionEntry'] = field(default_factory=list) + + def calculate_subservice_uuid(self, main_service_uuid: str) -> None: + if self.uuid: + return + composed_string = main_service_uuid + '-'.join( + f'{path_hop["device"]}/{path_hop["ingress_ep"]}/{path_hop["egress_ep"]}' for path_hop in self.path_hops + ) + self.uuid = get_uuid_from_string(composed_string) + def convert_explicit_path_hops_to_connections( path_hops : List[Dict], device_dict : Dict[str, Tuple[Dict, Device]], main_service_uuid : str, main_service_type : ServiceTypeEnum -) -> List[Tuple[str, int, List[str], List[str]]]: +) -> List[Tuple[str, int, List[Dict], List[str]]]: LOGGER.debug('path_hops={:s}'.format(str(path_hops))) connection_stack = queue.LifoQueue() - connections : List[Tuple[str, int, List[str], List[str]]] = list() + connections : List[ConnectionEntry] = list() prv_device_uuid = None prv_res_class : Tuple[Optional[int], Optional[DeviceTypeEnum], Optional[str]] = None, None, None @@ -85,82 +102,82 @@ def convert_explicit_path_hops_to_connections( LOGGER.debug(' create and terminate underlying connection') # create underlying connection - sub_service_uuid = str(uuid.uuid4()) - prv_service_type = connection_stack.queue[-1][1] + prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) - connection_stack.put((sub_service_uuid, service_type, [path_hop], [])) + connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) # underlying connection ended - connection = connection_stack.get() + connection: ConnectionEntry = connection_stack.get() connections.append(connection) - connection_stack.queue[-1][3].append(connection[0]) - #connection_stack.queue[-1][2].append(path_hop) + connection_stack.queue[-1].dependencies.append(connection) elif prv_res_class[2] is None and res_class[2] is not None: # entering domain of a device controller, create underlying connection LOGGER.debug(' entering domain of a device controller, create underlying connection') - sub_service_uuid = str(uuid.uuid4()) - prv_service_type = connection_stack.queue[-1][1] + prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) - connection_stack.put((sub_service_uuid, service_type, [path_hop], [])) + connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) elif prv_res_class[2] is not None and res_class[2] is None: # leaving domain of a device controller, terminate underlying connection LOGGER.debug(' leaving domain of a device controller, terminate underlying connection') connection = connection_stack.get() connections.append(connection) - connection_stack.queue[-1][3].append(connection[0]) - connection_stack.queue[-1][2].append(path_hop) + connection_stack.queue[-1].dependencies.append(connection) + connection_stack.queue[-1].path_hops.append(path_hop) elif prv_res_class[2] is not None and res_class[2] is not None: if prv_res_class[2] == res_class[2]: # stay in domain of a device controller, connection continues LOGGER.debug(' stay in domain of a device controller, connection continues') - connection_stack.queue[-1][2].append(path_hop) + connection_stack.queue[-1].path_hops.append(path_hop) else: # switching to different device controller, chain connections LOGGER.debug(' switching to different device controller, chain connections') connection = connection_stack.get() connections.append(connection) - connection_stack.queue[-1][3].append(connection[0]) + connection_stack.queue[-1].dependencies.append(connection) - sub_service_uuid = str(uuid.uuid4()) - prv_service_type = connection_stack.queue[-1][1] + prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) - connection_stack.put((sub_service_uuid, service_type, [path_hop], [])) + connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) elif prv_res_class[0] is None: # path ingress LOGGER.debug(' path ingress') - connection_stack.put((main_service_uuid, main_service_type, [path_hop], [])) + connection_entry = ConnectionEntry(uuid=main_service_uuid, service_type=main_service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) elif prv_res_class[0] > res_class[0]: # create underlying connection LOGGER.debug(' create underlying connection') - sub_service_uuid = str(uuid.uuid4()) - prv_service_type = connection_stack.queue[-1][1] + prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) - connection_stack.put((sub_service_uuid, service_type, [path_hop], [])) + connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) elif prv_res_class[0] == res_class[0]: # same resource group kind LOGGER.debug(' same resource group kind') if prv_res_class[1] == res_class[1] and prv_res_class[2] == res_class[2]: # same device type and device controller: connection continues LOGGER.debug(' connection continues') - connection_stack.queue[-1][2].append(path_hop) + connection_stack.queue[-1].path_hops.append(path_hop) else: # different device type or device controller: chain connections LOGGER.debug(' chain connections') connection = connection_stack.get() connections.append(connection) - connection_stack.queue[-1][3].append(connection[0]) + connection_stack.queue[-1].dependencies.append(connection) - sub_service_uuid = str(uuid.uuid4()) - prv_service_type = connection_stack.queue[-1][1] + prv_service_type = connection_stack.queue[-1].service_type service_type = get_service_type(res_class[1], prv_service_type) - connection_stack.put((sub_service_uuid, service_type, [path_hop], [])) + connection_entry = ConnectionEntry(service_type=service_type, path_hops=[path_hop]) + connection_stack.put(connection_entry) elif prv_res_class[0] < res_class[0]: # underlying connection ended LOGGER.debug(' underlying connection ended') connection = connection_stack.get() connections.append(connection) - connection_stack.queue[-1][3].append(connection[0]) - connection_stack.queue[-1][2].append(path_hop) + connection_stack.queue[-1].dependencies.append(connection) + connection_stack.queue[-1].path_hops.append(path_hop) else: raise Exception('Uncontrolled condition') @@ -172,7 +189,9 @@ def convert_explicit_path_hops_to_connections( connections.append(connection_stack.get()) LOGGER.debug('connections={:s}'.format(str(connections))) assert connection_stack.empty() - return connections + for c in connections: + c.calculate_subservice_uuid(main_service_uuid) + return [(c.uuid, c.service_type, c.path_hops, [cd.uuid for cd in c.dependencies]) for c in connections] def convert_explicit_path_hops_to_plain_connection( path_hops : List[Dict], main_service_uuid : str, main_service_type : ServiceTypeEnum 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 e3265ff32e3e1f93a3bfd3007aff7e80d3154d8f..33519532e69cc7a00bf65db8e2149bf39bf89aff 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_OPTICAL_TFS; 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.OPTICAL_TFS; 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 26c4b20238f70c5753b17abb9453c206ee9fe5c4..c8ba74fe98119caa044abfed10026d0e08dde7d8 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, OPTICAL_TFS, - IETF_ACTN + IETF_ACTN, + SMARTNIC } diff --git a/src/service/service/service_handler_api/FilterFields.py b/src/service/service/service_handler_api/FilterFields.py index e47fd635f0c02667a052ebb9cff0569496c5fbec..34f5ce59a2c962a7ceb26bfd256eb772e26daa2e 100644 --- a/src/service/service/service_handler_api/FilterFields.py +++ b/src/service/service/service_handler_api/FilterFields.py @@ -48,6 +48,7 @@ DEVICE_DRIVER_VALUES = { DeviceDriverEnum.DEVICEDRIVER_OC, DeviceDriverEnum.DEVICEDRIVER_QKD, DeviceDriverEnum.DEVICEDRIVER_IETF_L3VPN, + 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 85545d238f2b93bd77b1beb1fce2d46b01b06800..6e97563d5769476b23c2a241ee1d2a5a1659ee88 100644 --- a/src/service/service/service_handlers/__init__.py +++ b/src/service/service/service_handlers/__init__.py @@ -117,6 +117,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 4fa6829e760be6f24ba011a18664ce2ee4635595..90259295a1a1da429096982fb9f8c54509fc4c92 100644 --- a/src/webui/service/device/forms.py +++ b/src/webui/service/device/forms.py @@ -34,6 +34,7 @@ class AddDeviceForm(FlaskForm): device_drivers_optical_tfs = BooleanField('OPTICAL TFS') device_drivers_ietf_actn = BooleanField('IETF ACTN') device_drivers_qkd = BooleanField('QKD') + 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 16b86c769c5af1b69db4b669f5689043d03536bd..eafaa575820fd515b9df939e4eb627cda046ed49 100644 --- a/src/webui/service/device/routes.py +++ b/src/webui/service/device/routes.py @@ -135,6 +135,8 @@ def add(): device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_IETF_ACTN) if form.device_drivers_qkd.data: device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_QKD) + if form.device_drivers_smartnic.data: + device_drivers.append(DeviceDriverEnum.DEVICEDRIVER_SMARTNIC) device_obj.device_drivers.extend(device_drivers) # pylint: disable=no-member try: diff --git a/src/webui/service/templates/device/add.html b/src/webui/service/templates/device/add.html index b5628ab5902d1b59c70413d41d05a6736adc751a..15abc0894d923d7507e51d26e8b1fb6cdb7b757d 100644 --- a/src/webui/service/templates/device/add.html +++ b/src/webui/service/templates/device/add.html @@ -96,6 +96,8 @@ {{ form.device_drivers_optical_tfs }} {{ form.device_drivers_optical_tfs.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_qkd }} {{ form.device_drivers_qkd.label(class="col-sm-3 col-form-label") }} + <br /> + {{ form.device_drivers_smartnic }} {{ form.device_drivers_smartnic_actn.label(class="col-sm-3 col-form-label") }} {% endif %} </div> </div>