gnmi

package
v0.0.0-...-cc18b67 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

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

Variables

This section is empty.

Functions

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 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 sends a GetRequest to the given client.

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(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) 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. 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.

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

func ParseFlags

func ParseFlags() (*Config, []string)

ParseFlags reads arguments from stdin and returns a populated Config object and a list of paths to subscribe to

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