ddriver

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIEstablisher

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

APIEstablisher establishes control or ownership of resources in the API server for a parent.

func NewAPIEstablisher

func NewAPIEstablisher(client resource.ClientApplicator, log logging.Logger, deviceName, nsConfig, nsDeployment string) *APIEstablisher

NewAPIEstablisher creates a new APIEstablisher.

func (*APIEstablisher) UpdateConfigMap

func (e *APIEstablisher) UpdateConfigMap(ctx context.Context, cfg *string) error

UpdateDeviceStatusReady updates a set of resources

func (*APIEstablisher) UpdateDeviceStatusNotReady

func (e *APIEstablisher) UpdateDeviceStatusNotReady(ctx context.Context, dDetails *ndddvrv1.DeviceDetails) error

UpdateDeviceStatusReady updates a set of resources

func (*APIEstablisher) UpdateDeviceStatusReady

func (e *APIEstablisher) UpdateDeviceStatusReady(ctx context.Context, dDetails *ndddvrv1.DeviceDetails) error

UpdateDeviceStatusReady updates a set of resources

type Cache

type Cache struct {
	netwdevpb.UnimplementedCacheStatusServer
	netwdevpb.UnimplementedCacheUpdateServer

	Mutex                 sync.RWMutex
	NewK8sOperatorUpdates bool
	Data                  map[int]map[string]*ResourceData
	Levels                []int
	NewOnChangeUpdates    bool
	OnChangeReApplyCache  bool
	OnChangeDeletes       []string
	OnChangeUpdates       []string
	OnChangeDeviations    map[string]*Deviation
	CurrentConfig         []byte
	// contains filtered or unexported fields
}

Cache contains the

func NewCache

func NewCache(log logging.Logger) *Cache

func (*Cache) CheckCache

func (c *Cache) CheckCache(dep string) (int, string, bool)

CheckCache checks if an object exists in the cache

func (*Cache) CheckMissingDependency

func (c *Cache) CheckMissingDependency(dependencies []string) bool

CheckMissingDependency validates the dependencies of the path

func (*Cache) GetCurrentConfig

func (c *Cache) GetCurrentConfig() []byte

func (*Cache) GetNewK8sOperatorUpdates

func (c *Cache) GetNewK8sOperatorUpdates() bool

func (*Cache) GetNewOnChangeUpdates

func (c *Cache) GetNewOnChangeUpdates() bool

func (*Cache) GetOnChangeDeletes

func (c *Cache) GetOnChangeDeletes() []string

func (*Cache) GetOnChangeDeviations

func (c *Cache) GetOnChangeDeviations() map[string]*Deviation

func (*Cache) GetOnChangeReApplyCache

func (c *Cache) GetOnChangeReApplyCache() bool

func (*Cache) GetOnChangeUpdates

func (c *Cache) GetOnChangeUpdates() []string

func (*Cache) GetParentDependencyDeleteStatus

func (c *Cache) GetParentDependencyDeleteStatus(dependencies []string) bool

func (*Cache) LocatePathInCache

func (c *Cache) LocatePathInCache(pel []*gnmi.PathElem) (interface{}, bool, error)

func (*Cache) Lock

func (c *Cache) Lock()

func (*Cache) Request

Request is a GRPC service that provides the cache status

func (*Cache) SetCurrentConfig

func (c *Cache) SetCurrentConfig(b []byte)

func (*Cache) SetNewK8sOperatorUpdates

func (c *Cache) SetNewK8sOperatorUpdates(b bool)

func (*Cache) SetNewOnChangeUpdates

func (c *Cache) SetNewOnChangeUpdates(b bool)

func (*Cache) SetOnChangeCacheUpdates

func (c *Cache) SetOnChangeCacheUpdates(autoPilot bool, onChangeDeviations map[string]*Deviation)

func (*Cache) SetOnChangeReApplyCache

func (c *Cache) SetOnChangeReApplyCache(b bool)

func (*Cache) SetStatus

SetStatus sets the status of the data l = level, o = object

func (*Cache) ShowCacheStatus

func (c *Cache) ShowCacheStatus()

func (*Cache) Unlock

func (c *Cache) Unlock()

func (*Cache) Update

Update is a GRPC service that updates the cache with new information

func (*Cache) UpdateLeafRefDependency

func (c *Cache) UpdateLeafRefDependency(leafRefDep string)

UpdateLeafRefDependency validates and updates the leafref dependency status

type Collector

type Collector interface {
	Lock()
	Unlock()
	GetSubscription(subName string) bool
	StopSubscription(ctx context.Context, sub string) error
	StartSubscription(ctx context.Context, subName string, sub []string) error
}

type Deviation

type Deviation struct {
	OnChangeAction  netwdevpb.Deviation_OnChangeAction
	Pel             []*gnmi.PathElem
	Value           []byte
	DeviationAction netwdevpb.Deviation_DeviationAction
	Change          bool
}

type DeviceCollector

type DeviceCollector struct {
	TargetReceiveBuffer uint
	RetryTimer          time.Duration
	Target              *collector.Target

	Subscriptions map[string]*Subscription
	Mutex         sync.RWMutex
	// contains filtered or unexported fields
}

func NewDeviceCollector

func NewDeviceCollector(t *collector.Target, log logging.Logger) *DeviceCollector

func (*DeviceCollector) GetSubscription

func (c *DeviceCollector) GetSubscription(subName string) bool

func (*DeviceCollector) Lock

func (c *DeviceCollector) Lock()

func (*DeviceCollector) StartSubscription

func (c *DeviceCollector) StartSubscription(dctx context.Context, subName string, sub []string) error

func (*DeviceCollector) StopSubscription

func (c *DeviceCollector) StopSubscription(ctx context.Context, sub string) error

func (*DeviceCollector) Unlock

func (c *DeviceCollector) Unlock()

type DeviceDiscoverer

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

func NewDeviceDiscoverer

func NewDeviceDiscoverer(target *collector.Target, log logging.Logger) *DeviceDiscoverer

func (*DeviceDiscoverer) Discover

func (d *DeviceDiscoverer) Discover(ctx context.Context) (nddv1.DeviceType, error)

type DeviceDriver

type DeviceDriver struct {
	Device            devices.Device
	Objects           Establisher
	Discoverer        Discoverer
	Collector         Collector
	GrpcServerPort    *int
	GrpcServerAddress *string
	DeviceName        *string
	TargetConfig      *collector.TargetConfig
	Target            *collector.Target
	K8sClient         *client.Client
	NetworkNodeKind   *string
	DeviceDetails     *ndddvrv1.DeviceDetails
	InitialConfig     map[string]interface{}
	GrpcServer        *grpc.Server

	AutoPilot *bool
	Debug     *bool

	Registrator *Registrator
	Cache       *Cache
	SubCh       chan bool
	StopCh      chan struct{}
	Ctx         context.Context
	// contains filtered or unexported fields
}

DeviceDriver contains the device driver information

func NewDeviceDriver

func NewDeviceDriver(opts ...Option) (*DeviceDriver, error)

NewDeviceDriver function defines a new device driver

func (*DeviceDriver) DeletedUnwantedConfiguration

func (d *DeviceDriver) DeletedUnwantedConfiguration(f map[string]interface{}, prefix string)

func (*DeviceDriver) InitDeviceDriverControllers

func (d *DeviceDriver) InitDeviceDriverControllers() error

InitDeviceDriverControllers initializes the device driver controller

func (*DeviceDriver) InitGrpcServer

func (d *DeviceDriver) InitGrpcServer() error

func (*DeviceDriver) InitSubscriptionExceptionPaths

func (d *DeviceDriver) InitSubscriptionExceptionPaths() error

func (*DeviceDriver) Start

func (d *DeviceDriver) Start() error

func (*DeviceDriver) StartGnmiSubscriptionHandler

func (d *DeviceDriver) StartGnmiSubscriptionHandler()

func (*DeviceDriver) StartGrpcServer

func (d *DeviceDriver) StartGrpcServer(s string) error

StartGRPCServer starts the grpcs server

func (*DeviceDriver) StartReconcileProcess

func (d *DeviceDriver) StartReconcileProcess() error

StartReconcileProcess starts the driver reconciiation process

func (*DeviceDriver) StopGrpcServer

func (d *DeviceDriver) StopGrpcServer()

func (*DeviceDriver) UpdateLatestConfigWithGnmi

func (d *DeviceDriver) UpdateLatestConfigWithGnmi() error

type Discoverer

type Discoverer interface {
	// Discover discovers the device through gnmi
	Discover(ctx context.Context) (nddv1.DeviceType, error)
}

A Discoverer discovers device kinds

type ElementKeyValue

type ElementKeyValue struct {
	Element  string
	KeyName  string
	KeyValue interface{}
}

ElementKeyValue struct

type Establisher

type Establisher interface {
	// Update device status to ready state
	UpdateDeviceStatusReady(ctx context.Context, dd *ndddvrv1.DeviceDetails) error

	// Update device status to not ready state
	UpdateDeviceStatusNotReady(ctx context.Context, dd *ndddvrv1.DeviceDetails) error

	// Update config map
	UpdateConfigMap(ctx context.Context, cfg *string) error
}

An Establisher brings up or down a set of resources in the API server

type Option

type Option func(d *DeviceDriver)

Option is a function to initialize the options of the device driver

func WithAutoPilot

func WithAutoPilot(b *bool) Option

func WithContext

func WithContext() Option

func WithDebug

func WithDebug(b *bool) Option

func WithDeviceName

func WithDeviceName(n *string) Option

WithDeviceName initializes the device name in the device driver

func WithEstablisher

func WithEstablisher(er *APIEstablisher) Option

WithEstablisher specifies how the ddriver should create/delete/update resources through the k8s api

func WithGrpcServer

func WithGrpcServer(s *string) Option

WithGrpcServer initializes the cache server in the device driver

func WithGzip

func WithGzip(b *bool) Option

WithGzip initializes targetconfig

func WithInsecure

func WithInsecure(b *bool) Option

WithInsecure initializes insecure

func WithK8sClient

func WithK8sClient(c *client.Client) Option

WithDeviceName initializes the device name in the device driver

func WithLogger

func WithLogger(log logging.Logger) Option

WithLogger specifies how the Reconciler should log messages.

func WithPassword

func WithPassword(p *string) Option

WithPassword initializes the password

func WithSkipVerify

func WithSkipVerify(b *bool) Option

WithSkipVerify initializes skipVerify

func WithTLSCA

func WithTLSCA(t *string) Option

WithTLSCA initializes TLSCA

func WithTLSCert

func WithTLSCert(t *string) Option

WithTLSCert initializes TLSCert

func WithTLSKey

func WithTLSKey(t *string) Option

WithTLSKey initializes TLSKey

func WithTargetAddress

func WithTargetAddress(t *string) Option

WithTargetAddress initializes the address in the gnmi target

func WithTargetName

func WithTargetName(n *string) Option

WithTargetName initializes the name in the gnmi target

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout initializes the timeout in the protocol of the device driver

func WithUsername

func WithUsername(u *string) Option

WithUsername initializes the username

type Registrator

type Registrator struct {
	netwdevpb.UnimplementedRegistrationServer

	DeviceKind             string
	DeviceMatch            string
	Subscriptions          []string
	ExceptionPaths         []string
	ExplicitExceptionPaths []string
	// contains filtered or unexported fields
}

func NewRegistrator

func NewRegistrator(log logging.Logger, subCh chan bool) *Registrator

func (*Registrator) GetDeviceKind

func (r *Registrator) GetDeviceKind() string

func (*Registrator) GetDeviceMatch

func (r *Registrator) GetDeviceMatch() string

func (*Registrator) GetExceptionPaths

func (r *Registrator) GetExceptionPaths() []string

func (*Registrator) GetExplicitExceptionPaths

func (r *Registrator) GetExplicitExceptionPaths() []string

func (*Registrator) GetSubscriptions

func (r *Registrator) GetSubscriptions() []string

func (*Registrator) Register

Request is a GRPC service that provides the cache status

type ResourceData

type ResourceData struct {
	Config      *netwdevpb.CacheUpdateRequest
	CacheStatus netwdevpb.CacheStatusReply_CacheResourceStatus // Status of the resource
}

type Subscription

type Subscription struct {
	StopCh   chan bool
	CancelFn context.CancelFunc
}

Jump to

Keyboard shortcuts

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