Documentation
¶
Index ¶
- Constants
- func AllOutput() []string
- func ClassTypeMember(classType string, className string) string
- func ClassTypeNeighbor(layer string) string
- func GetRelativeFilePath(path string, cfg *Config) string
- func InitGloballNameSpace(nm *NetworkModel) (map[string]map[string]string, error)
- type Config
- func (cfg *Config) AddConnectionClass(nc *ConnectionClass)
- func (cfg *Config) AddFileDefinition(filedef *FileDefinition)
- func (cfg *Config) AddFileFormat(filefmt *FileFormat)
- func (cfg *Config) AddInterfaceClass(nc *InterfaceClass)
- func (cfg *Config) AddNetworkClass(nc *NetworkClass)
- func (cfg *Config) AddNodeClass(nc *NodeClass)
- func (cfg *Config) ConnectionClassByName(name string) (*ConnectionClass, bool)
- func (cfg *Config) DefaultConnectionLayer() []string
- func (cfg *Config) FileDefinitionByName(name string) (*FileDefinition, bool)
- func (cfg *Config) FileFormatByName(name string) (*FileFormat, 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) 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)
- type ConfigTemplate
- type Connection
- 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) 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) String() string
- func (conn *Connection) StringForMessage() string
- type ConnectionClass
- type FileDefinition
- type FileFormat
- type GlobalSettings
- type Group
- 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) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (g *Group) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- 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) 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 (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) 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 (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) 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) 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) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (n *Neighbor) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- func (n *Neighbor) StringForMessage() string
- type NeighborClass
- type NetworkClass
- type NetworkModel
- 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) GetConfigTemplates(cfg *Config) []*ConfigTemplate
- func (nm *NetworkModel) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
- 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) StringForMessage() string
- type Node
- func (mr Node) AddMember(m *Member)
- func (mr Node) AddMemberClass(mc *MemberClass)
- 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) 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 (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) String() string
- func (n *Node) StringForMessage() string
- type NodeClass
- type ObjectClass
- type ObjectInstance
- type ParameterRule
- type ParsedLabels
- 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) SetVirtual(flag bool)
- func (l *ParsedLabels) ValueLabels() map[string]string
- type SegmentMembers
- 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
Constants ¶
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 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 ConfigTemplateStyleHierarchy string = "hierarchy" // ConfigTemplate.Style
const ConfigTemplateStyleSort string = "sort"
const DefaultInterfacePrefix string = "net"
const DefaultNodePrefix string = "node"
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 NumberPrefixGroup string = "group" + NumberSeparator
const NumberPrefixMember string = "m" + NumberSeparator
const NumberPrefixNeighbor string = "n" + NumberSeparator
const NumberPrefixNode string = "node" + NumberSeparator
const NumberPrefixOppositeHeader string = "opp" + 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 SelfConfigHeader string = "self" + NumberSeparator
const ValueLabelSeparator string = "="
Variables ¶
This section is empty.
Functions ¶
func ClassTypeMember ¶
func ClassTypeNeighbor ¶
func GetRelativeFilePath ¶
func InitGloballNameSpace ¶
func InitGloballNameSpace(nm *NetworkModel) (map[string]map[string]string, error)
Types ¶
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"`
FileFormats []*FileFormat `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"`
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) AddFileFormat ¶
func (cfg *Config) AddFileFormat(filefmt *FileFormat)
func (*Config) AddInterfaceClass ¶
func (cfg *Config) AddInterfaceClass(nc *InterfaceClass)
func (*Config) AddNetworkClass ¶
func (cfg *Config) AddNetworkClass(nc *NetworkClass)
func (*Config) AddNodeClass ¶
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) FileFormatByName ¶
func (cfg *Config) FileFormatByName(name string) (*FileFormat, 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) 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)
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"`
// 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"`
// 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) GetClassInfo ¶
func (ct *ConfigTemplate) GetClassInfo() (string, string)
func (*ConfigTemplate) GetFormats ¶
func (ct *ConfigTemplate) GetFormats() []string
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 ¶
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) 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) 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"`
Primary bool `yaml:"primary" mapstructure:"primary"`
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"`
NeighborClasses []*NeighborClass `yaml:"neighbors,flow" mapstructure:"neighbors,flow"`
// Following attributes are valid only on primary interface classes.
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of interface auto-naming
TinetAttr map[string]interface{} `yaml:"tinet" mapstructure:"tinet"` // tinet attributes
ClabAttr map[string]interface{} `yaml:"clab" mapstructure:"clab"` // containerlab attributes
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.
Name string `yaml:"name" mapstructure:"name"`
// 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.
// For example, if Scope = "node", the file is created for each node.
Scope string `yaml:"scope" mapstructure:"scope"`
}
func (*FileDefinition) GetFormats ¶
func (fd *FileDefinition) GetFormats() []string
type FileFormat ¶
type FileFormat struct {
Name string `yaml:"name" mapstructure:"name"`
LinePrefix string `yaml:"lineprefix" mapstructure:"lineprefix"`
LineSuffix string `yaml:"linesuffix" mapstructure:"linesuffix"`
LineSeparator string `yaml:"lineseparator" mapstructure:"lineseparator"`
BlockPrefix string `yaml:"blockprefix" mapstructure:"blockprefix"`
BlockSuffix string `yaml:"blocksuffix" mapstructure:"blocksuffix"`
BlockSeparator string `yaml:"blockseparator" mapstructure:"blockseparator"`
}
type GlobalSettings ¶
type GlobalSettings struct {
PathSpecification string `yaml:"path" mapstructure:"path"`
MountSourcePath string `yaml:"mountsourcepath" mapstructure:"mountsourcepath"`
NodeAutoRename bool `yaml:"nodeautoname" mapstructure:"nodeautoname"`
// ASNumberMin and ASNumberMAX are optional, considered in AssignASNumbers if specified
ASNumberMin int `yaml:"asnumber_min" mapstructure:"asnumber_min"`
ASNumberMax int `yaml:"asnumber_max" mapstructure:"asnumber_max"`
ClabAttr map[string]interface{} `yaml:"clab" mapstructure:"clab"` // containerlab attributes
}
type Group ¶
type Group struct {
Name string
Nodes []*Node
*NameSpace
*ParsedLabels
}
func (*Group) BuildRelativeNameSpace ¶
func (*Group) ChildClasses ¶
func (*Group) ClassDefinition ¶
func (*Group) GetConfigTemplates ¶
func (g *Group) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*Group) GetPossibleConfigTemplates ¶
func (g *Group) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
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
TinetAttr *map[string]interface{}
// ClabAttr *map[string]interface{}
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) AwareLayer ¶
func (*Interface) BuildRelativeNameSpace ¶
func (*Interface) ChildClasses ¶
func (*Interface) ClassDefinition ¶
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) GivenIPAddress ¶
func (*Interface) SetClasses ¶
func (iface *Interface) SetClasses(cfg *Config, nm *NetworkModel) error
func (*Interface) StringForMessage ¶
type InterfaceClass ¶
type InterfaceClass struct {
// An interface can have only one of "primary" interface class or "primary" connection class.
Name string `yaml:"name" mapstructure:"name"`
Primary bool `yaml:"primary" mapstructure:"primary"`
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"`
ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
NeighborClasses []*NeighborClass `yaml:"neighbors,flow" mapstructure:"neighbors,flow"`
MemberClasses []*MemberClass `yaml:"classmembers,flow" mapstructure:"classmembers,flow"`
// Following attributes are valid only on primary interface classes.
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of auto-naming
TinetAttr map[string]interface{} `yaml:"tinet" mapstructure:"tinet"` // tinet attributes
ClabAttr map[string]interface{} `yaml:"clab" mapstructure:"clab"` // containerlab attributes
LabelOwnerClass
}
func (*InterfaceClass) GetGivenValues ¶
func (ic *InterfaceClass) GetGivenValues() map[string]string
type LabelOwner ¶
type LabelOwner interface {
ClassLabels() []string
PlaceLabels() []string
ValueLabels() map[string]string
MetaValueLabels() map[string]string
SetLabels(cfg *Config, labels []string, moduleLabels []string) error
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) 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)
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, 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) 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][]*SegmentMembers
// contains filtered or unexported fields
}
func NewNetworkModel ¶
func NewNetworkModel() *NetworkModel
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) GetConfigTemplates ¶
func (nm *NetworkModel) GetConfigTemplates(cfg *Config) []*ConfigTemplate
func (*NetworkModel) GetPossibleConfigTemplates ¶
func (nm *NetworkModel) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate
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) StringForMessage ¶
func (nm *NetworkModel) StringForMessage() string
type Node ¶
type Node struct {
Name string
Interfaces []*Interface
Groups []*Group
//Virtual bool
// Files *ConfigFiles
TinetAttr *map[string]interface{}
ClabAttr *map[string]interface{}
*NameSpace
*ParsedLabels
NamePrefix string
// contains filtered or unexported fields
}
func (Node) AddMemberClass ¶
func (mr Node) AddMemberClass(mc *MemberClass)
func (Node) AwareLayer ¶
func (*Node) BuildRelativeNameSpace ¶
func (*Node) ChildClasses ¶
func (*Node) ClassDefinition ¶
func (*Node) CreateManagementInterface ¶
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) 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 node can have only one "primary" node class.
// Unprimary node classes only have "name", "numbered" and "config". Other attributes are ignored.
// A virtual node have parameters, but no object nor configuration. It is considered only on parameter assignment.
Name string `yaml:"name" mapstructure:"name"`
Primary bool `yaml:"primary" mapstructure:"primary"`
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"`
// Following attributes are valid only on primary interface classes.
Prefix string `yaml:"prefix" mapstructure:"prefix"` // prefix of auto-naming
MgmtInterface string `yaml:"mgmt_interfaceclass" mapstructure:"mgmt_interfaceclass"` // InterfaceClass name for mgmt
TinetAttr map[string]interface{} `yaml:"tinet" mapstructure:"tinet"` // tinet attributes
ClabAttr map[string]interface{} `yaml:"clab" mapstructure:"clab"` // containerlab attributes
LabelOwnerClass
}
func (*NodeClass) GetGivenValues ¶
type ObjectClass ¶
type ObjectClass interface{}
type ObjectInstance ¶
type ObjectInstance interface {
StringForMessage() string // just for debug messages
}
type ParameterRule ¶
type ParameterRule struct {
Name string `yaml:"name" mapstructure:"name"`
// 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"`
}
type ParsedLabels ¶
type ParsedLabels struct {
Classes []ObjectClass
// contains filtered or unexported fields
}
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) SetVirtual ¶
func (l *ParsedLabels) SetVirtual(flag bool)
func (*ParsedLabels) ValueLabels ¶
func (l *ParsedLabels) ValueLabels() map[string]string
type SegmentMembers ¶
type SegmentMembers struct {
Interfaces []*Interface
Connections []*Connection
}
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