gnmi

package
v0.0.0-...-68ef6d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package gnmi implements a gnmi server to mock a device with YANG models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigCallback

type ConfigCallback func(ygot.ValidatedGoStruct) error

ConfigCallback is the signature of the function to apply a validated config to the physical device.

type GoStructEnumData

type GoStructEnumData map[string]map[int64]ygot.EnumDefinition

GoStructEnumData is the data type to maintain GoStruct enum type.

type JSONUnmarshaler

type JSONUnmarshaler func([]byte, ygot.GoStruct, ...ytypes.UnmarshalOpt) error

JSONUnmarshaler is the signature of the Unmarshal() function in the GoStruct code generated by openconfig ygot library.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model contains the model data and GoStruct information for the device to config.

func NewModel

NewModel returns an instance of Model struct.

func (*Model) NewConfigStruct

func (m *Model) NewConfigStruct(jsonConfig []byte) (ygot.ValidatedGoStruct, error)

NewConfigStruct creates a ValidatedGoStruct of this model from jsonConfig. If jsonConfig is nil, creates an empty GoStruct.

func (*Model) SupportedModels

func (m *Model) SupportedModels() []string

SupportedModels returns a list of supported models.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server struct maintains the data structure for device config and implements the interface of gnmi server. It supports Capabilities, Get, and Set APIs. Typical usage:

g := grpc.NewServer()
s, err := Server.NewServer(model, config, callback)
pb.NewServer(g, s)
reflection.Register(g)
listen, err := net.Listen("tcp", ":8080")
g.Serve(listen)

For a real device, apply the config changes to the hardware in the callback function. Arguments:

newConfig: new root config to be applied on the device.
func callback(newConfig ygot.ValidatedGoStruct) error {
		// Apply the config to your device and return nil if success. return error if fails.
		//
		// Do something ...
}

func NewServer

func NewServer(model *Model, config []byte, callback ConfigCallback) (*Server, error)

NewServer creates an instance of Server with given json config.

func (*Server) Capabilities

func (s *Server) Capabilities(ctx context.Context, req *pb.CapabilityRequest) (*pb.CapabilityResponse, error)

Capabilities returns supported encodings and supported models.

func (*Server) Get

func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (*pb.GetResponse, error)

Get implements the Get RPC in gNMI spec.

func (*Server) InternalUpdate

func (s *Server) InternalUpdate(fp func(config ygot.ValidatedGoStruct) error) error

InternalUpdate is an experimental feature to let the server update its internal states. Use it with your own risk.

func (*Server) Set

func (s *Server) Set(ctx context.Context, req *pb.SetRequest) (*pb.SetResponse, error)

Set implements the Set RPC in gNMI spec.

func (*Server) Subscribe

func (s *Server) Subscribe(stream pb.GNMI_SubscribeServer) error

Subscribe method is not implemented.

Directories

Path Synopsis
Package modeldata contains the following model data in gnmi proto struct: openconfig-interfaces 2.0.0, openconfig-openflow 0.1.0, openconfig-platform 0.5.0, openconfig-system 0.2.0.
Package modeldata contains the following model data in gnmi proto struct: openconfig-interfaces 2.0.0, openconfig-openflow 0.1.0, openconfig-platform 0.5.0, openconfig-system 0.2.0.
gostruct
Package gostruct is a generated package which contains definitions of structs which represent a YANG schema.
Package gostruct is a generated package which contains definitions of structs which represent a YANG schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL