Documentation ¶
Overview ¶
Package gnmi contains a reference on-device gNMI implementation.
Index ¶
- Constants
- func AddTimestampMetadata(ctx context.Context, timestamp int64) context.Context
- func NewSubscribeTargetUpdateInterceptor(target string) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- type Collector
- type Mode
- type PathAuth
- type Server
- func (s *Server) Capabilities(context.Context, *gpb.CapabilityRequest) (*gpb.CapabilityResponse, error)
- func (s *Server) Get(context.Context, *gpb.GetRequest) (*gpb.GetResponse, error)
- func (s *Server) LocalClient() gpb.GNMIClient
- func (s *Server) Set(ctx context.Context, req *gpb.SetRequest) (*gpb.SetResponse, error)
- func (s *Server) StartReconcilers(ctx context.Context) error
- func (s *Server) StopReconcilers(ctx context.Context) error
- func (s *Server) Subscribe(srv gpb.GNMI_SubscribeServer) error
Constants ¶
const ( // GNMIModeMetadataKey is the context metadata key used to specify the // mode in which the gNMI server should operate. GNMIModeMetadataKey = "gnmi-mode" // ConfigMode indicates that the gNMI service will allow updates to // intended configuration, but not operational state values. ConfigMode Mode = "config" // StateMode indicates that the gNMI service will allow updates to // operational state, but not intended configuration values. StateMode Mode = "state" // TimestampMetadataKey is the context metadata key used to specify a // custom timestamp for the values in the SetRequest instead of using // the time at which the SetRequest is received by the server. TimestampMetadataKey = "gnmi-timestamp" )
const (
// InternalOrigin is a special gNMI path origin used to store schemaless values.
InternalOrigin = "lemming-internal"
)
const (
OpenConfigOrigin = "openconfig"
)
Variables ¶
This section is empty.
Functions ¶
func AddTimestampMetadata ¶
AddTimestampMetadata adds a gNMI timestamp metadata to the context.
- ctx is the context to be used for accessing lemming's internal datastore. - timestamp is the number of nanoseconds since Epoch.
NOTE: The output of this function should only be used to call into the internal lemming gNMI server. This is because it adds an incoming rather than an outgoing context metadata to skip regular protobuf handling.
func NewSubscribeTargetUpdateInterceptor ¶ added in v0.4.0
func NewSubscribeTargetUpdateInterceptor(target string) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
NewSubscribeTargetUpdateInterceptor returns a stream interceptor to populate gNMI Subscribe's target if it's not populated in the SubscribeRequest message in order to retrieve the device's data.
ref: https://www.openconfig.net/docs/gnmi/gnmi-specification/#2221-path-target
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is a basic gNMI target that supports only the Subscribe RPC, and acts as a cache for exactly one target.
func NewCollector ¶
NewCollector returns an initialized gNMI Collector implementation.
To create a gNMI server that supports gnmi.Set as well, use New() instead.
func (*Collector) GnmiUpdate ¶ added in v0.4.0
func (c *Collector) GnmiUpdate(n *gpb.Notification) error
GnmiUpdate sends a pb.Notification into the target cache.
It simply forwards it to the gNMI cache implementation, populating the target (without copying the message) if empty.
func (*Collector) Start ¶
Start starts the collector and returns a linked gNMI server that supports gnmi.Subscribe.
func (*Collector) TargetUpdate ¶
func (c *Collector) TargetUpdate(m *gpb.SubscribeResponse)
TargetUpdate provides an input gNMI SubscribeResponse to update the cache and clients with.
type PathAuth ¶ added in v0.2.0
type PathAuth interface { // CheckPermit returns if the user is allowed to read from or write from in the input path. CheckPermit(path *gpb.Path, user string, write bool) bool // IsInitialized returns if the authorized has been initialized, if not authorization is not checked. IsInitialized() bool }
PathAuth is an interface for checking authorization for gNMI paths.
type Server ¶
type Server struct { // The subscribe Server implements only Subscribe for gNMI. *subscribe.Server // TODO(wenbli): Implement gnmi.Get and remove this. GetResponses []interface{} // contains filtered or unexported fields }
Server is a reference gNMI implementation.
func New ¶
func New(srv *grpc.Server, targetName string, pa PathAuth, recs ...reconciler.Reconciler) (*Server, error)
New creates and registers a reference gNMI server on the given gRPC server.
To avoid having to specify the Target field in gNMI requests in order to comply with https://www.openconfig.net/docs/gnmi/gnmi-specification/#2221-path-target, register the gRPC interceptor grpc.StreamInterceptor(gnmi.NewSubscribeTargetUpdateInterceptor(targetName)) when creating your grpc.Server object.
- targetName is the gNMI target name of the datastore. - pa is an optional PathAuth instance used for authorization gNMI requests, set to nil for no authorization.
func (*Server) Capabilities ¶
func (s *Server) Capabilities(context.Context, *gpb.CapabilityRequest) (*gpb.CapabilityResponse, error)
func (*Server) Get ¶
func (s *Server) Get(context.Context, *gpb.GetRequest) (*gpb.GetResponse, error)
func (*Server) LocalClient ¶
func (s *Server) LocalClient() gpb.GNMIClient
LocalClient returns a gNMI client for the server.
func (*Server) Set ¶
func (s *Server) Set(ctx context.Context, req *gpb.SetRequest) (*gpb.SetResponse, error)
Set implements lemming's gNMI Set operation.
If the given SetRequest is schema compliant AND passes higher-level validators, then the gNMI datastore is updated. Otherwise, the gNMI datastore is untouched and an error is returned.
Context metadata modifies the behaviour of this API. - GNMIModeMetadataKey specifies whether config or state leaves are expected in the SetRequest. This is an exclusive expectation: either the update consists solely of config values (a user request), or state values (an internal goroutine update). - TimestampMetadataKey specifies the timestamp for state leaf updates. This is to support cases where the data comes from an externally-timestamped source.
func (*Server) StartReconcilers ¶
StartReconcilers starts all the reconcilers.
func (*Server) StopReconcilers ¶
StopReconcilers stops all the reconcilers.
Directories ¶
Path | Synopsis |
---|---|
Package gnmiclient contains a funcs to create gNMI for the local cache.
|
Package gnmiclient contains a funcs to create gNMI for the local cache. |
Package oc is a generated package which contains definitions of structs which represent a YANG schema.
|
Package oc is a generated package which contains definitions of structs which represent a YANG schema. |
acl
Package acl is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package acl is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
bgpgue
Package bgpgue is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package bgpgue is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
definedsets
Package definedsets is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package definedsets is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
interfaces
Package interfaces is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package interfaces is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
keychain
Package keychain is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package keychain is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
lacp
Package lacp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package lacp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
lldp
Package lldp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package lldp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
netinstbgp
Package netinstbgp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package netinstbgp is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
netinstisis
Package netinstisis is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package netinstisis is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
networkinstance
Package networkinstance is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package networkinstance is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
ocpath
Package ocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package ocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
platform
Package platform is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package platform is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
qos
Package qos is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package qos is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
routingpolicy
Package routingpolicy is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package routingpolicy is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
system
Package system is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema.
|
Package system is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. |
Package reconciler contains a common interface for gNMI reconciler.
|
Package reconciler contains a common interface for gNMI reconciler. |