schema

package
v0.0.0-...-fc2a63e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: BSD-3-Clause, MPL-2.0 Imports: 26 Imported by: 13

README

configd-schema repository

Overview

The configd/schema package extends standard YANG with configd extensions. Each YANG node type can be extended with these extensions, and additionally there are 'tree', 'model' and 'modelset' nodes that can be extended.

It also provides the point of integration between core configd / sessiond / yangd functionality and VCI components.

Configd extensions

Configd extensions represent proprietary extensions to standard YANG, eg begin / create / update / delete / end action scripts, and allowed, normalize, syntax, validate, secret extensions.

The mechanism for supporting extensions is that when we call the YANG compiler (compile.CompileDir()), we pass in a CompilationExtensions object that conforms to the Extensions interface provided by the compiler. The provided functions return decorated nodes (ExtendedNode) that conform to the schema.Node interface, with additional state and extension information.

CompilationExtensions

In addition to conforming to the compile.Extensions interface, the CompilationExtensions object contains a Dispatcher and a slice of ComponentConfigs. These are provided by the caller (which in our case is the 'configd' application during startup).

Dispatcher

This is provided by golang-brocade-vyatta-yangd/dbus, and provides wrappers around Set/Get and Validate calls over DBUS to VCI components.

Bus address is 'net.vyatta.vci.config.[read|write].'.

ComponentConfig

This is a slice of VCI component configurations as parsed from their DotComponent files. This provides mappings between components, models, YANG modules and model sets.

As the DotComponent files may come from third party applications, we need to validate their content. Different parts of this are done in different places as appropriate.

ModelSet Extension

The ModelSet extension holds a slice of 'services' which represent each component's configuration, along with a dispatcher which provides communication over the DBUS to the components generically.

Documentation

Index

Constants

View Source
const (
	NoFilter   = ""
	SetRunning = "SetRunning"
	GetRunning = "GetRunning"
	GetState   = "GetState"
	Validate   = "Validate"
)

TestLog provides the ability for tests to verify which components had which operations performed on them (validate, set config, get config, get state), and in which order.

Variables

This section is empty.

Functions

func AttrsForPath

func AttrsForPath(st Node, path []string) *pathutil.PathAttrs

func GetHelp

func GetHelp(n yang.Node) string

func NewCompMgr

func NewCompMgr(
	opsMgr OperationsManager,
	svcMgr ServiceManager,
	m yang.ModelSet,
	mappings *ComponentMappings,
) *compMgr

func NormalizePath

func NormalizePath(st Node, ps []string) ([]string, error)

func Parse

func Parse(name, text string) (*parse.Tree, error)

func ParseModuleDir

func ParseModuleDir(dir string) (map[string]*parse.Tree, error)

func ParseModules

func ParseModules(list ...string) (map[string]*parse.Tree, error)

func ParseYang

func ParseYang(locations compile.YangLocator) (map[string]*parse.Tree, error)

func ValidateSchema

func ValidateSchema(
	compMgr ComponentManager,
	sn Node,
	dn datanode.DataNode,
	debug bool,
) (
	[]*exec.Output, []error, bool)

func ValidateSchemaWithLog

func ValidateSchemaWithLog(
	compMgr ComponentManager,
	sn Node,
	dn datanode.DataNode,
	debug bool,
	mustThreshold int,
	logFn func(string, time.Time),
) (
	[]*exec.Output,
	[]error,
	bool,
)

Types

type Binary

type Binary interface {
	yang.Binary
	// contains filtered or unexported methods
}

type Bits

type Bits interface {
	yang.Bits
	// contains filtered or unexported methods
}

type Boolean

type Boolean interface {
	yang.Boolean
	// contains filtered or unexported methods
}

type Case

type Case interface {
	yang.Case
	ExtendedNode
}

type Choice

type Choice interface {
	yang.Choice
	ExtendedNode
}

type CompilationExtensions

type CompilationExtensions struct {
}

Previously contained information passed through YANG compiler. Left in for now in case of future use given full removal requires changes across 3 repositories.

func (*CompilationExtensions) ExtendCase

func (*CompilationExtensions) ExtendCase(
	p parse.Node, y yang.Case,
) (yang.Case, error)

func (*CompilationExtensions) ExtendChoice

func (*CompilationExtensions) ExtendChoice(
	p parse.Node, y yang.Choice,
) (yang.Choice, error)

func (*CompilationExtensions) ExtendContainer

func (*CompilationExtensions) ExtendContainer(
	p parse.Node, y yang.Container,
) (yang.Container, error)

func (*CompilationExtensions) ExtendLeaf

func (*CompilationExtensions) ExtendLeaf(
	p parse.Node, y yang.Leaf,
) (yang.Leaf, error)

func (*CompilationExtensions) ExtendLeafList

func (*CompilationExtensions) ExtendLeafList(
	p parse.Node, y yang.LeafList,
) (yang.LeafList, error)

func (*CompilationExtensions) ExtendList

func (*CompilationExtensions) ExtendList(
	p parse.Node, y yang.List,
) (yang.List, error)

func (*CompilationExtensions) ExtendModel

func (*CompilationExtensions) ExtendModel(
	p parse.Node, m yang.Model, t yang.Tree,
) (yang.Model, error)

func (*CompilationExtensions) ExtendModelSet

func (c *CompilationExtensions) ExtendModelSet(
	m yang.ModelSet,
) (yang.ModelSet, error)

func (*CompilationExtensions) ExtendMust

func (*CompilationExtensions) ExtendMust(
	p parse.Node, m parse.Node,
) (string, error)

func (*CompilationExtensions) ExtendNotification

func (*CompilationExtensions) ExtendNotification(
	p parse.Node, y yang.Notification,
) (yang.Notification, error)

func (*CompilationExtensions) ExtendOpdArgument

func (*CompilationExtensions) ExtendOpdArgument(
	p parse.Node, y yang.OpdArgument,
) (yang.OpdArgument, error)

func (*CompilationExtensions) ExtendOpdCommand

func (*CompilationExtensions) ExtendOpdCommand(
	p parse.Node, y yang.OpdCommand,
) (yang.OpdCommand, error)

func (*CompilationExtensions) ExtendOpdOption

func (*CompilationExtensions) ExtendOpdOption(
	p parse.Node, y yang.OpdOption,
) (yang.OpdOption, error)

func (*CompilationExtensions) ExtendRpc

func (*CompilationExtensions) ExtendRpc(
	p parse.Node, y yang.Rpc,
) (yang.Rpc, error)

func (*CompilationExtensions) ExtendTree

func (*CompilationExtensions) ExtendTree(
	p parse.Node, y yang.Tree,
) (yang.Tree, error)

func (*CompilationExtensions) ExtendType

func (*CompilationExtensions) ExtendType(
	p parse.Node, base yang.Type, t yang.Type,
) (yang.Type, error)

func (*CompilationExtensions) NodeCardinality

func (e *CompilationExtensions) NodeCardinality(
	ntype parse.NodeType,
) map[parse.NodeType]parse.Cardinality

type ComponentManager

type ComponentManager interface {
	OperationsManager
	ServiceManager

	GetComponentNSMappings() *ComponentMappings

	ComponentValidation(
		ModelSet,
		datanode.DataNode,
		commitTimeLogFn,
	) []error
	ComponentSetRunning(
		ModelSet,
		datanode.DataNode,
		*map[string]bool,
	) []*exec.Output
	ComponentSetRunningWithLog(
		ModelSet,
		datanode.DataNode,
		*map[string]bool,
		commitTimeLogFn,
	) []*exec.Output
	ComponentGetRunning(
		ModelSet,
		ConfigMultiplexerFn,
	) (*data.Node, error)
	ComponentGetState(
		ModelSet,
		datanode.DataNode,
		*rfc7951data.Tree,
		StateLogger,
	) (*rfc7951data.Tree, error)
}

ComponentManager encapsulates bus operations to/from components, and service queries against the components' service status.

type ComponentMappings

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

func CreateComponentNSMappings

func CreateComponentNSMappings(
	m yang.ModelSet,
	modelSetName string,
	compConfig []*conf.ServiceConfig,
) (*ComponentMappings, error)

func (*ComponentMappings) Component

func (cm *ComponentMappings) Component(name string) *component

func (*ComponentMappings) Components

func (cm *ComponentMappings) Components() map[string]*component

func (*ComponentMappings) DefaultComponent

func (cm *ComponentMappings) DefaultComponent() string

func (*ComponentMappings) GetDefaultServiceModuleMap

func (cm *ComponentMappings) GetDefaultServiceModuleMap() map[string]struct{}

func (*ComponentMappings) GetModelNameForNamespace

func (cm *ComponentMappings) GetModelNameForNamespace(ns string) (string, bool)

func (*ComponentMappings) OrderedComponents

func (cm *ComponentMappings) OrderedComponents() []string

type ConfigMultiplexerFn

type ConfigMultiplexerFn func([][]byte, ModelSet) (*data.Node, error)

type ConfigdExt

type ConfigdExt struct {
	Help           string
	Validate       []string
	Syntax         []string
	Priority       uint
	Normalize      string
	Allowed        string
	Begin          []string
	End            []string
	Create         []string
	Update         []string
	Delete         []string
	Subst          []string
	Secret         bool
	DeferActions   string
	Must           string
	PatternHelp    []string
	CallRpc        string
	GetState       []string
	OpdHelp        string
	OpdAllowed     string
	OpdPatternHelp []string
}

func (*ConfigdExt) Copy

func (ext *ConfigdExt) Copy() *ConfigdExt

func (*ConfigdExt) GetHelp

func (ext *ConfigdExt) GetHelp() string

Get the help text for a node, if absent, return <No help text available>

func (*ConfigdExt) GetTypeHelp

func (ext *ConfigdExt) GetTypeHelp() string

Get the help text as is, suitable for a type node

func (*ConfigdExt) Merge

func (ext *ConfigdExt) Merge(in *ConfigdExt) *ConfigdExt

Types require merging of base data into new type

func (*ConfigdExt) Override

func (ext *ConfigdExt) Override(in *ConfigdExt) *ConfigdExt

type Container

type Container interface {
	yang.Container
	ExtendedNode
}

type Decimal64

type Decimal64 interface {
	yang.Decimal64
	// contains filtered or unexported methods
}

type Empty

type Empty interface {
	yang.Empty
	// contains filtered or unexported methods
}

type Enumeration

type Enumeration interface {
	yang.Enumeration
	// contains filtered or unexported methods
}

type ExtendedNode

type ExtendedNode interface {
	SchemaChild(name string) Node
	HelpMap() map[string]string
	// contains filtered or unexported methods
}

type Identityref

type Identityref interface {
	yang.Identityref
	// contains filtered or unexported methods
}

type InstanceId

type InstanceId interface {
	yang.InstanceId
	// contains filtered or unexported methods
}

type Integer

type Integer interface {
	yang.Integer
	// contains filtered or unexported methods
}

type Leaf

type Leaf interface {
	yang.Leaf
	ExtendedNode
}

type LeafList

type LeafList interface {
	yang.LeafList
	ExtendedNode
}

type LeafValue

type LeafValue interface {
	yang.LeafValue
	ExtendedNode
}

type Leafref

type Leafref interface {
	yang.Leafref
	// contains filtered or unexported methods
}

type List

type List interface {
	yang.List
	ExtendedNode
}

type ListEntry

type ListEntry interface {
	yang.ListEntry
	ExtendedNode
}

type Model

type Model interface {
	yang.Model
	Tree() Tree
}

type ModelSet

type ModelSet interface {
	yang.ModelSet
	ExtendedNode
	PathDescendant([]string) *TmplCompat
	OpdPathDescendant([]string) *TmplCompat
}

func CompileDir

func CompileDir(cfg *compile.Config, ext *CompilationExtensions) (ModelSet, error)

func CompileDirKeepMods

func CompileDirKeepMods(
	cfg *compile.Config,
	ext *CompilationExtensions,
) (ModelSet, error, map[string]*parse.Module, map[string]*parse.Module)

If you need to be able to look up prefix / module mappings after the schema has been compiled, then this function provides the module and submodule data to do this.

func CompileDirWithWarnings

func CompileDirWithWarnings(
	cfg *compile.Config,
	ext *CompilationExtensions,
) (ModelSet, []xutils.Warning, error,
)

func CompileModules

func CompileModules(
	mods map[string]*parse.Tree,
	capabilities string,
	skipUnknown bool,
	filter compile.SchemaFilter,
	ext *CompilationExtensions,
) (ModelSet, error)

func CompileModulesWithWarnings

func CompileModulesWithWarnings(
	mods map[string]*parse.Tree,
	capabilities string,
	skipUnknown bool,
	filter compile.SchemaFilter,
	ext *CompilationExtensions,
) (ModelSet, []xutils.Warning, error)

func CompileModulesWithWarningsAndCustomFunctions

func CompileModulesWithWarningsAndCustomFunctions(
	mods map[string]*parse.Tree,
	capabilities string,
	skipUnknown bool,
	filter compile.SchemaFilter,
	ext *CompilationExtensions,
	userFnChecker xpath.UserCustomFunctionCheckerFn,
) (ModelSet, []xutils.Warning, error)

func CompileParseTrees

func CompileParseTrees(
	mods map[string]*parse.Tree,
	features compile.FeaturesChecker,
	skipUnknown bool,
	filter compile.SchemaFilter,
	ext *CompilationExtensions,
) (ModelSet, error)

type Node

type Node interface {
	yang.Node
	ExtendedNode
}

func Descendant

func Descendant(node Node, path []string) Node

type Notification

type Notification interface {
	yang.Notification
}

type OpdArgument

type OpdArgument interface {
	yang.OpdArgument
	ExtendedNode
}

type OpdCommand

type OpdCommand interface {
	yang.OpdCommand
	ExtendedNode
}

type OpdOption

type OpdOption interface {
	yang.OpdOption
	ExtendedNode
}

type OpdOptionValue

type OpdOptionValue interface {
	yang.OpdOptionValue
	ExtendedNode
}

type OperationsManager

type OperationsManager interface {
	Dial() error
	SetConfigForModel(string, interface{}) error
	CheckConfigForModel(string, interface{}) error
	StoreConfigByModelInto(string, interface{}) error
	StoreStateByModelInto(string, interface{}) error
}

type Rpc

type Rpc interface {
	yang.Rpc
	Script() string
}

type ServiceManager

type ServiceManager interface {
	Close()
	IsActive(name string) (bool, error)
}

type StateLogger

type StateLogger interface {
	Printf(format string, a ...interface{})
	Println(a ...interface{})
}

type String

type String interface {
	yang.String
	// contains filtered or unexported methods
}

type TestCompMgr

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

func NewTestCompMgr

func NewTestCompMgr(
	t *testing.T,
	ms yang.ModelSet,
	mappings *ComponentMappings,
) *TestCompMgr

func (*TestCompMgr) CheckLogEntries

func (tcm *TestCompMgr) CheckLogEntries(
	t *testing.T,
	name string,
	entries []TestLogEntry,
	filter string,
)

func (*TestCompMgr) ClearLogEntries

func (tcm *TestCompMgr) ClearLogEntries()

func (*TestCompMgr) CommittedConfig

func (tcm *TestCompMgr) CommittedConfig(model string) string

func (TestCompMgr) ComponentGetRunning

func (cm TestCompMgr) ComponentGetRunning(
	m ModelSet,
	cfgMuxFn ConfigMultiplexerFn,
) (*data.Node, error)

func (TestCompMgr) ComponentGetState

func (cm TestCompMgr) ComponentGetState(
	m ModelSet,
	dn datanode.DataNode,
	ft *rfc7951data.Tree,
	logger StateLogger,
) (*rfc7951data.Tree, error)

func (TestCompMgr) ComponentSetRunning

func (cm TestCompMgr) ComponentSetRunning(
	m ModelSet,
	dn datanode.DataNode,
	changedNSMap *map[string]bool,
) []*exec.Output

func (TestCompMgr) ComponentSetRunningWithLog

func (cm TestCompMgr) ComponentSetRunningWithLog(
	m ModelSet,
	dn datanode.DataNode,
	changedNSMap *map[string]bool,
	commitLogFn commitTimeLogFn,
) []*exec.Output

func (TestCompMgr) ComponentValidation

func (cm TestCompMgr) ComponentValidation(
	m ModelSet,
	dn datanode.DataNode,
	logFn commitTimeLogFn,
) []error

func (*TestCompMgr) CurrentState

func (tcm *TestCompMgr) CurrentState(model string) string

func (TestCompMgr) GetComponentNSMappings

func (cm TestCompMgr) GetComponentNSMappings() *ComponentMappings

func (*TestCompMgr) SetCurrentState

func (tcm *TestCompMgr) SetCurrentState(model, stateJson string)

func (*TestCompMgr) ValidatedConfig

func (tcm *TestCompMgr) ValidatedConfig(model string) string

type TestLogEntry

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

func NewTestLogEntry

func NewTestLogEntry(fn string, params ...string) TestLogEntry

type TmplCompat

type TmplCompat struct {
	Node Node
	Val  bool
}

type Tree

type Tree interface {
	yang.Tree
	ExtendedNode
}

func NewTree

func NewTree(children []Node) (Tree, error)

type Type

type Type interface {
	yang.Type
	// contains filtered or unexported methods
}

type Uinteger

type Uinteger interface {
	yang.Uinteger
	// contains filtered or unexported methods
}

type Union

type Union interface {
	yang.Union
	// contains filtered or unexported methods
}

type ValidateCtx

type ValidateCtx struct {
	Noexec                bool
	CurPath               []string
	Path                  string
	Sid                   string
	St                    ModelSet
	IncompletePathIsValid bool
}

func (ValidateCtx) AllowIncompletePaths

func (v ValidateCtx) AllowIncompletePaths() bool

func (ValidateCtx) ErrorHelpText

func (v ValidateCtx) ErrorHelpText() []string

Jump to

Keyboard shortcuts

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