Documentation
¶
Index ¶
- Constants
- Variables
- func AllOutput() []string
- func CheckReservedParamName(paramName string) string
- func ClassTypeMember(classType string, className string) string
- func ClassTypeNeighbor(layer string) string
- func ClassTypeValue(paramRuleName string) string
- func GetRelativeFilePath(path string, cfg *Config) string
- func InitGloballNameSpace(nm *NetworkModel) (map[string]map[string]string, error)
- func ReservedNames() []string
- func ReservedPrefixes() []string
- type BlocksConfig
- type Config
- func (cfg *Config) AddConnectionClass(nc *ConnectionClass)
- func (cfg *Config) AddFileDefinition(filedef *FileDefinition)
- func (cfg *Config) AddFormatStyle(fmtstyle *FormatStyle)
- func (cfg *Config) AddInterfaceClass(nc *InterfaceClass)
- func (cfg *Config) AddNetworkClass(nc *NetworkClass)
- func (cfg *Config) AddNodeClass(nc *NodeClass)
- func (cfg *Config) AddParameterRule(pr *ParameterRule)
- func (cfg *Config) ConnectionClassByName(name string) (*ConnectionClass, bool)
- func (cfg *Config) DefaultConnectionLayer() []string
- func (cfg *Config) FileDefinitionByName(name string) (*FileDefinition, bool)
- func (cfg *Config) FormatStyleByName(name string) (*FormatStyle, bool)
- func (cfg *Config) GetValidConnectionClasses(given []string) *ParsedLabels
- func (cfg *Config) GetValidGroupClasses(given []string) *ParsedLabels
- func (cfg *Config) GetValidInterfaceClasses(given []string) *ParsedLabels
- func (cfg *Config) GetValidNodeClasses(given []string) *ParsedLabels
- func (cfg *Config) GetValidSegmentClasses(given []string) *ParsedLabels
- func (cfg *Config) GroupClassByName(name string) (*GroupClass, bool)
- func (cfg *Config) HasManagementLayer() bool
- func (cfg *Config) InterfaceClassByName(name string) (*InterfaceClass, bool)
- func (cfg *Config) LayerByName(name string) (*Layer, bool)
- func (cfg *Config) MountSourcePath(path string) (string, error)
- func (cfg *Config) NeighborClassesByName(iface string, ipspace string) ([]*NeighborClass, bool)
- func (cfg *Config) NodeClassByName(name string) (*NodeClass, bool)
- func (cfg *Config) ParameterRuleByName(name string) (*ParameterRule, bool)
- func (cfg *Config) SegmentClassByName(name string) (*SegmentClass, bool)
- type ConfigTemplate
- func (ct *ConfigTemplate) GetAssemblyFormats() []string
- func (ct *ConfigTemplate) GetClassInfo() (string, string)
- func (ct *ConfigTemplate) GetFormats() []string
- func (ct *ConfigTemplate) GetNamespaceFormats() []string
- func (ct *ConfigTemplate) HasRequiredParams(params map[string]string) bool
- func (ct *ConfigTemplate) NeighborNodeClassCheck(node *Node) bool
- func (ct *ConfigTemplate) NodeClassCheck(node *Node) bool
- func (ct *ConfigTemplate) String() string
- type Connection
- func (mr Connection) AddMember(m *Member)
- func (mr Connection) AddMemberClass(mc *MemberClass)
- func (vr Connection) AddValue(v *Value)
- func (a Connection) AwareLayer(layer string) bool
- func (conn *Connection) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (conn *Connection) ChildClasses() ([]string, error)
- func (conn *Connection) Childs(c string) ([]NameSpacer, error)
- func (conn *Connection) ClassDefinition(cfg *Config, cls string) (interface{}, error)
- func (conn *Connection) DependClasses() ([]string, error)
- func (conn *Connection) Depends(c string) ([]NameSpacer, error)
- func (conn *Connection) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (a Connection) GetLayerPolicy(layer string) *IPPolicy
- func (mr Connection) GetMemberClasses() []*MemberClass
- func (mr Connection) GetMembers() []*Member
- func (conn *Connection) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr Connection) GetValues() []*Value
- func (vr Connection) GetValuesByParamRule(paramRuleName string) []*Value
- func (conn *Connection) GivenIPNetwork(layer Layerer) (string, bool)
- func (conn *Connection) SetClasses(cfg *Config, nm *NetworkModel) error
- func (conn *Connection) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
- func (conn *Connection) SortKey() string
- func (conn *Connection) String() string
- func (conn *Connection) StringForMessage() string
- type ConnectionClass
- type FileDefinition
- type FileGenerator
- type FormatStyle
- func (fs *FormatStyle) GetFormatBlockPrefix() string
- func (fs *FormatStyle) GetFormatBlockSuffix() string
- func (fs *FormatStyle) GetFormatLinePrefix() string
- func (fs *FormatStyle) GetFormatLineSeparator() string
- func (fs *FormatStyle) GetFormatLineSuffix() string
- func (fs *FormatStyle) GetMergeBlockSeparator() string
- func (fs *FormatStyle) GetMergeResultPrefix() string
- func (fs *FormatStyle) GetMergeResultSuffix() string
- type GlobalSettings
- type Group
- func (vr Group) AddValue(v *Value)
- func (g *Group) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (g *Group) ChildClasses() ([]string, error)
- func (g *Group) Childs(c string) ([]NameSpacer, error)
- func (g *Group) ClassDefinition(cfg *Config, cls string) (interface{}, error)
- func (g *Group) DependClasses() ([]string, error)
- func (g *Group) Depends(c string) ([]NameSpacer, error)
- func (g *Group) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (g *Group) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr Group) GetValues() []*Value
- func (vr Group) GetValuesByParamRule(paramRuleName string) []*Value
- func (g *Group) SetClasses(cfg *Config, nm *NetworkModel) error
- func (g *Group) SetGroupRelativeParams(ns NameSpacer, header string) error
- func (g *Group) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
- func (g *Group) SortKey() string
- func (g *Group) StringForMessage() string
- type GroupClass
- type IPPolicy
- type Interface
- func (mr Interface) AddMember(m *Member)
- func (mr Interface) AddMemberClass(mc *MemberClass)
- func (iface *Interface) AddNeighbor(neighbor *Interface, layer string)
- func (vr Interface) AddValue(v *Value)
- func (a Interface) AwareLayer(layer string) bool
- func (iface *Interface) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (iface *Interface) ChildClasses() ([]string, error)
- func (iface *Interface) Childs(c string) ([]NameSpacer, error)
- func (iface *Interface) ClassDefinition(cfg *Config, cls string) (interface{}, error)
- func (iface *Interface) DependClasses() ([]string, error)
- func (iface *Interface) Depends(c string) ([]NameSpacer, error)
- func (iface *Interface) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (a Interface) GetLayerPolicy(layer string) *IPPolicy
- func (mr Interface) GetMemberClasses() []*MemberClass
- func (mr Interface) GetMembers() []*Member
- func (iface *Interface) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr Interface) GetValues() []*Value
- func (vr Interface) GetValuesByParamRule(paramRuleName string) []*Value
- func (iface *Interface) GivenIPAddress(layer Layerer) (string, bool)
- func (iface *Interface) SetClasses(cfg *Config, nm *NetworkModel) error
- func (iface *Interface) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
- func (iface *Interface) SortKey() string
- func (iface *Interface) String() string
- func (iface *Interface) StringForMessage() string
- type InterfaceClass
- type LabelOwner
- type LabelOwnerClass
- type Layer
- type Layerer
- type ManagementLayer
- type Member
- func (m *Member) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (m *Member) ChildClasses() ([]string, error)
- func (m *Member) Childs(c string) ([]NameSpacer, error)
- func (m *Member) DependClasses() ([]string, error)
- func (m *Member) Depends(c string) ([]NameSpacer, error)
- func (m *Member) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (m *Member) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (m *Member) StringForMessage() string
- type MemberClass
- type MemberReferrer
- type Module
- type NameSpace
- func (ns *NameSpace) AddParam(k, v string)
- func (ns *NameSpace) GetParamValue(key string) (string, error)
- func (ns *NameSpace) GetParams() map[string]string
- func (ns *NameSpace) GetRelativeParams() map[string]string
- func (ns *NameSpace) HasParam(k string) bool
- func (ns *NameSpace) HasRelativeParam(k string) bool
- func (ns *NameSpace) IterateFlaggedParams() <-chan string
- func (ns *NameSpace) SetRelativeParam(k, v string)
- func (ns *NameSpace) SetRelativeParams(given map[string]string)
- type NameSpacer
- type Neighbor
- func (n *Neighbor) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (n *Neighbor) ChildClasses() ([]string, error)
- func (n *Neighbor) Childs(c string) ([]NameSpacer, error)
- func (n *Neighbor) DependClasses() ([]string, error)
- func (n *Neighbor) Depends(c string) ([]NameSpacer, error)
- func (n *Neighbor) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (n *Neighbor) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (n *Neighbor) StringForMessage() string
- type NeighborClass
- type NetworkClass
- type NetworkModel
- func (vr NetworkModel) AddValue(v *Value)
- func (nm *NetworkModel) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (nm *NetworkModel) ChildClasses() ([]string, error)
- func (nm *NetworkModel) Childs(c string) ([]NameSpacer, error)
- func (nm *NetworkModel) ConnectionClassMembers(cls string) []NameSpacer
- func (nm *NetworkModel) DependClasses() ([]string, error)
- func (nm *NetworkModel) Depends(c string) ([]NameSpacer, error)
- func (nm *NetworkModel) FilesToGenerate(cfg *Config) []string
- func (nm *NetworkModel) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (nm *NetworkModel) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr NetworkModel) GetValues() []*Value
- func (vr NetworkModel) GetValuesByParamRule(paramRuleName string) []*Value
- func (nm *NetworkModel) GroupByName(name string) (*Group, bool)
- func (nm *NetworkModel) InterfaceClassMembers(cls string) []NameSpacer
- func (nm *NetworkModel) LabelOwners() (result []LabelOwner)
- func (nm *NetworkModel) MemberReferrers() (result []MemberReferrer)
- func (nm *NetworkModel) NameSpacers() (result []NameSpacer)
- func (nm *NetworkModel) NewConnection(src *Interface, dst *Interface) *Connection
- func (nm *NetworkModel) NewGroup(name string) *Group
- func (nm *NetworkModel) NewNode(name string) *Node
- func (nm *NetworkModel) NodeByName(name string) (*Node, bool)
- func (nm *NetworkModel) NodeClassMembers(cls string) []NameSpacer
- func (nm *NetworkModel) RenameNode(node *Node, oldName string, newName string)
- func (nm *NetworkModel) SegmentClassMembers(cls string) []NameSpacer
- func (nm *NetworkModel) SortKey() string
- func (nm *NetworkModel) StringForMessage() string
- func (nm *NetworkModel) ValueOwners() (result []ValueOwner)
- type NetworkSegment
- func (mr NetworkSegment) AddMember(m *Member)
- func (mr NetworkSegment) AddMemberClass(mc *MemberClass)
- func (vr NetworkSegment) AddValue(v *Value)
- func (seg *NetworkSegment) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (seg *NetworkSegment) ChildClasses() ([]string, error)
- func (seg *NetworkSegment) Childs(c string) ([]NameSpacer, error)
- func (seg *NetworkSegment) ClassDefinition(cfg *Config, cls string) (interface{}, error)
- func (seg *NetworkSegment) DependClasses() ([]string, error)
- func (seg *NetworkSegment) Depends(c string) ([]NameSpacer, error)
- func (seg *NetworkSegment) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (mr NetworkSegment) GetMemberClasses() []*MemberClass
- func (mr NetworkSegment) GetMembers() []*Member
- func (seg *NetworkSegment) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr NetworkSegment) GetValues() []*Value
- func (vr NetworkSegment) GetValuesByParamRule(paramRuleName string) []*Value
- func (seg *NetworkSegment) SetClasses(cfg *Config, nm *NetworkModel) error
- func (seg *NetworkSegment) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
- func (seg *NetworkSegment) SetSegmentLabelsFromRelationalLabels(cfg *Config, layer *Layer) error
- func (seg *NetworkSegment) SortKey() string
- func (seg *NetworkSegment) String() string
- func (seg *NetworkSegment) StringForMessage() string
- type Node
- func (mr Node) AddMember(m *Member)
- func (mr Node) AddMemberClass(mc *MemberClass)
- func (vr Node) AddValue(v *Value)
- func (a Node) AwareLayer(layer string) bool
- func (n *Node) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (n *Node) ChildClasses() ([]string, error)
- func (n *Node) Childs(c string) ([]NameSpacer, error)
- func (n *Node) ClassDefinition(cfg *Config, cls string) (interface{}, error)
- func (n *Node) CreateManagementInterface(cfg *Config, name string) (*Interface, error)
- func (n *Node) DependClasses() ([]string, error)
- func (n *Node) Depends(c string) ([]NameSpacer, error)
- func (n *Node) FilesToGenerate(cfg *Config) []string
- func (n *Node) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (a Node) GetLayerPolicy(layer string) *IPPolicy
- func (n *Node) GetManagementInterface() *Interface
- func (mr Node) GetMemberClasses() []*MemberClass
- func (mr Node) GetMembers() []*Member
- func (n *Node) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (vr Node) GetValues() []*Value
- func (vr Node) GetValuesByParamRule(paramRuleName string) []*Value
- func (n *Node) GivenIPLoopback(layer *Layer) (string, bool)
- func (n *Node) HasAwareInterface(layer string) bool
- func (n *Node) InterfaceByName(name string) (*Interface, bool)
- func (n *Node) NewInterface(name string) *Interface
- func (n *Node) RenameInterface(iface *Interface, oldName string, newName string)
- func (n *Node) SetClasses(cfg *Config, nm *NetworkModel) error
- func (n *Node) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
- func (n *Node) SortKey() string
- func (n *Node) String() string
- func (n *Node) StringForMessage() string
- type NodeClass
- type ObjectClass
- type ObjectInstance
- type ParameterGenerator
- type ParameterRule
- type ParameterRuleSource
- type ParsedLabels
- func (l *ParsedLabels) AddClassLabels(labels ...string)
- func (l *ParsedLabels) ClassLabels() []string
- func (l *ParsedLabels) GetClasses() []ObjectClass
- func (l *ParsedLabels) HasClass(name string) bool
- func (l *ParsedLabels) IsVirtual() bool
- func (l *ParsedLabels) MetaValueLabels() map[string]string
- func (l *ParsedLabels) PlaceLabels() []string
- func (l *ParsedLabels) RelationalClassLabels() []RelationalClassLabel
- func (l *ParsedLabels) SetVirtual(flag bool)
- func (l *ParsedLabels) ValueLabels() map[string]string
- type RelationalClassLabel
- type SegmentClass
- type StandardModule
- func (m *StandardModule) AddModuleConnectionClassLabel(label string)
- func (m *StandardModule) AddModuleInterfaceClassLabel(label string)
- func (m *StandardModule) AddModuleNodeClassLabel(label string)
- func (m *StandardModule) GetModuleConnectionClassLabels() []string
- func (m *StandardModule) GetModuleInterfaceClassLabels() []string
- func (m *StandardModule) GetModuleNodeClassLabels() []string
- type Value
- func (v *Value) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
- func (v *Value) ChildClasses() ([]string, error)
- func (v *Value) Childs(c string) ([]NameSpacer, error)
- func (v *Value) DependClasses() ([]string, error)
- func (v *Value) Depends(c string) ([]NameSpacer, error)
- func (v *Value) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (v *Value) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (v *Value) StringForMessage() string
- type ValueOwner
Constants ¶
const ( // ParameterRuleModeDistribute distributes one parameter per object (default, legacy behavior) ParameterRuleModeDistribute = "distribute" // ParameterRuleModeAttach attaches multiple Values to one object ParameterRuleModeAttach = "attach" )
ParameterRuleMode constants
const ChildConnectionsConfigHeader string = "connections" + NumberSeparator
const ChildGroupsConfigHeader string = "groups" + NumberSeparator
const ChildInterfacesConfigHeader string = "interfaces" + NumberSeparator
const ChildMembersConfigHeader string = "members" + NumberSeparator
const ChildNeighborsConfigHeader string = "neighbors" + NumberSeparator
const ChildNodesConfigHeader string = "nodes" + NumberSeparator
const ChildSegmentsConfigHeader string = "segments" + NumberSeparator
const ClassAll string = "all" // all objects
const ClassDefault string = "default" // all empty objects
const ClassTypeConnection string = "connection"
const ClassTypeGroup string = "group"
const ClassTypeInterface string = "interface"
const ClassTypeMemberClassNameAny = "any"
const ClassTypeMemberHeader string = "member"
const ClassTypeNeighborHeader string = "neighbor"
const ClassTypeNeighborLayerAny = "any"
const ClassTypeNetwork string = "network"
const ClassTypeNode string = "node"
const ClassTypeSegment string = "segment"
const ClassTypeValueHeader string = "value"
const ConfigTemplateStyleHierarchy string = "hierarchy" // ConfigTemplate.Style
const ConfigTemplateStyleSort string = "sort"
const DefaultConnectionPrefix string = "conn"
const DefaultFormatPhaseFormatName = "DefaultFormatPhaseFormat"
Default format names
const DefaultInterfacePrefix string = "net"
const DefaultMergePhaseFormatName = "DefaultMergePhaseFormat"
const DefaultNodePrefix string = "node"
const DefaultSegmentPrefix string = "seg"
IP number replacer: [IPSpace]_[IPReplacerXX] const IPLoopbackReplacerFooter string = "loopback"
const IPPolicyTypeDefault string = "ip"
const IPPolicyTypeLoopback string = "loopback"
const MountSourcePathAbs string = "abs" // absolute path
const MountSourcePathLocal string = "local"
const NumberPrefixConnection string = "conn" + NumberSeparator
const NumberPrefixGroup string = "group" + NumberSeparator
const NumberPrefixMember string = "m" + NumberSeparator
const NumberPrefixNeighbor string = "n" + NumberSeparator
const NumberPrefixNode string = "node" + NumberSeparator
const NumberPrefixOppositeInterface string = "opp" + NumberSeparator
const NumberSeparator string = "_"
namespace related constants
const OutputAsis string = "command"
const OutputClab string = "clab"
const OutputTinet string = "tinet"
const PathSpecificationDefault string = "default" // search files from working directory
const PathSpecificationLocal string = "local" // search files from the directory with config file
const PlaceLabelPrefix string = "@"
const RelationalClassLabelSeparator string = "#"
const ReservedParamName string = "name"
Reserved parameter name for object name
const SelfConfigHeader string = "self" + NumberSeparator
const ValueLabelSeparator string = "="
const ValueReferencePrefix string = "values" + NumberSeparator
Value reference prefix for template parameters
const VirtualNodeClassName string = "virtual"
Special class names used by modules
Variables ¶
var DefaultFormatPhaseFormat = &FormatStyle{ Name: DefaultFormatPhaseFormatName, FormatLineSeparator: "\n", }
Default format definitions
var DefaultMergePhaseFormat = &FormatStyle{ Name: DefaultMergePhaseFormatName, MergeBlockSeparator: "\n", }
Functions ¶
func CheckReservedParamName ¶ added in v0.7.0
CheckReservedParamName checks if a parameter name conflicts with reserved names or prefixes. Returns an error message if the name is reserved, or empty string if it's safe to use.
func ClassTypeMember ¶
func ClassTypeNeighbor ¶
func ClassTypeValue ¶ added in v0.7.0
ClassTypeValue returns the class type string for a Value with given param_rule name
func GetRelativeFilePath ¶
func InitGloballNameSpace ¶
func InitGloballNameSpace(nm *NetworkModel) (map[string]map[string]string, error)
func ReservedNames ¶ added in v0.7.0
func ReservedNames() []string
ReservedNames returns the list of reserved parameter names. These exact names are reserved for internal use.
func ReservedPrefixes ¶ added in v0.7.0
func ReservedPrefixes() []string
ReservedPrefixes returns the list of reserved parameter name prefixes. Parameters starting with these prefixes are reserved for internal use.
Types ¶
type BlocksConfig ¶ added in v0.6.0
type BlocksConfig struct {
Before []string `yaml:"before" mapstructure:"before"`
After []string `yaml:"after" mapstructure:"after"`
}
BlocksConfig defines config blocks to be merged before/after the template
type Config ¶
type Config struct {
Name string `yaml:"name" mapstructure:"name"`
Modules []string `yaml:"module" mapstructure:"module"`
GlobalSettings GlobalSettings `yaml:"global" mapstructure:"global"`
FileDefinitions []*FileDefinition `yaml:"file" mapstructure:"file"`
FormatStyles []*FormatStyle `yaml:"format,flow" mapstructure:"format,flow"`
Layers []*Layer `yaml:"layer" mapstructure:"layer"`
ManagementLayer ManagementLayer `yaml:"mgmt_layer" mapstructure:"mgmt_layer"`
ParameterRules []*ParameterRule `yaml:"param_rule,flow" mapstructure:"param_rule,flow"`
NetworkClasses []*NetworkClass `yaml:"networkclass,flow" mapstructure:"network,flow"`
NodeClasses []*NodeClass `yaml:"nodeclass,flow" mapstructure:"nodes,flow"`
InterfaceClasses []*InterfaceClass `yaml:"interfaceclass,flow" mapstructure:"interfaces,flow"`
ConnectionClasses []*ConnectionClass `yaml:"connectionclass,flow" mapstructure:"connections,flow"`
GroupClasses []*GroupClass `yaml:"groupclass,flow" mapstructure:"group,flow"`
SegmentClasses []*SegmentClass `yaml:"segmentclass,flow" mapstructure:"segments,flow"`
LoadedModules []Module // reference to loaded modules, internal
SorterConfigTemplateGroups mapset.Set[string] // list of sort-style config template groups
// contains filtered or unexported fields
}
func LoadConfig ¶
func LoadTemplates ¶
func (*Config) AddConnectionClass ¶
func (cfg *Config) AddConnectionClass(nc *ConnectionClass)
func (*Config) AddFileDefinition ¶
func (cfg *Config) AddFileDefinition(filedef *FileDefinition)
func (*Config) AddFormatStyle ¶ added in v0.6.0
func (cfg *Config) AddFormatStyle(fmtstyle *FormatStyle)
func (*Config) AddInterfaceClass ¶
func (cfg *Config) AddInterfaceClass(nc *InterfaceClass)
func (*Config) AddNetworkClass ¶
func (cfg *Config) AddNetworkClass(nc *NetworkClass)
func (*Config) AddNodeClass ¶
func (*Config) AddParameterRule ¶ added in v0.7.0
func (cfg *Config) AddParameterRule(pr *ParameterRule)
func (*Config) ConnectionClassByName ¶
func (cfg *Config) ConnectionClassByName(name string) (*ConnectionClass, bool)
func (*Config) DefaultConnectionLayer ¶
func (*Config) FileDefinitionByName ¶
func (cfg *Config) FileDefinitionByName(name string) (*FileDefinition, bool)
func (*Config) FormatStyleByName ¶ added in v0.6.0
func (cfg *Config) FormatStyleByName(name string) (*FormatStyle, bool)
func (*Config) GetValidConnectionClasses ¶
func (cfg *Config) GetValidConnectionClasses(given []string) *ParsedLabels
func (*Config) GetValidGroupClasses ¶
func (cfg *Config) GetValidGroupClasses(given []string) *ParsedLabels
func (*Config) GetValidInterfaceClasses ¶
func (cfg *Config) GetValidInterfaceClasses(given []string) *ParsedLabels
func (*Config) GetValidNodeClasses ¶
func (cfg *Config) GetValidNodeClasses(given []string) *ParsedLabels
func (*Config) GetValidSegmentClasses ¶ added in v0.5.0
func (cfg *Config) GetValidSegmentClasses(given []string) *ParsedLabels
func (*Config) GroupClassByName ¶
func (cfg *Config) GroupClassByName(name string) (*GroupClass, bool)
func (*Config) HasManagementLayer ¶
func (*Config) InterfaceClassByName ¶
func (cfg *Config) InterfaceClassByName(name string) (*InterfaceClass, bool)
func (*Config) NeighborClassesByName ¶
func (cfg *Config) NeighborClassesByName(iface string, ipspace string) ([]*NeighborClass, bool)
func (*Config) ParameterRuleByName ¶
func (cfg *Config) ParameterRuleByName(name string) (*ParameterRule, bool)
func (*Config) SegmentClassByName ¶ added in v0.5.0
func (cfg *Config) SegmentClassByName(name string) (*SegmentClass, bool)
type ConfigTemplate ¶
type ConfigTemplate struct {
// Config block aggregation styles
// hierarchy (default): specify child config templates in the template description as parameter
// sort: merge child config templates of SortTarget groups into the "sort" config templates
Style string `yaml:"style" mapstructure:"style"`
SortGroup string `yaml:"sort_group" mapstructure:"sort_group"`
// Target file definition name
// Config templates with file will generate a file of generated text
File string `yaml:"file" mapstructure:"file"`
// Name is used by parent objects to specify as childs in templates
// Config templates with name will form a parameter that can be embeded in other hierarchy templates
Name string `yaml:"name" mapstructure:"name"`
// Group is used for sort config templates
// A sort config template will aggregate all config blocks generated in child (or grandchild) objects of the same group
Group string `yaml:"group" mapstructure:"group"`
// Priority is used to reorder config templates in sort style
// Config blocks with smaller priority should be on the top of generated config files
// Default is 0, so users should specify negative values to make a config block top of a file
Priority int `yaml:"priority" mapstructure:"priority"`
// Used for hierarchy config templates
// Config template names on same object that need to be embeded
// Required for ordering config template generation considering the dependency
Depends []string `yaml:"depends" mapstructure:"depends"`
// Blocks configuration for flexible config block merging
Blocks BlocksConfig `yaml:"blocks" mapstructure:"blocks"`
// Format specifications
// NamespaceFormat: format applied when registering config blocks to namespace
NamespaceFormat string `yaml:"namespace_format" mapstructure:"namespace_format"`
NamespaceFormats []string `yaml:"namespace_formats" mapstructure:"namespace_formats"`
// AssemblyFormat: format applied when assembling config blocks (Sort, blocks)
AssemblyFormat string `yaml:"assembly_format" mapstructure:"assembly_format"`
AssemblyFormats []string `yaml:"assembly_formats" mapstructure:"assembly_formats"`
// Condition related fields
// add config only for interfaces of nodes belongs to the nodeclass(es)
// this option is valid only on InterfaceClass, ConnectionClass, and their NeighborClass
NodeClass string `yaml:"node" mapstructure:"node"`
NodeClasses []string `yaml:"nodes" mapstructure:"nodes"`
// add config only if the neighbor node belongs to the nodeclass(es)
// this option is valid only on NeighborClass
NeighborNodeClass string `yaml:"neighbor_node" mapstructure:"neighbor_node"`
NeighborNodeClasses []string `yaml:"neighbor_nodes" mapstructure:"neighbor_nodes"`
// put empty file or namespace if conditions are not satisfied
Empty bool `yaml:"empty" mapstructure:"empty"`
// RequiredParams specifies parameters that must exist for this template to generate output
// If any of the specified parameters are missing, the entire block is skipped
RequiredParams []string `yaml:"required_params,flow" mapstructure:"required_params,flow"`
// This option is valid only on InterfaceClass or ConnectionClass
// If specified, add config only for included output (e.g., tinet only, clab only, etc)
Platform []string `yaml:"platform,flow" mapstructure:"platform,flow"`
// Style is used to iterpret the given config format. Style can be different on one file. As-is in default.
//Style string `yaml:"style" mapstructure:"style"`
Format string `yaml:"format" mapstructure:"format"`
Formats []string `yaml:"formats" mapstructure:"formats"`
// Priority is a value to be used for sorting config blocks. 0 in default.
// Priority int `yaml:"priority" mapstructure:"priority"`
// Load config template
Template []string `yaml:"template" mapstructure:"template"`
// Load config template from external file
SourceFile string `yaml:"sourcefile" mapstructure:"sourcefile"`
ParsedTemplate *template.Template
// contains filtered or unexported fields
}
func (*ConfigTemplate) GetAssemblyFormats ¶ added in v0.6.0
func (ct *ConfigTemplate) GetAssemblyFormats() []string
GetAssemblyFormats returns formats to apply when assembling config blocks (Sort, blocks) Falls back to GetFormats() for backward compatibility, then to default format
func (*ConfigTemplate) GetClassInfo ¶
func (ct *ConfigTemplate) GetClassInfo() (string, string)
func (*ConfigTemplate) GetFormats ¶
func (ct *ConfigTemplate) GetFormats() []string
func (*ConfigTemplate) GetNamespaceFormats ¶ added in v0.6.0
func (ct *ConfigTemplate) GetNamespaceFormats() []string
GetNamespaceFormats returns formats to apply when registering config blocks to namespace Falls back to GetFormats() for backward compatibility, then to default format
func (*ConfigTemplate) HasRequiredParams ¶ added in v0.7.0
func (ct *ConfigTemplate) HasRequiredParams(params map[string]string) bool
HasRequiredParams checks if all required parameters exist and are non-empty in the given params map. Returns true if RequiredParams is empty or all required parameters exist with non-empty values. Returns false if any required parameter is missing or has an empty value.
func (*ConfigTemplate) NeighborNodeClassCheck ¶
func (ct *ConfigTemplate) NeighborNodeClassCheck(node *Node) bool
func (*ConfigTemplate) NodeClassCheck ¶
func (ct *ConfigTemplate) NodeClassCheck(node *Node) bool
return true if conditions satisfied
func (*ConfigTemplate) String ¶
func (ct *ConfigTemplate) String() string
type Connection ¶
type Connection struct {
Name string
Src *Interface
Dst *Interface
Layers mapset.Set[string]
*ParsedLabels
*NameSpace
// contains filtered or unexported fields
}
func (Connection) AddMemberClass ¶ added in v0.5.0
func (mr Connection) AddMemberClass(mc *MemberClass)
func (Connection) AddValue ¶ added in v0.7.0
func (vr Connection) AddValue(v *Value)
AddValue adds a Value to the reference
func (Connection) AwareLayer ¶ added in v0.5.0
func (*Connection) BuildRelativeNameSpace ¶ added in v0.5.0
func (conn *Connection) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
func (*Connection) ChildClasses ¶
func (conn *Connection) ChildClasses() ([]string, error)
func (*Connection) Childs ¶
func (conn *Connection) Childs(c string) ([]NameSpacer, error)
func (*Connection) ClassDefinition ¶
func (conn *Connection) ClassDefinition(cfg *Config, cls string) (interface{}, error)
func (*Connection) DependClasses ¶ added in v0.5.0
func (conn *Connection) DependClasses() ([]string, error)
func (*Connection) Depends ¶ added in v0.5.0
func (conn *Connection) Depends(c string) ([]NameSpacer, error)
func (*Connection) GetConfigTemplates ¶ added in v0.5.0
func (conn *Connection) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (Connection) GetLayerPolicy ¶ added in v0.5.0
func (Connection) GetMemberClasses ¶ added in v0.5.0
func (mr Connection) GetMemberClasses() []*MemberClass
func (Connection) GetMembers ¶ added in v0.5.0
func (mr Connection) GetMembers() []*Member
func (*Connection) GetPossibleConfigTemplates ¶ added in v0.5.0
func (conn *Connection) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (Connection) GetValues ¶ added in v0.7.0
func (vr Connection) GetValues() []*Value
GetValues returns all Values
func (Connection) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*Connection) GivenIPNetwork ¶
func (conn *Connection) GivenIPNetwork(layer Layerer) (string, bool)
func (*Connection) SetClasses ¶
func (conn *Connection) SetClasses(cfg *Config, nm *NetworkModel) error
func (*Connection) SetLabels ¶
func (conn *Connection) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
func (*Connection) SortKey ¶ added in v0.7.0
func (conn *Connection) SortKey() string
func (*Connection) String ¶
func (conn *Connection) String() string
func (*Connection) StringForMessage ¶
func (conn *Connection) StringForMessage() string
type ConnectionClass ¶
type ConnectionClass struct {
Name string `yaml:"name" mapstructure:"name"`
Virtual bool `yaml:"virtual" mapstructure:"virtual"`
IPPolicy []string `yaml:"policy,flow" mapstructure:"policy,flow"`
Layers []string `yaml:"layers,flow" mapstructure:"layers,flow"` // Connection is limited to specified layers
Parameters []string `yaml:"params,flow" mapstructure:"params,flow"` // Parameter policies
Values map[string]string `yaml:"values" mapstructure:"values"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
MemberClasses []*MemberClass `yaml:"classmembers,flow" mapstructure:"classmembers,flow"`
// Connection naming
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of connection auto-naming
LabelOwnerClass
}
func (*ConnectionClass) GetGivenValues ¶
func (cc *ConnectionClass) GetGivenValues() map[string]string
type FileDefinition ¶
type FileDefinition struct {
// Name is used as the filename of generated file.
// If empty and NamePrefix/NameSuffix are specified, filename is generated as:
// {NamePrefix}{object_name}{NameSuffix}
Name string `yaml:"name" mapstructure:"name"`
// NamePrefix is prepended to the object name when Name is empty.
NamePrefix string `yaml:"name_prefix" mapstructure:"name_prefix"`
// NameSuffix is appended to the object name when Name is empty.
NameSuffix string `yaml:"name_suffix" mapstructure:"name_suffix"`
// Path is the path that the generated file is placed on the node.
// If empty, the file is generated but not placed on the node.
Path string `yaml:"path" mapstructure:"path"`
// Format is used to determine the way to format lines in generated config text.
Format string `yaml:"format" mapstructure:"format"`
Formats []string `yaml:"formats,flow" mapstructure:"formats,flow"`
// Scope specifies the scope of file creation.
// Available values:
// - "network": File is created at network level (root directory)
// - "node": File is created for each node (node_name/file_name)
// - "" (empty): Defaults to "node" scope for backward compatibility
// Examples:
// - Scope = "network": Creates "spec.yaml", "topo.yaml" at root
// - Scope = "node" or "": Creates "r1/frr.conf", "r2/frr.conf", etc.
Scope string `yaml:"scope" mapstructure:"scope"`
// Output specifies where the file is placed in the output directory.
// Available values:
// - "root": File is placed at root directory
// - "node": File is placed in node subdirectory (node_name/file_name)
// - "" (empty): Defaults based on Scope (network->root, node->node)
// This is useful for Kathara-style startup files that need to be at root
// but are generated per-node (e.g., r1.startup, r2.startup).
Output string `yaml:"output" mapstructure:"output"`
}
func (*FileDefinition) GetFileName ¶ added in v0.7.0
func (fd *FileDefinition) GetFileName(objectName string) string
GetFileName returns the output filename for this file definition. If NamePrefix or NameSuffix is specified, it generates filename as:
{NamePrefix}{objectName}{NameSuffix}
Otherwise, it returns Name directly. This allows Name to be used as an identifier for referencing, while NamePrefix/NameSuffix control the actual output filename.
func (*FileDefinition) GetFormats ¶
func (fd *FileDefinition) GetFormats() []string
func (*FileDefinition) GetOutputLocation ¶ added in v0.7.0
func (fd *FileDefinition) GetOutputLocation() string
GetOutputLocation returns the effective output location. If Output is specified, it returns Output. If Output is empty, it returns the default based on Scope:
- "network" -> "root"
- "node" or "" -> "node"
type FileGenerator ¶ added in v0.6.0
type FileGenerator interface {
// FilesToGenerate returns a list of file names that this object will generate based on its classes.
FilesToGenerate(cfg *Config) []string
}
FileGenerator is an interface for objects that can generate files. Both NetworkModel and Node implement this interface.
type FormatStyle ¶ added in v0.6.0
type FormatStyle struct {
Name string `yaml:"name" mapstructure:"name"`
// Format Phase (block生成時の装飾)
FormatLinePrefix string `yaml:"format_lineprefix" mapstructure:"format_lineprefix"`
FormatLineSuffix string `yaml:"format_linesuffix" mapstructure:"format_linesuffix"`
FormatLineSeparator string `yaml:"format_lineseparator" mapstructure:"format_lineseparator"`
FormatBlockPrefix string `yaml:"format_blockprefix" mapstructure:"format_blockprefix"`
FormatBlockSuffix string `yaml:"format_blocksuffix" mapstructure:"format_blocksuffix"`
// Merge Phase (block結合時の処理)
MergeBlockSeparator string `yaml:"merge_blockseparator" mapstructure:"merge_blockseparator"`
MergeResultPrefix string `yaml:"merge_resultprefix" mapstructure:"merge_resultprefix"`
MergeResultSuffix string `yaml:"merge_resultsuffix" mapstructure:"merge_resultsuffix"`
}
FormatStyle defines how to format configuration blocks Renamed from FileFormat to align with YAML `format:` section
func (*FormatStyle) GetFormatBlockPrefix ¶ added in v0.6.0
func (fs *FormatStyle) GetFormatBlockPrefix() string
func (*FormatStyle) GetFormatBlockSuffix ¶ added in v0.6.0
func (fs *FormatStyle) GetFormatBlockSuffix() string
func (*FormatStyle) GetFormatLinePrefix ¶ added in v0.6.0
func (fs *FormatStyle) GetFormatLinePrefix() string
Format Phase Getters
func (*FormatStyle) GetFormatLineSeparator ¶ added in v0.6.0
func (fs *FormatStyle) GetFormatLineSeparator() string
func (*FormatStyle) GetFormatLineSuffix ¶ added in v0.6.0
func (fs *FormatStyle) GetFormatLineSuffix() string
func (*FormatStyle) GetMergeBlockSeparator ¶ added in v0.6.0
func (fs *FormatStyle) GetMergeBlockSeparator() string
Merge Phase Getters
func (*FormatStyle) GetMergeResultPrefix ¶ added in v0.6.0
func (fs *FormatStyle) GetMergeResultPrefix() string
func (*FormatStyle) GetMergeResultSuffix ¶ added in v0.6.0
func (fs *FormatStyle) GetMergeResultSuffix() string
type GlobalSettings ¶
type Group ¶
type Group struct {
Name string
Nodes []*Node
*NameSpace
*ParsedLabels
// contains filtered or unexported fields
}
func (Group) AddValue ¶ added in v0.7.0
func (vr Group) AddValue(v *Value)
AddValue adds a Value to the reference
func (*Group) BuildRelativeNameSpace ¶
func (*Group) ChildClasses ¶
func (*Group) ClassDefinition ¶
func (*Group) DependClasses ¶ added in v0.5.0
func (*Group) GetConfigTemplates ¶
func (g *Group) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Group) GetPossibleConfigTemplates ¶
func (g *Group) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (Group) GetValues ¶ added in v0.7.0
func (vr Group) GetValues() []*Value
GetValues returns all Values
func (Group) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*Group) SetClasses ¶
func (g *Group) SetClasses(cfg *Config, nm *NetworkModel) error
func (*Group) SetGroupRelativeParams ¶
func (g *Group) SetGroupRelativeParams(ns NameSpacer, header string) error
Set relative parameters of the group to the group member namespacers
func (*Group) StringForMessage ¶
type GroupClass ¶
type GroupClass struct {
Name string `yaml:"name" mapstructure:"name"`
Virtual bool `yaml:"virtual" mapstructure:"virtual"`
Parameters []string `yaml:"params,flow" mapstructure:"params,flow"` // Parameter policies
Values map[string]string `yaml:"values" mapstructure:"values"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
LabelOwnerClass
}
func (*GroupClass) GetGivenValues ¶
func (gc *GroupClass) GetGivenValues() map[string]string
type IPPolicy ¶
type IPPolicy struct {
Name string `yaml:"name" mapstructure:"name"`
// type: ip (deafult), loopback, mgmt
Type string `yaml:"type" mapstructure:"type"`
AddrRange string `yaml:"range" mapstructure:"range"`
DefaultPrefixLength int `yaml:"prefix" mapstructure:"prefix"`
// contains filtered or unexported fields
}
type Interface ¶
type Interface struct {
Name string
Node *Node
Virtual bool
Connection *Connection
Opposite *Interface
Neighbors map[string][]*Neighbor
NamePrefix string
*NameSpace
*ParsedLabels
// contains filtered or unexported fields
}
func (Interface) AddMemberClass ¶
func (mr Interface) AddMemberClass(mc *MemberClass)
func (*Interface) AddNeighbor ¶
add Neighbor object only when the Interface has NeighborClasses of corresponding layer
func (Interface) AddValue ¶ added in v0.7.0
func (vr Interface) AddValue(v *Value)
AddValue adds a Value to the reference
func (Interface) AwareLayer ¶
func (*Interface) BuildRelativeNameSpace ¶
func (*Interface) ChildClasses ¶
func (*Interface) ClassDefinition ¶
func (*Interface) DependClasses ¶ added in v0.5.0
func (*Interface) Depends ¶ added in v0.5.0
func (iface *Interface) Depends(c string) ([]NameSpacer, error)
func (*Interface) GetConfigTemplates ¶
func (iface *Interface) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (Interface) GetLayerPolicy ¶
func (Interface) GetMemberClasses ¶
func (mr Interface) GetMemberClasses() []*MemberClass
func (Interface) GetMembers ¶
func (mr Interface) GetMembers() []*Member
func (*Interface) GetPossibleConfigTemplates ¶
func (iface *Interface) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (Interface) GetValues ¶ added in v0.7.0
func (vr Interface) GetValues() []*Value
GetValues returns all Values
func (Interface) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*Interface) GivenIPAddress ¶
func (*Interface) SetClasses ¶
func (iface *Interface) SetClasses(cfg *Config, nm *NetworkModel) error
func (*Interface) StringForMessage ¶
type InterfaceClass ¶
type InterfaceClass struct {
Name string `yaml:"name" mapstructure:"name"`
Virtual bool `yaml:"virtual" mapstructure:"virtual"`
IPPolicy []string `yaml:"policy,flow" mapstructure:"policy,flow"`
Layers []string `yaml:"layers,flow" mapstructure:"layers,flow"` // Interface connection is limited to specified layers
Parameters []string `yaml:"params,flow" mapstructure:"params,flow"` // Parameter policies
Values map[string]string `yaml:"values" mapstructure:"values"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
NeighborClasses []*NeighborClass `yaml:"neighbors,flow" mapstructure:"neighbors,flow"`
MemberClasses []*MemberClass `yaml:"classmembers,flow" mapstructure:"classmembers,flow"`
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of auto-naming
LabelOwnerClass
}
func (*InterfaceClass) GetGivenValues ¶
func (ic *InterfaceClass) GetGivenValues() map[string]string
type LabelOwner ¶
type LabelOwner interface {
ClassLabels() []string
RelationalClassLabels() []RelationalClassLabel
PlaceLabels() []string
ValueLabels() map[string]string
MetaValueLabels() map[string]string
SetLabels(cfg *Config, labels []string, moduleLabels []string) error
AddClassLabels(labels ...string)
HasClass(string) bool
GetClasses() []ObjectClass
SetVirtual(bool)
IsVirtual() bool
ClassDefinition(cfg *Config, cls string) (interface{}, error)
ObjectInstance
}
LabelOwner includes Node, Interface, Connection, Group
type LabelOwnerClass ¶
type Layer ¶
type Layer struct {
Name string `yaml:"name" mapstructure:"name"`
// If default_connect is true, ConnectionClasses without ipspaces field are considered as connected on this Layer
DefaultConnect bool `yaml:"default_connect" mapstructure:"default_connect"`
Policies []*IPPolicy `yaml:"policy" mapstructure:"policy"`
Layerer
IPPolicy []*IPPolicy
LoopbackPolicy []*IPPolicy
}
func (*Layer) IPAddressReplacer ¶
func (*Layer) IPLoopbackReplacer ¶
func (*Layer) IPNetworkReplacer ¶
func (*Layer) IPPrefixLengthReplacer ¶
func (*Layer) IPProtocolReplacer ¶
type ManagementLayer ¶
type ManagementLayer struct {
Name string `yaml:"name" mapstructure:"name"`
AddrRange string `yaml:"range" mapstructure:"range"`
// gateway is used only for management network or external network
// the address is avoided in automated IPaddress assignment
ExternalGateway string `yaml:"gateway" mapstructure:"gateway"`
InterfaceName string `yaml:"interface_name" mapstructure:"mgmt_name"`
Layerer
}
func (*ManagementLayer) IPAddressReplacer ¶
func (layer *ManagementLayer) IPAddressReplacer() string
func (*ManagementLayer) IPNetworkReplacer ¶
func (layer *ManagementLayer) IPNetworkReplacer() string
func (*ManagementLayer) IPPrefixLengthReplacer ¶
func (layer *ManagementLayer) IPPrefixLengthReplacer() string
type Member ¶
type Member struct {
ClassName string
ClassType string
Referrer MemberReferrer
Member NameSpacer
*NameSpace
}
func NewMember ¶
func NewMember(cls string, classtype string, memberObject NameSpacer, referrer MemberReferrer) *Member
func (*Member) BuildRelativeNameSpace ¶
func (*Member) ChildClasses ¶
func (*Member) DependClasses ¶ added in v0.5.0
func (*Member) GetConfigTemplates ¶
func (m *Member) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Member) GetPossibleConfigTemplates ¶
func (m *Member) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Member) StringForMessage ¶
type MemberClass ¶
type MemberClass struct {
NodeClass string `yaml:"node" mapstructure:"node"`
NodeClasses []string `yaml:"nodes" mapstructure:"nodes"`
InterfaceClass string `yaml:"interface" mapstructure:"interface"`
InterfaceClasses []string `yaml:"interfaces" mapstructure:"interfaces"`
ConnectionClass string `yaml:"connection" mapstructure:"connection"`
ConnectionClasses []string `yaml:"connections" mapstructure:"connections"`
IncludeSelf bool `yaml:"include_self" mapstructure:"include_self"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
}
func (*MemberClass) GetSpecifiedClasses ¶
func (mc *MemberClass) GetSpecifiedClasses() (string, []string, error)
check MemberClass description and return (classtype, classnames)
type MemberReferrer ¶
type MemberReferrer interface {
LabelOwner
NameSpacer
ObjectInstance
AddMemberClass(*MemberClass)
GetMemberClasses() []*MemberClass
AddMember(*Member)
GetMembers() []*Member
}
classMemberReferer includes Node, Interface commented out because it currently does not have abstracted usage (explicitly addressed) Note: MemberClass is defined in config.go
type Module ¶
type Module interface {
UpdateConfig(cfg *Config) error
AddModuleNodeClassLabel(label string)
GetModuleNodeClassLabels() []string
AddModuleInterfaceClassLabel(label string)
GetModuleInterfaceClassLabels() []string
AddModuleConnectionClassLabel(label string)
GetModuleConnectionClassLabels() []string
//SetClasses(cfg *Config, nm *NetworkModel) error
GenerateParameters(cfg *Config, nm *NetworkModel) error
CheckModuleRequirements(cfg *Config, nm *NetworkModel) error
}
type NameSpace ¶
type NameSpace struct {
// contains filtered or unexported fields
}
Namespace only implements parameter related methods, but does not provide top-down structure
func (*NameSpace) GetParamValue ¶
GetParamValue returns a parameter value from relative namespace
func (*NameSpace) GetRelativeParams ¶
func (*NameSpace) HasRelativeParam ¶
func (*NameSpace) IterateFlaggedParams ¶
func (*NameSpace) SetRelativeParam ¶
func (*NameSpace) SetRelativeParams ¶
type NameSpacer ¶
type NameSpacer interface {
// Methods to trace top-down network model
ChildClasses() ([]string, error)
Childs(c string) ([]NameSpacer, error)
// Methods for dependency graph processing
DependClasses() ([]string, error)
Depends(c string) ([]NameSpacer, error)
IterateFlaggedParams() <-chan string
AddParam(k, v string)
HasParam(k string) bool
// BuildRelativeNameSpace() error
BuildRelativeNameSpace(globalParams map[string]map[string]string) error
SetRelativeParam(k, v string)
HasRelativeParam(k string) bool
SetRelativeParams(map[string]string)
GetParams() map[string]string
GetRelativeParams() map[string]string
GetParamValue(string) (string, error)
GetConfigTemplates(cfg *Config) []*ConfigTemplate
GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
ObjectInstance
// contains filtered or unexported methods
}
NameSpacer is an element of top-down network model A namespacer owns parameter namespace and generates configuration blocks Candidates: Network, Node, Interface, Segment, Neighbor, Member, Group
type Neighbor ¶
type Neighbor struct {
Self *Interface
Neighbor *Interface
Layer string
NeighborClasses []*NeighborClass
*NameSpace
}
func (*Neighbor) BuildRelativeNameSpace ¶
func (*Neighbor) ChildClasses ¶
func (*Neighbor) DependClasses ¶ added in v0.5.0
func (*Neighbor) Depends ¶ added in v0.5.0
func (n *Neighbor) Depends(c string) ([]NameSpacer, error)
func (*Neighbor) GetConfigTemplates ¶
func (n *Neighbor) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Neighbor) GetPossibleConfigTemplates ¶
func (n *Neighbor) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Neighbor) StringForMessage ¶
type NeighborClass ¶
type NeighborClass struct {
Layer string `yaml:"layer" mapstructure:"layer"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
}
type NetworkClass ¶
type NetworkClass struct {
Name string `yaml:"name" mapstructure:"name"`
Values map[string]string `yaml:"values" mapstructure:"values"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
LabelOwnerClass
}
func (*NetworkClass) GetGivenValues ¶
func (nc *NetworkClass) GetGivenValues() map[string]string
type NetworkModel ¶
type NetworkModel struct {
Name string
Nodes []*Node
Connections []*Connection
Groups []*Group
Classes []*NetworkClass
*NameSpace
NetworkSegments map[string][]*NetworkSegment
// contains filtered or unexported fields
}
func NewNetworkModel ¶
func NewNetworkModel() *NetworkModel
func (NetworkModel) AddValue ¶ added in v0.7.0
func (vr NetworkModel) AddValue(v *Value)
AddValue adds a Value to the reference
func (*NetworkModel) BuildRelativeNameSpace ¶
func (nm *NetworkModel) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
func (*NetworkModel) ChildClasses ¶
func (nm *NetworkModel) ChildClasses() ([]string, error)
func (*NetworkModel) Childs ¶
func (nm *NetworkModel) Childs(c string) ([]NameSpacer, error)
func (*NetworkModel) ConnectionClassMembers ¶
func (nm *NetworkModel) ConnectionClassMembers(cls string) []NameSpacer
func (*NetworkModel) DependClasses ¶ added in v0.5.0
func (nm *NetworkModel) DependClasses() ([]string, error)
func (*NetworkModel) Depends ¶ added in v0.5.0
func (nm *NetworkModel) Depends(c string) ([]NameSpacer, error)
func (*NetworkModel) FilesToGenerate ¶ added in v0.6.0
func (nm *NetworkModel) FilesToGenerate(cfg *Config) []string
FilesToGenerate returns a list of file names that the network will generate based on its NetworkClasses.
func (*NetworkModel) GetConfigTemplates ¶
func (nm *NetworkModel) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*NetworkModel) GetPossibleConfigTemplates ¶
func (nm *NetworkModel) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (NetworkModel) GetValues ¶ added in v0.7.0
func (vr NetworkModel) GetValues() []*Value
GetValues returns all Values
func (NetworkModel) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*NetworkModel) GroupByName ¶
func (nm *NetworkModel) GroupByName(name string) (*Group, bool)
func (*NetworkModel) InterfaceClassMembers ¶
func (nm *NetworkModel) InterfaceClassMembers(cls string) []NameSpacer
func (*NetworkModel) LabelOwners ¶
func (nm *NetworkModel) LabelOwners() (result []LabelOwner)
func (*NetworkModel) MemberReferrers ¶
func (nm *NetworkModel) MemberReferrers() (result []MemberReferrer)
func (*NetworkModel) NameSpacers ¶
func (nm *NetworkModel) NameSpacers() (result []NameSpacer)
func (*NetworkModel) NewConnection ¶
func (nm *NetworkModel) NewConnection(src *Interface, dst *Interface) *Connection
func (*NetworkModel) NewGroup ¶
func (nm *NetworkModel) NewGroup(name string) *Group
func (*NetworkModel) NewNode ¶
func (nm *NetworkModel) NewNode(name string) *Node
func (*NetworkModel) NodeByName ¶
func (nm *NetworkModel) NodeByName(name string) (*Node, bool)
func (*NetworkModel) NodeClassMembers ¶
func (nm *NetworkModel) NodeClassMembers(cls string) []NameSpacer
func (*NetworkModel) RenameNode ¶
func (nm *NetworkModel) RenameNode(node *Node, oldName string, newName string)
func (*NetworkModel) SegmentClassMembers ¶ added in v0.5.0
func (nm *NetworkModel) SegmentClassMembers(cls string) []NameSpacer
func (*NetworkModel) SortKey ¶ added in v0.7.0
func (nm *NetworkModel) SortKey() string
func (*NetworkModel) StringForMessage ¶
func (nm *NetworkModel) StringForMessage() string
func (*NetworkModel) ValueOwners ¶ added in v0.7.0
func (nm *NetworkModel) ValueOwners() (result []ValueOwner)
ValueOwners returns all objects that can have Values attached
type NetworkSegment ¶ added in v0.5.0
type NetworkSegment struct {
Name string // Auto-assigned name
Layer string
Interfaces []*Interface
Connections []*Connection
NamePrefix string // Prefix for auto-naming
*NameSpace
*ParsedLabels
// contains filtered or unexported fields
}
func NewNetworkSegment ¶ added in v0.5.0
func NewNetworkSegment() *NetworkSegment
func (NetworkSegment) AddMemberClass ¶ added in v0.5.0
func (mr NetworkSegment) AddMemberClass(mc *MemberClass)
func (NetworkSegment) AddValue ¶ added in v0.7.0
func (vr NetworkSegment) AddValue(v *Value)
AddValue adds a Value to the reference
func (*NetworkSegment) BuildRelativeNameSpace ¶ added in v0.5.0
func (seg *NetworkSegment) BuildRelativeNameSpace(globalParams map[string]map[string]string) error
func (*NetworkSegment) ChildClasses ¶ added in v0.5.0
func (seg *NetworkSegment) ChildClasses() ([]string, error)
func (*NetworkSegment) Childs ¶ added in v0.5.0
func (seg *NetworkSegment) Childs(c string) ([]NameSpacer, error)
func (*NetworkSegment) ClassDefinition ¶ added in v0.5.0
func (seg *NetworkSegment) ClassDefinition(cfg *Config, cls string) (interface{}, error)
func (*NetworkSegment) DependClasses ¶ added in v0.5.0
func (seg *NetworkSegment) DependClasses() ([]string, error)
func (*NetworkSegment) Depends ¶ added in v0.5.0
func (seg *NetworkSegment) Depends(c string) ([]NameSpacer, error)
func (*NetworkSegment) GetConfigTemplates ¶ added in v0.5.0
func (seg *NetworkSegment) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (NetworkSegment) GetMemberClasses ¶ added in v0.5.0
func (mr NetworkSegment) GetMemberClasses() []*MemberClass
func (NetworkSegment) GetMembers ¶ added in v0.5.0
func (mr NetworkSegment) GetMembers() []*Member
func (*NetworkSegment) GetPossibleConfigTemplates ¶ added in v0.5.0
func (seg *NetworkSegment) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (NetworkSegment) GetValues ¶ added in v0.7.0
func (vr NetworkSegment) GetValues() []*Value
GetValues returns all Values
func (NetworkSegment) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*NetworkSegment) SetClasses ¶ added in v0.5.1
func (seg *NetworkSegment) SetClasses(cfg *Config, nm *NetworkModel) error
func (*NetworkSegment) SetLabels ¶ added in v0.5.0
func (seg *NetworkSegment) SetLabels(cfg *Config, labels []string, moduleLabels []string) error
func (*NetworkSegment) SetSegmentLabelsFromRelationalLabels ¶ added in v0.5.0
func (seg *NetworkSegment) SetSegmentLabelsFromRelationalLabels(cfg *Config, layer *Layer) error
SetSegmentLabelsFromRelationalLabels sets segment class labels by collecting relational class labels from the segment's connections and interfaces. Unlike SetLabels, segments receive labels indirectly.
func (*NetworkSegment) SortKey ¶ added in v0.7.0
func (seg *NetworkSegment) SortKey() string
func (*NetworkSegment) String ¶ added in v0.5.1
func (seg *NetworkSegment) String() string
func (*NetworkSegment) StringForMessage ¶ added in v0.5.0
func (seg *NetworkSegment) StringForMessage() string
type Node ¶
type Node struct {
Name string
Interfaces []*Interface
Groups []*Group
*NameSpace
*ParsedLabels
NamePrefix string
// contains filtered or unexported fields
}
func (Node) AddMemberClass ¶
func (mr Node) AddMemberClass(mc *MemberClass)
func (Node) AddValue ¶ added in v0.7.0
func (vr Node) AddValue(v *Value)
AddValue adds a Value to the reference
func (Node) AwareLayer ¶
func (*Node) BuildRelativeNameSpace ¶
func (*Node) ChildClasses ¶
func (*Node) ClassDefinition ¶
func (*Node) CreateManagementInterface ¶
func (*Node) DependClasses ¶ added in v0.5.0
func (*Node) FilesToGenerate ¶ added in v0.6.0
FilesToGenerate returns a list of file names that the node will generate based on its classes. It examines NodeClass ConfigTemplates.
func (*Node) GetConfigTemplates ¶
func (n *Node) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (Node) GetLayerPolicy ¶
func (*Node) GetManagementInterface ¶
func (Node) GetMemberClasses ¶
func (mr Node) GetMemberClasses() []*MemberClass
func (Node) GetMembers ¶
func (mr Node) GetMembers() []*Member
func (*Node) GetPossibleConfigTemplates ¶
func (n *Node) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
func (Node) GetValues ¶ added in v0.7.0
func (vr Node) GetValues() []*Value
GetValues returns all Values
func (Node) GetValuesByParamRule ¶ added in v0.7.0
GetValuesByParamRule returns Values generated by the specified param_rule
func (*Node) HasAwareInterface ¶
func (*Node) NewInterface ¶
func (*Node) RenameInterface ¶
func (*Node) SetClasses ¶
func (n *Node) SetClasses(cfg *Config, nm *NetworkModel) error
func (*Node) StringForMessage ¶
type NodeClass ¶
type NodeClass struct {
// A virtual node have parameters, but no object nor configuration. It is considered only on parameter assignment.
Name string `yaml:"name" mapstructure:"name"`
Virtual bool `yaml:"virtual" mapstructure:"virtual"`
IPPolicy []string `yaml:"policy,flow" mapstructure:"policy,flow"`
Parameters []string `yaml:"params,flow" mapstructure:"params,flow"` // Parameter policies
Values map[string]string `yaml:"values" mapstructure:"values"`
InterfaceIPPolicy []string `yaml:"interface_policy,flow" mapstructure:"interface_policy,flow"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
MemberClasses []*MemberClass `yaml:"classmembers,flow" mapstructure:"classmembers,flow"`
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of auto-naming
MgmtInterface string `yaml:"mgmt_interfaceclass" mapstructure:"mgmt_interfaceclass"` // InterfaceClass name for mgmt
LabelOwnerClass
}
func (*NodeClass) GetGivenValues ¶
type ObjectClass ¶
type ObjectClass interface{}
type ObjectInstance ¶
type ObjectInstance interface {
StringForMessage() string // just for debug messages
}
type ParameterGenerator ¶ added in v0.7.0
type ParameterGenerator interface {
// GenerateValueParameters generates a list of parameter sets for creating Values
// generatorName: the generator name after the module prefix (e.g., "filemounts" for "clab.filemounts")
// target: the target object (Node, Interface, etc.)
// cfg: the configuration
// nm: the network model
// Returns: a list of parameter maps, one per Value to be created
GenerateValueParameters(
generatorName string,
target ValueOwner,
cfg *Config,
nm *NetworkModel,
) ([]map[string]string, error)
}
ParameterGenerator is optionally implemented by modules that can generate Value parameter lists for attach mode param_rules with generator specification (e.g., "clab.filemounts")
type ParameterRule ¶
type ParameterRule struct {
Name string `yaml:"name" mapstructure:"name"`
// Mode: "distribute" (default) or "attach"
// distribute: N objects get 1 parameter each (legacy behavior)
// attach: 1 object gets N Values attached
Mode string `yaml:"mode" mapstructure:"mode"`
// object (in default) or segment
Assign string `yaml:"assign" mapstructure:"assign"`
// layer is used only when the assign option is "segment"
Layer string `yaml:"layer" mapstructure:"layer"`
// integer (in default) or file
Type string `yaml:"type" mapstructure:"type"`
// for type integer
Max int `yaml:"max" mapstructure:"max"`
Min int `yaml:"min" mapstructure:"min"`
Header string `yaml:"header" mapstructure:"header"`
// for type file
SourceFile string `yaml:"sourcefile" mapstructure:"soucefile"`
// === attach mode fields ===
// Source defines how to generate Value list (for attach mode)
Source *ParameterRuleSource `yaml:"source" mapstructure:"source"`
// Generator specifies a module-provided generator (e.g., "clab.bindmounts")
Generator string `yaml:"generator" mapstructure:"generator"`
// ParamFormat defines how to format source values into Value parameters
ParamFormat map[string]string `yaml:"param_format" mapstructure:"param_format"`
// ConfigTemplates defines config blocks for Values
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
// Sort specifies ordering: "asc", "desc", or empty (preserve generation order)
Sort string `yaml:"sort" mapstructure:"sort"`
}
func (*ParameterRule) GetMode ¶ added in v0.7.0
func (pr *ParameterRule) GetMode() string
GetMode returns the mode, defaulting to "distribute" if not specified
func (*ParameterRule) IsAttachMode ¶ added in v0.7.0
func (pr *ParameterRule) IsAttachMode() bool
IsAttachMode returns true if this rule uses attach mode
type ParameterRuleSource ¶ added in v0.7.0
type ParameterRuleSource struct {
// Type specifies the source type: range, sequence, list, file
Type string `yaml:"type" mapstructure:"type"`
// Start is used for range type
Start int `yaml:"start" mapstructure:"start"`
// End is used for range type
End int `yaml:"end" mapstructure:"end"`
// Values is used for list type (inline values)
Values []map[string]interface{} `yaml:"values" mapstructure:"values"`
// File is used for file type
File string `yaml:"file" mapstructure:"file"`
// Format specifies the file format: yaml, json, csv, text (default: auto-detect from extension)
Format string `yaml:"format" mapstructure:"format"`
}
ParameterRuleSource defines the source for generating Value lists
type ParsedLabels ¶
type ParsedLabels struct {
Classes []ObjectClass
// contains filtered or unexported fields
}
func (*ParsedLabels) AddClassLabels ¶ added in v0.5.0
func (l *ParsedLabels) AddClassLabels(labels ...string)
func (*ParsedLabels) ClassLabels ¶
func (l *ParsedLabels) ClassLabels() []string
func (*ParsedLabels) GetClasses ¶
func (l *ParsedLabels) GetClasses() []ObjectClass
func (*ParsedLabels) HasClass ¶
func (l *ParsedLabels) HasClass(name string) bool
func (*ParsedLabels) IsVirtual ¶
func (l *ParsedLabels) IsVirtual() bool
func (*ParsedLabels) MetaValueLabels ¶
func (l *ParsedLabels) MetaValueLabels() map[string]string
func (*ParsedLabels) PlaceLabels ¶
func (l *ParsedLabels) PlaceLabels() []string
func (*ParsedLabels) RelationalClassLabels ¶ added in v0.5.0
func (l *ParsedLabels) RelationalClassLabels() []RelationalClassLabel
func (*ParsedLabels) SetVirtual ¶
func (l *ParsedLabels) SetVirtual(flag bool)
func (*ParsedLabels) ValueLabels ¶
func (l *ParsedLabels) ValueLabels() map[string]string
type RelationalClassLabel ¶ added in v0.5.0
type SegmentClass ¶ added in v0.5.0
type SegmentClass struct {
Name string `yaml:"name" mapstructure:"name"`
Layer string `yaml:"layer" mapstructure:"layer"`
Parameters []string `yaml:"params,flow" mapstructure:"params,flow"` // Parameter policies
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of segment auto-naming
}
type StandardModule ¶
type StandardModule struct {
NodeClassLabels []string
InterfaceClassLabels []string
ConnectionClassLabels []string
}
func NewStandardModule ¶
func NewStandardModule() *StandardModule
func (*StandardModule) AddModuleConnectionClassLabel ¶
func (m *StandardModule) AddModuleConnectionClassLabel(label string)
func (*StandardModule) AddModuleInterfaceClassLabel ¶
func (m *StandardModule) AddModuleInterfaceClassLabel(label string)
func (*StandardModule) AddModuleNodeClassLabel ¶
func (m *StandardModule) AddModuleNodeClassLabel(label string)
func (*StandardModule) GetModuleConnectionClassLabels ¶
func (m *StandardModule) GetModuleConnectionClassLabels() []string
func (*StandardModule) GetModuleInterfaceClassLabels ¶
func (m *StandardModule) GetModuleInterfaceClassLabels() []string
func (*StandardModule) GetModuleNodeClassLabels ¶
func (m *StandardModule) GetModuleNodeClassLabels() []string
type Value ¶ added in v0.7.0
type Value struct {
// ParamRuleName is the name of the param_rule that generated this Value
ParamRuleName string
// Owner is the parent object that owns this Value
Owner ValueOwner
// Index is the position in the Value list (0, 1, 2, ...)
Index int
*NameSpace
}
Value represents a virtual object that holds a set of related parameters. Unlike Node, Interface, etc., Value has no corresponding object in the DOT file. Values are dynamically generated by param_rule with mode: attach.
func NewValue ¶ added in v0.7.0
func NewValue(paramRuleName string, owner ValueOwner, index int) *Value
NewValue creates a new Value with the given parameters
func (*Value) BuildRelativeNameSpace ¶ added in v0.7.0
BuildRelativeNameSpace builds the relative namespace for template rendering
func (*Value) ChildClasses ¶ added in v0.7.0
ChildClasses returns an empty list (Value is a leaf object)
func (*Value) Childs ¶ added in v0.7.0
func (v *Value) Childs(c string) ([]NameSpacer, error)
Childs returns nil (Value has no children)
func (*Value) DependClasses ¶ added in v0.7.0
DependClasses returns an empty list (Value has no dependencies)
func (*Value) Depends ¶ added in v0.7.0
func (v *Value) Depends(c string) ([]NameSpacer, error)
Depends returns nil (Value has no dependencies)
func (*Value) GetConfigTemplates ¶ added in v0.7.0
func (v *Value) GetConfigTemplates(cfg *Config) []*ConfigTemplate
GetConfigTemplates returns config templates from the param_rule that generated this Value
func (*Value) GetPossibleConfigTemplates ¶ added in v0.7.0
func (v *Value) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
GetPossibleConfigTemplates returns the same as GetConfigTemplates for Value
func (*Value) StringForMessage ¶ added in v0.7.0
StringForMessage returns a string representation for debug messages
type ValueOwner ¶ added in v0.7.0
type ValueOwner interface {
NameSpacer
// SortKey returns a string key for deterministic sorting of objects.
// Used to ensure stable parameter assignment order regardless of map iteration order.
SortKey() string
// AddValue adds a Value to this owner
AddValue(v *Value)
// GetValues returns all Values attached to this owner
GetValues() []*Value
// GetValuesByParamRule returns Values generated by the specified param_rule
GetValuesByParamRule(paramRuleName string) []*Value
}
ValueOwner is an interface for objects that can have Values attached. Values are virtual objects generated by param_rule with mode: attach. Implemented by: NetworkModel, Node, Interface, Connection, Group, NetworkSegment