southbound

package
v0.6.6 Latest Latest
Warning

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

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

Documentation

Overview

Package southbound implements configuration of network devices via gNMI clients.

Index

Constants

This section is empty.

Variables

View Source
var GnmiBaseClientFactory = func() BaseClientInterface {
	return gnmiBaseClientImpl{
		&client.BaseClient{},
	}
}

GnmiBaseClientFactory : Default BaseClient creation.

View Source
var GnmiClientFactory = func(ctx context.Context, d client.Destination) (GnmiClient, error) {
	openconfigClient, err := gclient.New(ctx, d)
	if err != nil {
		return nil, err
	}
	c := openconfigClient.(*gclient.Client)
	return gnmiClientImpl{
		c: c,
	}, err
}

GnmiClientFactory : Default GnmiClient creation.

View Source
var TargetGenerator func() TargetIf = NewTarget

TargetGenerator is a function for generating gnmi southbound Targets Default target generator is the NewTarget func below - can be overridden for tests

View Source
var Targets = make(map[topodevice.ID]TargetIf)

Targets is a global cache of connected targets

Functions

func NewSubscribeRequest

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

NewSubscribeRequest returns a SubscribeRequest for the given paths

Types

type BaseClientInterface

type BaseClientInterface interface {
	Subscribe(context.Context, client.Query, ...string) error
}

BaseClientInterface : interface to hide struct dependency on client.BaseClient. Can be overridden by tests.

type GnmiClient

type GnmiClient interface {
	Capabilities(ctx context.Context, r *gpb.CapabilityRequest) (*gpb.CapabilityResponse, error)
	Get(ctx context.Context, r *gpb.GetRequest) (*gpb.GetResponse, error)
	Set(ctx context.Context, r *gpb.SetRequest) (*gpb.SetResponse, error)
	Subscribe(ctx context.Context, q client.Query) error
	Close() error
}

GnmiClient : interface to hide struct dependency on gnmi.client. Can be overridden by tests.

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

type Target

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

Target struct for connecting to gNMI

func (*Target) Capabilities

func (target *Target) Capabilities(ctx context.Context, request *gpb.CapabilityRequest) (*gpb.CapabilityResponse, error)

Capabilities get capabilities according to a formatted request

func (*Target) CapabilitiesWithString

func (target *Target) CapabilitiesWithString(ctx context.Context, request string) (*gpb.CapabilityResponse, error)

CapabilitiesWithString allows a request for the capabilities by a string - can be empty

func (*Target) Client

func (target *Target) Client() GnmiClient

Client allows retrieval of the context for the target

func (*Target) Close

func (target *Target) Close() error

Close closes the target

func (*Target) ConnectTarget

func (target *Target) ConnectTarget(ctx context.Context, device topodevice.Device) (topodevice.ID, error)

ConnectTarget connects to a given Device according to the passed information establishing a channel to it. TODO make asyc TODO lock channel to allow one request to device at each time

func (*Target) Context

func (target *Target) Context() *context.Context

Context allows retrieval of the context for the target

func (*Target) Destination

func (target *Target) Destination() *client.Destination

Destination allows retrieval of the context for the target

func (*Target) Get

func (target *Target) Get(ctx context.Context, request *gpb.GetRequest) (*gpb.GetResponse, error)

Get can make a get request according to a formatted request

func (*Target) GetWithString

func (target *Target) GetWithString(ctx context.Context, request string) (*gpb.GetResponse, error)

GetWithString can make a get request according by a string - can be empty

func (*Target) Set

func (target *Target) Set(ctx context.Context, request *gpb.SetRequest) (*gpb.SetResponse, error)

Set can make a set request according to a formatted request

func (*Target) SetWithString

func (target *Target) SetWithString(ctx context.Context, request string) (*gpb.SetResponse, error)

SetWithString can make a set request according by a string

func (*Target) Subscribe

func (target *Target) Subscribe(ctx context.Context, request *gpb.SubscribeRequest, handler client.ProtoHandler) error

Subscribe initiates a subscription to a target and set of paths by establishing a new channel

type TargetIf

type TargetIf interface {
	ConnectTarget(ctx context.Context, device topodevice.Device) (topodevice.ID, error)
	//Capabilities(ctx context.Context, request *gpb.CapabilityRequest) (*gpb.CapabilityResponse, error)
	CapabilitiesWithString(ctx context.Context, request string) (*gpb.CapabilityResponse, error)
	Get(ctx context.Context, request *gpb.GetRequest) (*gpb.GetResponse, error)
	GetWithString(ctx context.Context, request string) (*gpb.GetResponse, error)
	Set(ctx context.Context, request *gpb.SetRequest) (*gpb.SetResponse, error)
	SetWithString(ctx context.Context, request string) (*gpb.SetResponse, error)
	Subscribe(ctx context.Context, request *gpb.SubscribeRequest, handler client.ProtoHandler) error
	Context() *context.Context
	Destination() *client.Destination
	Client() GnmiClient
	Close() error
}

TargetIf defines the API for Target

func GetTarget

func GetTarget(key topodevice.ID) (TargetIf, error)

GetTarget attempts to get a specific target from the targets cache

func NewTarget

func NewTarget() TargetIf

NewTarget is a method for constructing a target

Directories

Path Synopsis
Package synchronizer synchronizes configurations down to devices
Package synchronizer synchronizes configurations down to devices

Jump to

Keyboard shortcuts

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