Documentation ¶
Index ¶
- Constants
- func CompileDir(extensions Extensions, cfg *Config) (schema.ModelSet, error)
- func CompileDirKeepMods(extensions Extensions, cfg *Config) (schema.ModelSet, error, map[string]*parse.Module, map[string]*parse.Module)
- func CompileDirWithWarnings(extensions Extensions, cfg *Config) (schema.ModelSet, []xutils.Warning, error)
- func CompileModules(extensions Extensions, mods map[string]*parse.Tree, features string, ...) (schema.ModelSet, error)
- func CompileModulesWithWarnings(extensions Extensions, mods map[string]*parse.Tree, features string, ...) (schema.ModelSet, []xutils.Warning, error)
- func CompileModulesWithWarningsAndCustomFunctions(extensions Extensions, mods map[string]*parse.Tree, features string, ...) (schema.ModelSet, []xutils.Warning, error)
- func CompileParseTrees(extensions Extensions, mods map[string]*parse.Tree, features FeaturesChecker, ...) (schema.ModelSet, error)
- func DisableCompilerDebug()
- func EnableCompilerDebug()
- func IsConfig(sn schema.Node) bool
- func IsOpd(sn schema.Node) bool
- func IsState(sn schema.Node) bool
- func ParseModuleDir(dir string, extCard parse.NodeCardinality) (map[string]*parse.Tree, error)
- func ParseModules(extCard parse.NodeCardinality, list ...string) (map[string]*parse.Tree, error)
- func ParseYang(extCard parse.NodeCardinality, locator YangLocator) (map[string]*parse.Tree, error)
- func YangModulesFromDir(dir string) ([]string, error)
- type Compiler
- func (c *Compiler) BuildBaseType(cfgNode parse.Node, typ parse.Node, def string, hasDef bool, ...) (schema.Type, xml.Name, bool)
- func (c *Compiler) BuildCase(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (c *Compiler) BuildChoice(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (c *Compiler) BuildContainer(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (comp *Compiler) BuildLeaf(features inheritedFeatures, mod parse.Node, node parse.Node, isKey bool) schema.Node
- func (c *Compiler) BuildLeafList(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (c *Compiler) BuildList(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (c *Compiler) BuildModule(module *parse.Module, m parse.Node) schema.Model
- func (c *Compiler) BuildModules() (modules map[string]schema.Model, err error)
- func (c *Compiler) BuildMusts(n parse.Node) []schema.MustContext
- func (c *Compiler) BuildNode(inherited inheritedFeatures, m parse.Node, n parse.Node, isKey bool) (retNodes []schema.Node)
- func (c *Compiler) BuildOpdArgument(features inheritedFeatures, mod parse.Node, node parse.Node) schema.Node
- func (c *Compiler) BuildOpdCommand(features inheritedFeatures, m parse.Node, n parse.Node) schema.Node
- func (c *Compiler) BuildOpdOption(features inheritedFeatures, mod parse.Node, node parse.Node) schema.Node
- func (c *Compiler) BuildType(cfgNode parse.Node, typ parse.Node, def string, hasDef bool, ...) schema.Type
- func (c *Compiler) BuildWhens(n parse.Node) []schema.WhenContext
- func (c *Compiler) CheckChildren(m parse.Node, n parse.Node)
- func (c *Compiler) CheckIfFeature(n parse.Node, parentStatus schema.Status) bool
- func (c *Compiler) CheckMinMax(n parse.Node, min, max uint)
- func (c *Compiler) CheckUniqueConstraint(m parse.Node, n parse.Node)
- func (c *Compiler) CheckUnknown(m parse.Node, n parse.Node)
- func (c *Compiler) ExpandModules() (err error)
- func (c *Compiler) IgnoreNode(node parse.Node, parentStatus schema.Status) bool
- func (c *Compiler) ProcessModuleIncludes(m parse.Node, submodules map[string]parse.Node)
- func (c *Compiler) ProcessSubmoduleIncludes(m parse.Node, submodules map[string]parse.Node)
- func (c *Compiler) VerifyModuleIncludes(m parse.Node, submodules map[string]parse.Node)
- type Config
- type Extensions
- type FeatureStatus
- type FeaturesChecker
- type SchemaFilter
- type SchemaType
- type YangLocator
Constants ¶
const DefaultCapsLocation = "/config/features"
const SystemCapsLocation = "/opt/vyatta/etc/features"
TODO: We should make this able to be configured. We are currently under a crunch, so doing this for now. This location is non-user changeable so only non-shipped features can be toggled.
Variables ¶
This section is empty.
Functions ¶
func CompileDir ¶
func CompileDir(extensions Extensions, cfg *Config, ) (schema.ModelSet, error, )
func CompileDirKeepMods ¶
func CompileDirWithWarnings ¶
func CompileModules ¶
func CompileModules( extensions Extensions, mods map[string]*parse.Tree, features string, skipUnknown bool, filter SchemaFilter, ) (schema.ModelSet, error)
func CompileModulesWithWarningsAndCustomFunctions ¶
func CompileModulesWithWarningsAndCustomFunctions( extensions Extensions, mods map[string]*parse.Tree, features string, skipUnknown bool, filter SchemaFilter, userFnChecker xpath.UserCustomFunctionCheckerFn, ) (schema.ModelSet, []xutils.Warning, error)
func CompileParseTrees ¶
func CompileParseTrees( extensions Extensions, mods map[string]*parse.Tree, features FeaturesChecker, skipUnknown bool, filter SchemaFilter, ) (schema.ModelSet, error)
func DisableCompilerDebug ¶
func DisableCompilerDebug()
func EnableCompilerDebug ¶
func EnableCompilerDebug()
func ParseModuleDir ¶
func ParseModules ¶
func ParseYang ¶
func ParseYang(extCard parse.NodeCardinality, locator YangLocator) (map[string]*parse.Tree, error)
func YangModulesFromDir ¶
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func NewCompiler ¶
func NewCompiler( extensions Extensions, modules map[string]*parse.Module, submodules map[string]*parse.Module, features FeaturesChecker, skipUnknown, generateWarnings bool, filter SchemaFilter, ) *Compiler
func (*Compiler) BuildBaseType ¶
func (*Compiler) BuildChoice ¶
func (*Compiler) BuildContainer ¶
func (*Compiler) BuildLeafList ¶
func (*Compiler) BuildModule ¶
func (*Compiler) BuildModules ¶
func (*Compiler) BuildMusts ¶
func (c *Compiler) BuildMusts(n parse.Node) []schema.MustContext
func (*Compiler) BuildOpdArgument ¶
func (*Compiler) BuildOpdCommand ¶
func (*Compiler) BuildOpdOption ¶
func (*Compiler) BuildType ¶
func (c *Compiler) BuildType( cfgNode parse.Node, typ parse.Node, def string, hasDef bool, parentStatus schema.Status, ) schema.Type
This recursively works down a chain of type / typedefs until it gets to the base type. It then builds the base type, checking range. Then we work back up, refining the type as we go if it's a typedef type.
We also set the default, if specified, and pass it up. At each level, a new default overrides an existing one, otherwise we inherit the default, if it exists.
Cannot have default and mandatory - unclear how we will check if default is inherited.
func (*Compiler) BuildWhens ¶
func (c *Compiler) BuildWhens(n parse.Node) []schema.WhenContext
func (*Compiler) CheckIfFeature ¶
Verify that an if-feature reference is valid, and determine if the referenced feature is enabled A referenced feature takes the form [prefix:]feature-name If no prefix is present, it is an implicit reference to the local module.
func (*Compiler) CheckUniqueConstraint ¶
unique-arg cannot traverse a descedant list (see https://www.ietf.org/mail-archive/web/netmod/current/msg06386.html)
func (*Compiler) ExpandModules ¶
func (*Compiler) IgnoreNode ¶
func (*Compiler) ProcessModuleIncludes ¶
func (*Compiler) ProcessSubmoduleIncludes ¶
type Config ¶
type Config struct { YangDir string YangLocations YangLocator CapsLocation string Features FeaturesChecker SkipUnknown bool Filter SchemaFilter // Used for the likes of yangc to inject names of valid custom functions // that otherwise would not be visible to the compiler. Only used during // path evaluation. UserFnCheckFn xpath.UserCustomFunctionCheckerFn }
type Extensions ¶
type Extensions interface { // Returns a function used to get the cardinality of any extension NodeCardinality(parse.NodeType) map[parse.NodeType]parse.Cardinality // Extend the complete model set, including the combined tree of // all the underlying models ExtendModelSet(schema.ModelSet) (schema.ModelSet, error) // Extend the schema tree used for RPC parameters and schema Models ExtendModel(parse.Node, schema.Model, schema.Tree) (schema.Model, error) // Extend the RPC node which includes input and output parameters // as trees ExtendRpc(parse.Node, schema.Rpc) (schema.Rpc, error) // Extend the Notification node ExtendNotification(parse.Node, schema.Notification) (schema.Notification, error) // Extend the schema tree used for RPC parameters and schema Models ExtendTree(parse.Node, schema.Tree) (schema.Tree, error) // Extend the various nodes within a schema Tree ExtendContainer(parse.Node, schema.Container) (schema.Container, error) ExtendList(parse.Node, schema.List) (schema.List, error) ExtendLeaf(parse.Node, schema.Leaf) (schema.Leaf, error) ExtendLeafList(parse.Node, schema.LeafList) (schema.LeafList, error) // Extend choice and case nodes ExtendChoice(parse.Node, schema.Choice) (schema.Choice, error) ExtendCase(parse.Node, schema.Case) (schema.Case, error) // Extend the type, given the parse node and the base type that this // type is derived from. The base time may be nil, when the type is // a built in type. ExtendType(p parse.Node, base schema.Type, t schema.Type) (schema.Type, error) // Extend must to allow for custom must optimisations ExtendMust(p parse.Node, m parse.Node) (string, error) ExtendOpdCommand(parse.Node, schema.OpdCommand) (schema.OpdCommand, error) ExtendOpdOption(parse.Node, schema.OpdOption) (schema.OpdOption, error) ExtendOpdArgument(parse.Node, schema.OpdArgument) (schema.OpdArgument, error) }
* To add extensions to the schema tree a simple pattern is followed. * The compiler turns a set of parse nodes into a schema node. As each * node is compiled, it is passed to the extensions which are given an * opportunity to wrap (decorate) the node with any extensions. If * the extensions are misused then an error may be returned instead.
type FeatureStatus ¶
type FeatureStatus int
const ( DISABLED FeatureStatus = iota ENABLED NOTPRESENT )
func StatusFromBool ¶
func StatusFromBool(b bool) FeatureStatus
func (FeatureStatus) String ¶
func (f FeatureStatus) String() string
type FeaturesChecker ¶
type FeaturesChecker interface {
Status(feature string) FeatureStatus
}
FeaturesChecker checks the status of a feature feature is formatted <module>:<feature name>
func FeaturesFromLocations ¶
func FeaturesFromLocations(enabled bool, locations ...string) FeaturesChecker
func FeaturesFromNames ¶
func FeaturesFromNames(enabled bool, features ...string) FeaturesChecker
func MultiFeatureCheckers ¶
func MultiFeatureCheckers(f ...FeaturesChecker) FeaturesChecker
type SchemaFilter ¶
func Exclude ¶
func Exclude(filters ...SchemaFilter) SchemaFilter
Returns a filter which will exclude nodes that match a set of filters
func Include ¶
func Include(filters ...SchemaFilter) SchemaFilter
Returns a filter which will include nodes that match a set of filters
func IncludeState ¶
func IncludeState(state bool) SchemaFilter
Returns an operational state node filter if state is true
func IsConfigOrState ¶
func IsConfigOrState() SchemaFilter
Filter configuration and operational state nodes
type SchemaType ¶
type SchemaType int
const ( SchemaBool SchemaType = iota SchemaEmpty SchemaEnumeration SchemaIdentity SchemaInstanceId SchemaNumber SchemaDecimal64 SchemaString SchemaUnion SchemaBits SchemaLeafRef )
type YangLocator ¶
func YangDirs ¶
func YangDirs(dirs ...string) YangLocator
func YangFiles ¶
func YangFiles(files ...string) YangLocator
func YangLocations ¶
func YangLocations(locations ...YangLocator) YangLocator