gnmi

package
v0.0.0-...-ad9c0bf Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CapabilitiesTests = []struct {
	Desc          string
	ExpVersion    string
	ExpModels     []*gnmi.ModelData
	ExpEncodings  []gnmi.Encoding
	ExpExtensions []*gnmi_ext.Extension
}{{
	Desc:       "retrieve system capabilities",
	ExpVersion: "0.7.0",
	ExpModels: []*gnmi.ModelData{
		{Name: "openconfig-interfaces", Organization: "OpenConfig working group", Version: "2.0.0"},
		{Name: "openconfig-openflow", Organization: "OpenConfig working group", Version: "0.1.0"},
		{Name: "openconfig-platform", Organization: "OpenConfig working group", Version: "0.5.0"},
		{Name: "openconfig-system", Organization: "OpenConfig working group", Version: "0.2.0"},
	},
	ExpEncodings: []gnmi.Encoding{
		gnmi.Encoding(gnmi.Encoding_JSON),
		gnmi.Encoding(gnmi.Encoding_JSON_IETF),
	},
	ExpExtensions: []*gnmi_ext.Extension{},
}}
View Source
var GetTests = []struct {
	Desc            string
	XPaths          []string
	ExtractorString func(n []*gnmi.Notification) string
	ExpResp         interface{}
	ExtractorUInt   func(n []*gnmi.Notification) uint64
	MinResp         interface{}
}{
	{
		Desc:            "get system config hostname",
		XPaths:          []string{"/system/config/hostname"},
		ExtractorString: ExtractSingleStringValueFromResponse,
		ExpResp:         "target.gnxi.lan",
	},
	{
		Desc:            "get platform component os state version",
		XPaths:          []string{"/components/component[name=os]/state/description"},
		ExtractorString: ExtractSingleStringValueFromResponse,
		ExpResp:         "2.9.2",
	},
	{
		Desc:            "get system openflow controller connection config address",
		XPaths:          []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/address"},
		ExtractorString: ExtractSingleStringValueFromResponse,
		ExpResp:         "172.18.0.2",
	},
	{
		Desc:          "get system openflow controller connection config port",
		XPaths:        []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/port"},
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		ExpResp:       uint64(6653),
	},
	{
		Desc:          "get interface state counters in-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/in-pkts"},
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
	{
		Desc:          "get interface state counters out-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/out-pkts"},
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
}
View Source
var SetTests = []struct {
	Desc                  string
	DeleteXPaths          []string
	RollbackDeleteXPaths  []string
	ReplaceXPaths         []string
	RollbackReplaceXPaths []string
	UpdateXPaths          []string
	RollbackUpdateXPaths  []string
	ExtractorString       func(n []*gnmi.Notification) string
	ExpResp               interface{}
	RollbackExpResp       interface{}
	ExtractorUInt         func(n []*gnmi.Notification) uint64
	MinResp               interface{}
	Type                  string
	OVSResultKey          string
	OVSDataBefore         string
	OVSDataAfter          string
}{
	{
		Desc:                 "set system openflow controller connection config address",
		UpdateXPaths:         []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/address:172.18.0.3"},
		RollbackUpdateXPaths: []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/address:172.18.0.2"},
		ExtractorString:      ExtractSingleStringValueFromResponse,
		ExpResp:              "172.18.0.3",
		RollbackExpResp:      "172.18.0.2",
		Type:                 ovs.ControllerTable,
		OVSResultKey:         "target",
		OVSDataBefore:        "ssl:172.18.0.2:6653",
		OVSDataAfter:         "ssl:172.18.0.3:6653",
	},
	{
		Desc:                 "set system openflow controller connection config port",
		UpdateXPaths:         []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/port:6654"},
		RollbackUpdateXPaths: []string{"/system/openflow/controllers/controller[name=main]/connections/connection[aux-id=0]/config/port:6653"},
		ExtractorUInt:        ExtractSingleUintValueFromResponse,
		ExpResp:              uint64(6654),
		RollbackExpResp:      uint64(6653),
		Type:                 ovs.ControllerTable,
		OVSResultKey:         "target",
		OVSDataBefore:        "ssl:172.18.0.2:6653",
		OVSDataAfter:         "ssl:172.18.0.2:6654",
	},
}
View Source
var SubscribeOnceTests = []struct {
	Desc          string
	XPaths        []string
	ExtractorUInt func(n []*gnmi.Notification) uint64
	MinResp       interface{}
}{
	{
		Desc:          "subscribe to interface state counters in-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/in-pkts"},
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
	{
		Desc:          "subscribe to interface state counters out-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/out-pkts"},
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
}
View Source
var SubscribePollTests = []struct {
	Desc          string
	XPaths        []string
	MaxPollResp   int
	ExtractorUInt func(n []*gnmi.Notification) uint64
	MinResp       interface{}
}{
	{
		Desc:          "subscribe to interface state counters in-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/in-pkts"},
		MaxPollResp:   3,
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
	{
		Desc:          "subscribe to interface state counters out-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/out-pkts"},
		MaxPollResp:   3,
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
}
View Source
var SubscribeStreamTests = []struct {
	Desc          string
	XPaths        []string
	MaxStreamResp int
	ExtractorUInt func(n []*gnmi.Notification) uint64
	MinResp       interface{}
}{
	{
		Desc:          "subscribe to interface state counters in-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/in-pkts"},
		MaxStreamResp: 3,
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
	{
		Desc:          "subscribe to interface state counters out-pkts",
		XPaths:        []string{"/interfaces/interface[name=sw1-eth1]/state/counters/out-pkts"},
		MaxStreamResp: 3,
		ExtractorUInt: ExtractSingleUintValueFromResponse,
		MinResp:       uint64(0),
	},
}

Functions

func ExtractSingleStringValueFromResponse

func ExtractSingleStringValueFromResponse(n []*gnmi.Notification) string

func ExtractSingleUintValueFromResponse

func ExtractSingleUintValueFromResponse(n []*gnmi.Notification) uint64

Types

type Client

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

func NewClient

func NewClient(targetAddress, targetName, encodingName string) *Client

NewClient returns an instance of GNMIClient struct.

func (*Client) Capabilities

func (c *Client) Capabilities(ctx context.Context) (*pb.CapabilityResponse, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, getXPaths []string) (*pb.GetResponse, error)

func (*Client) Set

func (c *Client) Set(ctx context.Context, deleteXPaths, replaceXPaths, updateXPaths []string) (*pb.SetResponse, error)

func (*Client) SubscribeOnce

func (c *Client) SubscribeOnce(ctx context.Context, subscribeXPaths []string) (*pb.SubscribeResponse, error)

func (*Client) SubscribePoll

func (c *Client) SubscribePoll(ctx context.Context, subscribeXPaths []string, respChan chan<- *pb.SubscribeResponse, errChan chan<- error)

func (*Client) SubscribeStream

func (c *Client) SubscribeStream(ctx context.Context, subscribeXPaths []string, respChan chan<- *pb.SubscribeResponse, errChan chan<- error)

Jump to

Keyboard shortcuts

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