model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllDataNodes

func FindAllDataNodes(gs ygot.GoStruct, path *gpb.Path) ([]interface{}, bool)

FindAllDataNodes - finds all nodes matched to the gNMI Path.

func FindAllSchemaPaths

func FindAllSchemaPaths(gs ygot.GoStruct, path *gpb.Path) ([]string, bool)

FindAllSchemaPaths - finds all schema nodes matched to the gNMI Path.

func FindAllSchemaTypes

func FindAllSchemaTypes(gs ygot.GoStruct, path *gpb.Path) ([]reflect.Type, bool)

FindAllSchemaTypes - finds all schema nodes matched to the gNMI Path.

func NewGoStruct

func NewGoStruct(m *Model, jsonData []byte) (ygot.ValidatedGoStruct, error)

NewGoStruct - creates a ValidatedGoStruct of this model from jsonData. If jsonData is nil, creates an empty GoStruct.

Types

type ConfigCallback

type ConfigCallback interface {
	DataCallback
	ConfigCallback(ygot.GoStruct) error
}

ConfigCallback is an interface to be invoked by the configuration

type DataAndPath

type DataAndPath struct {
	Value interface{}
	Path  string
}

DataAndPath - used to retrieve of the data and gNMI path from ygot go structure.

func FindAllData

func FindAllData(gs ygot.GoStruct, path *gpb.Path) ([]*DataAndPath, bool)

FindAllData - finds all nodes matched to the gNMI Path.

type DataCallback

type DataCallback interface {
}

DataCallback is an interface to be invoked by the modeled data control

type GoStructEnumData

type GoStructEnumData map[string]map[int64]ygot.EnumDefinition

GoStructEnumData is the data type to maintain GoStruct enum type.

type JSONUnmarshaler

type JSONUnmarshaler func([]byte, ygot.GoStruct, ...ytypes.UnmarshalOpt) error

JSONUnmarshaler is the signature of the Unmarshal() function in the GoStruct code generated by openconfig ygot library.

type Model

type Model struct {
	StructRootType  reflect.Type
	SchemaTree      map[string]*yang.Entry
	SchemaTreeRoot  *yang.Entry
	JSONUnmarshaler JSONUnmarshaler
	EnumData        GoStructEnumData
	// contains filtered or unexported fields
}

Model contains the model data and GoStruct information for the device.

func NewCustomModel

func NewCustomModel(
	modelData []*gpb.ModelData,
	structRootType reflect.Type,
	schemaTree map[string]*yang.Entry,
	jSONUnmarshaler JSONUnmarshaler,
	enumData GoStructEnumData,
) *Model

NewCustomModel returns an instance of Model struct.

func NewModel

func NewModel() *Model

NewModel returns an instance of Model struct.

func (*Model) CheckModels

func (m *Model) CheckModels(models []*gpb.ModelData) error

CheckModels checks whether models are supported by the model. Return error if anything is unsupported.

func (*Model) FindAllData

func (m *Model) FindAllData(gs ygot.GoStruct, path *gpb.Path) ([]*DataAndPath, bool)

FindAllData - finds all data nodes matched to the gNMI Path.

func (*Model) FindAllPaths

func (m *Model) FindAllPaths(path *gpb.Path) ([]string, bool)

FindAllPaths - finds all XPaths against to the gNMI Path that has wildcard

func (*Model) FindSchema

func (m *Model) FindSchema(t reflect.Type) *yang.Entry

FindSchema - find the yang.Entry for schema info.

func (*Model) FindSchemaByName

func (m *Model) FindSchemaByName(parent *yang.Entry, name string) *yang.Entry

FindSchemaByName - find the yang.Entry for schema info.

func (*Model) FindSchemaByPath

func (m *Model) FindSchemaByPath(path string) (*yang.Entry, error)

FindSchemaByPath - find the yang.Entry for schema info.

func (*Model) FindSchemaPaths

func (m *Model) FindSchemaPaths(prefix, path *gpb.Path) ([]string, bool)

FindSchemaPaths - validates all schema of the gNMI Path.

func (*Model) GetModelData

func (m *Model) GetModelData() []*gpb.ModelData

GetModelData - returns ModelData of the model.

func (*Model) SupportedModels

func (m *Model) SupportedModels() []string

SupportedModels returns a list of supported models.

func (*Model) ValidatePathSchema

func (m *Model) ValidatePathSchema(path *gpb.Path) bool

ValidatePathSchema - validates all schema of the gNMI Path.

type ModelData

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

ModelData - the data instance for the model

func NewModelData

func NewModelData(m *Model, jsonData []byte, yamlData []byte, callback DataCallback, disableYdbChannel bool) (*ModelData, error)

NewModelData creates a ValidatedGoStruct of this model from jsonData. If jsonData is nil, creates an empty GoStruct.

func (*ModelData) ChangeRoot

func (mdata *ModelData) ChangeRoot(root ygot.ValidatedGoStruct) error

ChangeRoot - replaces the root of the Model Data

func (*ModelData) Close

func (mdata *ModelData) Close()

Close the connected YDB instance

func (*ModelData) Create

func (mdata *ModelData) Create(keys []string, key string, tag string, value string) error

Create - constructs ModelData

func (*ModelData) Delete

func (mdata *ModelData) Delete(keys []string, key string) error

Delete - constructs ModelData

func (*ModelData) GetRoot

func (mdata *ModelData) GetRoot() ygot.ValidatedGoStruct

GetRoot - replaces the root of the Model Data

func (*ModelData) GetSyncUpdatePath

func (mdata *ModelData) GetSyncUpdatePath(prefix *gpb.Path, paths []*gpb.Path) []string

GetSyncUpdatePath - synchronizes the data in the path

func (*ModelData) Lock

func (mdata *ModelData) Lock()

Lock - Lock the YDB instance for use.

func (*ModelData) RLock

func (mdata *ModelData) RLock()

RLock - Lock the YDB instance for read.

func (*ModelData) RUnlock

func (mdata *ModelData) RUnlock()

RUnlock - Unlock of the YDB instance for read.

func (*ModelData) Replace

func (mdata *ModelData) Replace(keys []string, key string, tag string, value string) error

Replace - constructs ModelData

func (*ModelData) RunSyncUpdate

func (mdata *ModelData) RunSyncUpdate(syncIgnoreTime time.Duration, syncPaths []string)

RunSyncUpdate - synchronizes & update the data in the path. It locks model data.

func (*ModelData) SetDelete

func (mdata *ModelData) SetDelete(jsonTree map[string]interface{}, prefix, path *gpb.Path) (*gpb.UpdateResult, error)

SetDelete deletes the path from the json tree if the path exists. If success, it calls the callback function to apply the change to the device hardware.

func (*ModelData) SetReplaceOrUpdate

func (mdata *ModelData) SetReplaceOrUpdate(jsonTree map[string]interface{}, op gpb.UpdateResult_Operation, prefix, path *gpb.Path, val *gpb.TypedValue) (*gpb.UpdateResult, error)

SetReplaceOrUpdate validates the replace or update operation to be applied to the device, modifies the json tree of the config struct, then calls the callback function to apply the operation to the device hardware.

func (*ModelData) Unlock

func (mdata *ModelData) Unlock()

Unlock - Unlock of the YDB instance.

func (*ModelData) UpdateEnd

func (mdata *ModelData) UpdateEnd()

UpdateEnd - indicates the end of ModelData construction

func (*ModelData) UpdateStart

func (mdata *ModelData) UpdateStart()

UpdateStart - indicates the start of ModelData construction

type OnChangeCallback

type OnChangeCallback interface {
	DataCallback
	OnChangeStarted(changes ygot.GoStruct)
	OnChangeCreated(path []string, changes ygot.GoStruct)
	OnChangeReplaced(path []string, changes ygot.GoStruct)
	OnChangeDeleted(path []string)
	OnChangeFinished(changes ygot.GoStruct)
}

OnChangeCallback is an interface to be invoked upon the model data changes

Directories

Path Synopsis
Package gostruct is a generated package which contains definitions of structs which represent a YANG schema.
Package gostruct is a generated package which contains definitions of structs which represent a YANG schema.

Jump to

Keyboard shortcuts

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