feat(inputs.gnmi): Add support for "depth" extension (#16480)
This commit is contained in:
parent
9a43d7c35e
commit
601467fd51
|
|
@ -75,12 +75,19 @@ details on how to use them.
|
||||||
## gRPC Maximum Message Size
|
## gRPC Maximum Message Size
|
||||||
# max_msg_size = "4MB"
|
# max_msg_size = "4MB"
|
||||||
|
|
||||||
|
## Subtree depth for depth extension (disables if < 1)
|
||||||
|
## see https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-depth.md
|
||||||
|
# depth = 0
|
||||||
|
|
||||||
## Enable to get the canonical path as field-name
|
## Enable to get the canonical path as field-name
|
||||||
# canonical_field_names = false
|
# canonical_field_names = false
|
||||||
|
|
||||||
## Remove leading slashes and dots in field-name
|
## Remove leading slashes and dots in field-name
|
||||||
# trim_field_names = false
|
# trim_field_names = false
|
||||||
|
|
||||||
|
## Only receive updates for the state, also suppresses receiving the initial state
|
||||||
|
# updates_only = false
|
||||||
|
|
||||||
## Guess the path-tag if an update does not contain a prefix-path
|
## Guess the path-tag if an update does not contain a prefix-path
|
||||||
## Supported values are
|
## Supported values are
|
||||||
## none -- do not add a 'path' tag
|
## none -- do not add a 'path' tag
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/gnxi/utils/xpath"
|
"github.com/google/gnxi/utils/xpath"
|
||||||
"github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
|
"github.com/openconfig/gnmi/proto/gnmi_ext"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
|
|
||||||
|
|
@ -54,6 +55,7 @@ type GNMI struct {
|
||||||
Password config.Secret `toml:"password"`
|
Password config.Secret `toml:"password"`
|
||||||
Redial config.Duration `toml:"redial"`
|
Redial config.Duration `toml:"redial"`
|
||||||
MaxMsgSize config.Size `toml:"max_msg_size"`
|
MaxMsgSize config.Size `toml:"max_msg_size"`
|
||||||
|
Depth int32 `toml:"depth"`
|
||||||
Trace bool `toml:"dump_responses"`
|
Trace bool `toml:"dump_responses"`
|
||||||
CanonicalFieldNames bool `toml:"canonical_field_names"`
|
CanonicalFieldNames bool `toml:"canonical_field_names"`
|
||||||
TrimFieldNames bool `toml:"trim_field_names"`
|
TrimFieldNames bool `toml:"trim_field_names"`
|
||||||
|
|
@ -376,6 +378,19 @@ func (c *GNMI) newSubscribeRequest() (*gnmi.SubscribeRequest, error) {
|
||||||
return nil, fmt.Errorf("unsupported encoding %s", c.Encoding)
|
return nil, fmt.Errorf("unsupported encoding %s", c.Encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extensions []*gnmi_ext.Extension
|
||||||
|
if c.Depth > 0 {
|
||||||
|
extensions = []*gnmi_ext.Extension{
|
||||||
|
{
|
||||||
|
Ext: &gnmi_ext.Extension_Depth{
|
||||||
|
Depth: &gnmi_ext.Depth{
|
||||||
|
Level: uint32(c.Depth),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &gnmi.SubscribeRequest{
|
return &gnmi.SubscribeRequest{
|
||||||
Request: &gnmi.SubscribeRequest_Subscribe{
|
Request: &gnmi.SubscribeRequest_Subscribe{
|
||||||
Subscribe: &gnmi.SubscriptionList{
|
Subscribe: &gnmi.SubscriptionList{
|
||||||
|
|
@ -386,6 +401,7 @@ func (c *GNMI) newSubscribeRequest() (*gnmi.SubscribeRequest, error) {
|
||||||
UpdatesOnly: c.UpdatesOnly,
|
UpdatesOnly: c.UpdatesOnly,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Extension: extensions,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,19 @@
|
||||||
## gRPC Maximum Message Size
|
## gRPC Maximum Message Size
|
||||||
# max_msg_size = "4MB"
|
# max_msg_size = "4MB"
|
||||||
|
|
||||||
|
## Subtree depth for depth extension (disables if < 1)
|
||||||
|
## see https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-depth.md
|
||||||
|
# depth = 0
|
||||||
|
|
||||||
## Enable to get the canonical path as field-name
|
## Enable to get the canonical path as field-name
|
||||||
# canonical_field_names = false
|
# canonical_field_names = false
|
||||||
|
|
||||||
## Remove leading slashes and dots in field-name
|
## Remove leading slashes and dots in field-name
|
||||||
# trim_field_names = false
|
# trim_field_names = false
|
||||||
|
|
||||||
|
## Only receive updates for the state, also suppresses receiving the initial state
|
||||||
|
# updates_only = false
|
||||||
|
|
||||||
## Guess the path-tag if an update does not contain a prefix-path
|
## Guess the path-tag if an update does not contain a prefix-path
|
||||||
## Supported values are
|
## Supported values are
|
||||||
## none -- do not add a 'path' tag
|
## none -- do not add a 'path' tag
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,19 @@
|
||||||
## gRPC Maximum Message Size
|
## gRPC Maximum Message Size
|
||||||
# max_msg_size = "4MB"
|
# max_msg_size = "4MB"
|
||||||
|
|
||||||
|
## Subtree depth for depth extension (disables if < 1)
|
||||||
|
## see https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-depth.md
|
||||||
|
# depth = 0
|
||||||
|
|
||||||
## Enable to get the canonical path as field-name
|
## Enable to get the canonical path as field-name
|
||||||
# canonical_field_names = false
|
# canonical_field_names = false
|
||||||
|
|
||||||
## Remove leading slashes and dots in field-name
|
## Remove leading slashes and dots in field-name
|
||||||
# trim_field_names = false
|
# trim_field_names = false
|
||||||
|
|
||||||
|
## Only receive updates for the state, also suppresses receiving the initial state
|
||||||
|
# updates_only = false
|
||||||
|
|
||||||
## Guess the path-tag if an update does not contain a prefix-path
|
## Guess the path-tag if an update does not contain a prefix-path
|
||||||
## Supported values are
|
## Supported values are
|
||||||
## none -- do not add a 'path' tag
|
## none -- do not add a 'path' tag
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue