Documentation ¶
Index ¶
- Constants
- func AddDefaults(schema Node, under datanode.DataNode) datanode.DataNode
- func ConvertToXpathNode(c datanode.DataNode, s Node) xutils.XpathNode
- func FilterTree(schema Node, under datanode.DataNode, keep_it Filter) datanode.DataNode
- func IsActiveDefault(sch Node, name string, cfgChkr ConfigChecker) bool
- func NewEmptyLeafValueError(name string, path []string) error
- func NewInvalidPathError(path []string) error
- func NewMissingChildError(path []string) error
- func NewMissingKeyError(path []string) error
- func NewMissingValueError(path []string) error
- func NewNode() *node
- func NewNodeExistsError(path []string) error
- func NewNodeNotExistsError(path []string) error
- func NewPathInvalidError(path []string, invalidElem string) error
- func NewSchemaMismatchError(name string, path []string) error
- func ValidateSchema(sn Node, c datanode.DataNode, debug bool) ([]*exec.Output, []error, bool)
- func ValidateSchemaWithLog(sn Node, c datanode.DataNode, options ...YangDebugOption) ([]*exec.Output, []error, bool)
- type ActionFnType
- type Binary
- type Bit
- type BitWidth
- type Bits
- type Boolean
- type Case
- type Choice
- type ConfigChecker
- type Container
- type Decimal64
- type Drb
- type DrbSlice
- func (rangeBdry DrbSlice) Append(start, end interface{}) RangeBoundarySlicer
- func (rangeBdry DrbSlice) Contiguous(lower, higher interface{}) bool
- func (rangeBdry DrbSlice) Create(entries, capacity int) RangeBoundarySlicer
- func (rangeBdry DrbSlice) GetEnd(i int) interface{}
- func (rangeBdry DrbSlice) GetStart(i int) interface{}
- func (rangeBdry DrbSlice) GreaterThan(first, second interface{}) bool
- func (rangeBdry DrbSlice) Len() int
- func (rangeBdry DrbSlice) LessThan(first, second interface{}) bool
- func (rangeBdry DrbSlice) Parse(start string, base int, bitSize int) (interface{}, error)
- func (rangeBdry DrbSlice) String(i int) string
- type Empty
- type Enum
- type Enumeration
- type Filter
- type Fracdigit
- type Identity
- type Identityref
- type InstanceId
- type Integer
- type Lb
- type LbSlice
- func (rangeBdry LbSlice) Append(start, end interface{}) RangeBoundarySlicer
- func (rangeBdry LbSlice) Contiguous(lower, higher interface{}) bool
- func (rangeBdry LbSlice) Create(entries, capacity int) RangeBoundarySlicer
- func (rangeBdry LbSlice) GetEnd(i int) interface{}
- func (rangeBdry LbSlice) GetStart(i int) interface{}
- func (rangeBdry LbSlice) GreaterThan(first, second interface{}) bool
- func (rangeBdry LbSlice) Len() int
- func (rangeBdry LbSlice) LessThan(first, second interface{}) bool
- func (rangeBdry LbSlice) Parse(start string, base int, bitSize int) (interface{}, error)
- func (rangeBdry LbSlice) String(i int) string
- type Leaf
- type LeafList
- type LeafValue
- type Leafref
- type Length
- type Limit
- type List
- type ListEntry
- type Model
- type ModelSet
- type MustContext
- type Node
- type NodeProperty
- type NodeSpec
- type NodeSubSpec
- type Notification
- type Number
- type OpdArgument
- type OpdCommand
- type OpdOption
- type OpdOptionValue
- type Pattern
- type RangeBoundarySlicer
- type Rb
- type RbSlice
- func (rangeBdry RbSlice) Append(start, end interface{}) RangeBoundarySlicer
- func (rangeBdry RbSlice) Contiguous(lower, higher interface{}) bool
- func (rangeBdry RbSlice) Create(entries, capacity int) RangeBoundarySlicer
- func (rangeBdry RbSlice) GetEnd(i int) interface{}
- func (rangeBdry RbSlice) GetStart(i int) interface{}
- func (rangeBdry RbSlice) GreaterThan(first, second interface{}) bool
- func (rangeBdry RbSlice) Len() int
- func (rangeBdry RbSlice) LessThan(first, second interface{}) bool
- func (rangeBdry RbSlice) Parse(start string, base int, bitSize int) (interface{}, error)
- func (rangeBdry RbSlice) String(i int) string
- type Restriction
- type Rpc
- type SchemaValidator
- type Status
- type String
- type Submodule
- type Tree
- type Type
- type Uinteger
- type Union
- type Urb
- type UrbSlice
- func (rangeBdry UrbSlice) Append(start, end interface{}) RangeBoundarySlicer
- func (rangeBdry UrbSlice) Contiguous(lower, higher interface{}) bool
- func (rangeBdry UrbSlice) Create(entries, capacity int) RangeBoundarySlicer
- func (rangeBdry UrbSlice) GetEnd(i int) interface{}
- func (rangeBdry UrbSlice) GetStart(i int) interface{}
- func (rangeBdry UrbSlice) GreaterThan(first, second interface{}) bool
- func (rangeBdry UrbSlice) Len() int
- func (rangeBdry UrbSlice) LessThan(first, second interface{}) bool
- func (rangeBdry UrbSlice) Parse(start string, base int, bitSize int) (interface{}, error)
- func (rangeBdry UrbSlice) String(i int) string
- type ValidateCtx
- type ValidationType
- type WhenAndMustContext
- type WhenContext
- type XNode
- func (xn *XNode) XChildren(filter xutils.XFilter, sortSpec xutils.SortSpec) []xutils.XpathNode
- func (xn *XNode) XIsEphemeral() bool
- func (xn *XNode) XIsLeaf() bool
- func (xn *XNode) XIsLeafList() bool
- func (xn *XNode) XIsNonPresCont() bool
- func (xn *XNode) XListKeyMatches(key xml.Name, val string) bool
- func (xn *XNode) XListKeys() []xutils.NodeRefKey
- func (xn *XNode) XName() string
- func (xn *XNode) XParent() xutils.XpathNode
- func (xn *XNode) XPath() xutils.PathType
- func (xn *XNode) XRoot() xutils.XpathNode
- func (xn *XNode) XValue() string
- type YangDebugOption
Constants ¶
const ( Current = iota Deprecated Obsolete )
Variables ¶
This section is empty.
Functions ¶
func AddDefaults ¶
Create a wrapper around a datanode that provides defaults
func FilterTree ¶
Create a wrapper around a datanode that filters out unwanted nodes
func IsActiveDefault ¶
func IsActiveDefault(sch Node, name string, cfgChkr ConfigChecker) bool
IsActiveDefault - Check default nodes and determine if they are active defaults that should be instantiated.
A node is an active default in one of the given circumstances ¶
- The node is under a choice but there is no active configuration under the choice, any nodes under the default case, if it is defined, become active defaults.
- There is config under one of the cases in a choice, any other node in that case will be an active default.
- The node is not under a choice and has a default
isActiveDefault() and isActiveDefaultCase() are called recursively to traverse down a choice/case
func NewEmptyLeafValueError ¶
func NewInvalidPathError ¶
func NewMissingChildError ¶
func NewMissingKeyError ¶
func NewMissingValueError ¶
func NewNodeExistsError ¶
func NewNodeNotExistsError ¶
func NewPathInvalidError ¶
Preferred to NewInvalidPathError, generating consistent error type and consistent path style (split between path and info fields). Legacy one kept to avoid having to play with opd errors.
func NewSchemaMismatchError ¶
func ValidateSchema ¶
func ValidateSchemaWithLog ¶
Types ¶
type ActionFnType ¶
type ActionFnType func( targetNode Node, parentNode *XNode, nodeToFind NodeSpec, path []string, param interface{}, ) (done, success bool, retSlice []interface{})
ActionFnType - action to be carried out on each node during a walk. As the tree is walked, we carry out the actionFn on each node in turn. For a find operation, this function may return <done> as true, indicating no further walking is required. At this point, <success> indicates whether the overall 'mission' of the walk was successful or not. Otherwise, if a walk runs to completion (all nodes walked) we return true. <retSlice> is used to store any number of objects returned by each invocation of the actionFn, eg output(s) generated by each node.
type Bit ¶
type ConfigChecker ¶
type Container ¶
func NewContainer ¶
func NewContainer( name, namespace, modulename, submodule, desc, ref string, presence, config bool, status Status, whens []WhenContext, musts []MustContext, children []Node, ) (Container, error)
type Decimal64 ¶
type Drb ¶
type Drb struct {
Start, End float64
}
decimal64 range boundary (Drb)
func NewDecimalRangeBoundary ¶
type DrbSlice ¶
type DrbSlice []Drb
To allow us to provide common handling for different RangeBoundary types it is useful to create an explicit slice type for each RB type as we can then create functions that operate on such slices. We use these functions from the common handling functions using the magic of interface{}.
func (DrbSlice) Append ¶
func (rangeBdry DrbSlice) Append(start, end interface{}) RangeBoundarySlicer
func (DrbSlice) Contiguous ¶
func (DrbSlice) Create ¶
func (rangeBdry DrbSlice) Create(entries, capacity int) RangeBoundarySlicer
func (DrbSlice) GreaterThan ¶
type Enum ¶
type Enumeration ¶
type Enumeration interface { Type Enums() []*Enum String() string // contains filtered or unexported methods }
func NewEnumeration ¶
type Identity ¶
type Identity struct { Val string Desc string Ref string Value string Module string Namespace string // contains filtered or unexported fields }
func NewIdentity ¶
type Identityref ¶
type Identityref interface { Type Identities() []*Identity String() string // contains filtered or unexported methods }
func NewIdentityref ¶
type InstanceId ¶
func NewInstanceId ¶
type Lb ¶
type Lb struct {
Start, End uint64
// contains filtered or unexported fields
}
string length (range) boundary (Lb)
func NewLengthBoundary ¶
type LbSlice ¶
type LbSlice []Lb
Lb RangeBoundarySlicer interface implementation
func (LbSlice) Append ¶
func (rangeBdry LbSlice) Append(start, end interface{}) RangeBoundarySlicer
func (LbSlice) Contiguous ¶
func (LbSlice) Create ¶
func (rangeBdry LbSlice) Create(entries, capacity int) RangeBoundarySlicer
func (LbSlice) GreaterThan ¶
type Leaf ¶
func NewLeaf ¶
func NewLeaf( name, namespace, modulename, submodule, desc, ref, units string, mandatory bool, typ Type, config bool, status Status, whens []WhenContext, musts []MustContext, ) Leaf
type LeafList ¶
func NewLeafList ¶
func NewLeafList( name, namespace, modulename, submodule, desc, ref, def, orderedby, units string, min, max uint, typ Type, config bool, status Status, whens []WhenContext, musts []MustContext, ) LeafList
type Leafref ¶
type Length ¶
type Length struct { Lbs LbSlice Msg string AppTag string // contains filtered or unexported fields }
Length
type List ¶
type Model ¶
type ModelSet ¶
type ModelSet interface { Tree Modules() map[string]Model Submodules() map[string]Submodule Rpcs() map[string]map[string]Rpc Notifications() map[string]map[string]Notification FindOrWalk( nodeToFind NodeSpec, actionFn ActionFnType, param interface{}) (Node, bool, []interface{}) // contains filtered or unexported methods }
type MustContext ¶
type MustContext struct { WhenAndMustContext // Used to evaluate paths in the configd:must extension ExtPathEvalMach *xpath.Machine }
func NewMustContext ¶
type Node ¶
type Node interface { Child(string) Node Descendant([]string) Node Validate(ValidateCtx, []string, []string) error CheckCardinality(xutils.PathType, int) error Children() []Node OpdChildren() []Node Choices() []Node Name() string Namespace() string Module() string Submodule() string Paths(string) []string Whens() []WhenContext Musts() []MustContext Type() Type HasDefault() bool DefaultChild(name string) Node DefaultChildNames() []string DefaultChildren() []Node OrdBy() string HasPresence() bool Config() bool String() string Status() Status Description() string Repeatable() bool Parent() *node Arguments() []string Mandatory() bool // contains filtered or unexported methods }
type NodeProperty ¶
Structures used to specify the properties of the node to be found during a walk.
type NodeSpec ¶
type NodeSpec struct { Path []string DefaultPropNotPresent bool // If true, we expect node to exist w/o property Statement NodeSubSpec DataPropNotPresent bool // If true, we expect node to exist w/o data Data NodeSubSpec }
For the likes of verifying default is NOT set on a node, we have the NotPresent options, which default to false (present) as that is the more commonly tested case and this avoids needing to specify these so often.
Note that NotPresent means node either doesn't exist, or has a different value to that specified.
type NodeSubSpec ¶
type NodeSubSpec struct { Type string Properties []NodeProperty }
type Notification ¶
type Notification interface { Schema() Tree // contains filtered or unexported methods }
func NewNotification ¶
func NewNotification(n Tree) Notification
type Number ¶
type Number interface { Type Ranges() RangeBoundarySlicer Msg() string AppTag() string BitWidth() BitWidth }
type OpdArgument ¶
type OpdCommand ¶
type OpdOption ¶
type OpdOptionValue ¶
type OpdOptionValue interface { Node IsOpdOptionValue() }
type Pattern ¶
func NewPattern ¶
type RangeBoundarySlicer ¶
type RangeBoundarySlicer interface { // Return length of RangeBoundary Len() int // Pretty-print function for %s String(i int) string // Return start/end value at given position in the slice GetStart(i int) interface{} GetEnd(i int) interface{} // For ranges with discrete values (ie int/uint/string), if one range // ends at 'x' and the following one starts at 'x + 1', then the two // ranges may be deemed to be contiguous, and a derived type or // refined range may span the two. // // NB: decimal64 covers real rather than whole numbers and so no two // ranges can ever be considered contiguous. Contiguous(lower, higher interface{}) bool // Return a RangeBoundarySlicer object with given entries and capacity. Create(entries, capacity int) RangeBoundarySlicer // Parse the string to obtain the numeric values for the range(s) // specified. Parse(start string, base int, bitSize int) (interface{}, error) // Create a new slice element with start and end and append it to the // slice. Append(start, end interface{}) RangeBoundarySlicer // These two don't really belong here - a type switch function would // perhaps be more appropriate - as they only use the RangeBoundary to // implicitly tell what underlying type to use. LessThan(first, second interface{}) bool GreaterThan(first, second interface{}) bool }
Interface for ALL range boundary (<n>rb) types that allows us to have generic handling routines in the compiler for range creation and validation etc.
type RbSlice ¶
type RbSlice []Rb
Rb RangeBoundarySlicer interface implementation
func (RbSlice) Append ¶
func (rangeBdry RbSlice) Append(start, end interface{}) RangeBoundarySlicer
func (RbSlice) Contiguous ¶
func (RbSlice) Create ¶
func (rangeBdry RbSlice) Create(entries, capacity int) RangeBoundarySlicer
func (RbSlice) GreaterThan ¶
type Restriction ¶
type Restriction interface {
// contains filtered or unexported methods
}
Restrictions
type SchemaValidator ¶
type SchemaValidator struct {
// contains filtered or unexported fields
}
func NewSchemaValidator ¶
func NewSchemaValidator(sn Node, c datanode.DataNode) *SchemaValidator
func (*SchemaValidator) SetValidation ¶
func (sv *SchemaValidator) SetValidation( valType ValidationType, ) *SchemaValidator
type String ¶
type Submodule ¶
type Submodule interface { EncodeXML(*xml.Encoder) Identifier() string Namespace() string Data() string // contains filtered or unexported methods }
func NewSubmodule ¶
type Type ¶
type Type interface { Validate(ctx ValidateCtx, path []string, s string) error Name() xml.Name // Strings (possibly other types) may have an empty string as the default. // So, we need to explicitly note the presence / absence of a default Default() (string, bool) AllowedValues(ctxNode xutils.XpathNode, debug bool) ( allowedValues []string, err error) // contains filtered or unexported methods }
type Union ¶
type Urb ¶
type Urb struct {
Start, End uint64
}
uint range boundary (Urb)
type UrbSlice ¶
type UrbSlice []Urb
Urb RangeBoundarySlicer interface implementation
func (UrbSlice) Append ¶
func (rangeBdry UrbSlice) Append(start, end interface{}) RangeBoundarySlicer
func (UrbSlice) Contiguous ¶
func (UrbSlice) Create ¶
func (rangeBdry UrbSlice) Create(entries, capacity int) RangeBoundarySlicer
func (UrbSlice) GreaterThan ¶
type ValidateCtx ¶
type ValidateCtx interface { ErrorHelpText() []string // For validating paths that could exist, eg when making a NETCONF request // for the tree under a non-presence container, we need to allow a path // that stops at a non-presence container to be considered valid. Likewise // list names w/o entry name, leaves w/o values. AllowIncompletePaths() bool }
An optional type to be passed into validation to allow extensions to operate
type ValidationType ¶
type ValidationType int
const ( ValidateAll ValidationType = iota DontValidate ValidateState ValidateConfig )
type WhenAndMustContext ¶
type WhenAndMustContext struct { // Mach is the machine that evaulates the full XPATH logic. Mach *xpath.Machine // ErrMsg is the error message when the XPATH expression returns false. // // For 'must', this can be specified in YANG, or a default generated by // the compiler. For 'when', it is always the latter. ErrMsg string // AppTag is used in the <rpc-error> error-app-tag field in errors sent // to NETCONF clients. AppTag string // PathEvalMach is the machine that checks paths in the XPATH expression. PathEvalMach *xpath.Machine Namespace string }
WhenAndMustContext stores common context for When and Must machines.
type WhenContext ¶
type WhenContext struct { WhenAndMustContext // RunAsParent indicates whether the machine is run on node or parent. // // 'when' statements can be added directly under an augment statement. In // this case we store the statement on each augmented child, but need to // run it using the context (current node) set to the parent node. RunAsParent bool }
func NewWhenContext ¶
type XNode ¶
type XNode struct { Node // contains filtered or unexported fields }
func (*XNode) XIsEphemeral ¶
The way XNodes are created means they must refer to real configured nodes, so cannot be ephemeral
func (*XNode) XIsLeafList ¶
func (*XNode) XIsNonPresCont ¶
func (*XNode) XListKeys ¶
func (xn *XNode) XListKeys() []xutils.NodeRefKey
type YangDebugOption ¶
type YangDebugOption func(*yangValDebugContext)
func MustLogThreshold ¶
func MustLogThreshold(threshold int) YangDebugOption
func ValidationDebug ¶
func ValidationDebug(debug bool) YangDebugOption