From 277809ba83e5aac0123da52ba3dda95394bb3c8f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 14 Oct 2024 15:03:25 -0300 Subject: [PATCH] daemon-grpc: update `Capabilities` RPC to return supported features per module It's important to know which features are enabled or disabled, as this determines which parts of the YANG module are implemented. gNMI's `Capabilities` RPC doesn't provide this information, since OpenConfig modules typically don't use "feature" and "if-feature" statements, unlike IETF models. Signed-off-by: Renato Westphal --- holo-daemon/src/northbound/client/grpc.rs | 11 ++++++++++- proto/holo.proto | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/holo-daemon/src/northbound/client/grpc.rs b/holo-daemon/src/northbound/client/grpc.rs index 4a3cec6c..4ecbb8b5 100644 --- a/holo-daemon/src/northbound/client/grpc.rs +++ b/holo-daemon/src/northbound/client/grpc.rs @@ -9,7 +9,7 @@ use std::time::SystemTime; use futures::Stream; use holo_utils::Sender; -use holo_yang::YANG_CTX; +use holo_yang::{YANG_CTX, YANG_FEATURES}; use tokio::sync::oneshot; use tonic::transport::{Server, ServerTlsConfig}; use tonic::{Request, Response, Status}; @@ -63,6 +63,15 @@ impl proto::Northbound for NorthboundService { .unwrap_or_default() .to_owned(), revision: module.revision().unwrap_or_default().to_owned(), + supported_features: YANG_FEATURES + .get(&module.name()) + .map(|features| { + features + .iter() + .map(|feature| (*feature).to_owned()) + .collect() + }) + .unwrap_or_default(), }) .collect(); diff --git a/proto/holo.proto b/proto/holo.proto index 985c0f7d..1fb4af72 100644 --- a/proto/holo.proto +++ b/proto/holo.proto @@ -231,6 +231,9 @@ message ModuleData { // Latest revision of the module; string revision = 3; + + // Supported features. + repeated string supported_features = 4; } // Supported encodings for YANG instance data.