v0.0.0-...-47ee895 Latest Latest

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 26 Imported by: 0




View Source
const (

	// HostnameArg is the value to be replaced by the actual hostname
	HostnameArg = "HOSTNAME"


This section is empty.


func ArbitrationExt

func ArbitrationExt(s string) (*gnmi_ext.Extension, error)

ArbitrationExt takes a string representation of a master arbitration value (e.g. "23", "role:42") and return a *gnmi_ext.Extension.

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 DialContext

func DialContext(ctx context.Context, cfg *Config) (pb.GNMIClient, error)

DialContext 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:


func Get

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

Get sends a GetRequest to the given server.

func GetWithRequest

func GetWithRequest(ctx context.Context, client pb.GNMIClient,
	req *pb.GetRequest) error

GetWithRequest takes a fully formed GetRequest, performs the Get, and displays any response.

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(ctx context.Context, 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 ParseHostnames

func ParseHostnames(list string) ([]string, error)

ParseHostnames parses a comma-separated list of names and replaces HOSTNAME with the current hostname in it

func Set

func Set(ctx context.Context, client pb.GNMIClient, setOps []*Operation,
	exts ...*gnmi_ext.Extension) (*pb.SetResponse, 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 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. Deprecated: Use SubscribeErr instead.

func SubscribeErr

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

SubscribeErr makes a gNMI.Subscribe call and writes the responses to the respChan. Before returning respChan will be closed.

func TypedValue

func TypedValue(val interface{}) *pb.TypedValue

TypedValue marshals an interface into a gNMI TypedValue value


type Config

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

Config is the gnmi.Client config

type Operation

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

Operation describes an gNMI operation.

type PublishFunc

type PublishFunc func(addr string, message proto.Message)

PublishFunc is the method to publish responses

type SubscribeOptions

type SubscribeOptions struct {
	UpdatesOnly       bool
	Prefix            string
	Mode              string
	StreamMode        string
	SampleInterval    uint64
	SuppressRedundant bool
	HeartbeatInterval uint64
	Paths             [][]string
	Origin            string
	Target            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