gnmi

package
v0.0.0-...-9a46783 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0, Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capabilities

func Capabilities(ctx context.Context, client pb.GNMIClient) error

Capabilities retuns the capabilities of the client.

func DecimalToFloat

func DecimalToFloat(dec *pb.Decimal64) float64

DecimalToFloat converts a gNMI Decimal64 to a float64

func Dial

func Dial(cfg *Config) (pb.GNMIClient, error)

Dial connects to a gnmi service and returns a client

func ExtractValue

func ExtractValue(update *pb.Update) (interface{}, error)

ExtractValue pulls a value out of a gNMI Update, parsing JSON if present. Possible return types:

string
int64
uint64
bool
[]byte
float32
*gnmi.Decimal64
json.Number
*any.Any
[]interface{}
map[string]interface{}

func Get

func Get(ctx context.Context, client pb.GNMIClient, paths [][]string, origin string) error

Get sents a GetRequest to the given client.

func JoinPaths

func JoinPaths(paths ...*pb.Path) *pb.Path

JoinPaths joins multiple gnmi paths and returns a string representation

func LogSubscribeResponse

func LogSubscribeResponse(response *pb.SubscribeResponse) error

LogSubscribeResponse logs update responses to stderr.

func NewContext

func NewContext(ctx context.Context, cfg *Config) context.Context

NewContext returns a new context with username and password metadata if they are set in cfg.

func NewGetRequest

func NewGetRequest(paths [][]string, origin string) (*pb.GetRequest, error)

NewGetRequest returns a GetRequest for the given paths

func NewSubscribeRequest

func NewSubscribeRequest(subscribeOptions *SubscribeOptions) (*pb.SubscribeRequest, error)

NewSubscribeRequest returns a SubscribeRequest for the given paths

func NotificationToMap

func NotificationToMap(notif *gnmi.Notification) (map[string]interface{}, error)

NotificationToMap converts a Notification into a map[string]interface{}

func ParseGNMIElements

func ParseGNMIElements(elms []string) (*pb.Path, error)

ParseGNMIElements builds up a gnmi path, from user-supplied text

func Set

func Set(ctx context.Context, client pb.GNMIClient, setOps []*Operation) error

Set sends a SetRequest to the given client.

func SplitPath

func SplitPath(path string) []string

SplitPath splits a gnmi path according to the spec. See https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-path-conventions.md No validation is done. Behavior is undefined if path is an invalid gnmi path. TODO: Do validation?

func SplitPaths

func SplitPaths(paths []string) [][]string

SplitPaths splits multiple gnmi paths

func StrPath

func StrPath(path *pb.Path) string

StrPath builds a human-readable form of a gnmi path. e.g. /a/b/c[e=f]

func StrUpdateVal

func StrUpdateVal(u *pb.Update) string

StrUpdateVal will return a string representing the value within the supplied update

func StrVal

func StrVal(val *pb.TypedValue) string

StrVal will return a string representing the supplied value

func Subscribe

func Subscribe(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions,
	respChan chan<- *pb.SubscribeResponse, errChan chan<- error)

Subscribe sends a SubscribeRequest to the given client.

Types

type Config

type Config struct {
	Addr        string
	CAFile      string
	CertFile    string
	KeyFile     string
	Password    string
	Username    string
	TLS         bool
	Compression string
	DialOptions []grpc.DialOption
}

Config is the gnmi.Client config

type Operation

type Operation struct {
	Type   string
	Origin string
	Path   []string
	Val    string
}

Operation describes an gNMI operation.

type SubscribeOptions

type SubscribeOptions struct {
	UpdatesOnly       bool
	Prefix            string
	Mode              string
	StreamMode        string
	SampleInterval    uint64
	HeartbeatInterval uint64
	Paths             [][]string
	Origin            string
}

SubscribeOptions is the gNMI subscription request options

Jump to

Keyboard shortcuts

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