types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ChildGroupsConfigHeader string = "groups" + NumberSeparator
View Source
const ChildInterfacesConfigHeader string = "interfaces" + NumberSeparator
View Source
const ChildMembersConfigHeader string = "members" + NumberSeparator
View Source
const ChildNeighborsConfigHeader string = "neighbors" + NumberSeparator
View Source
const ChildNodesConfigHeader string = "nodes" + NumberSeparator
View Source
const ClassAll string = "all" // all objects
View Source
const ClassDefault string = "default" // all empty objects
View Source
const ClassTypeConnection string = "connection"
View Source
const ClassTypeGroup string = "group"
View Source
const ClassTypeInterface string = "interface"
View Source
const ClassTypeMemberClassNameAny = "any"
View Source
const ClassTypeMemberHeader string = "member"
View Source
const ClassTypeNeighborHeader string = "neighbor"
View Source
const ClassTypeNeighborLayerAny = "any"
View Source
const ClassTypeNetwork string = "network"
View Source
const ClassTypeNode string = "node"
View Source
const ClassTypeSegment string = "segment"
View Source
const ConfigTemplateStyleHierarchy string = "hierarchy" // ConfigTemplate.Style
View Source
const ConfigTemplateStyleSort string = "sort"
View Source
const DefaultConnectionPrefix string = "conn"
View Source
const DefaultInterfacePrefix string = "net"
View Source
const DefaultNodePrefix string = "node"
View Source
const IPAddressReplacerFooter string = "addr"
View Source
const IPLoopbackReplacerFooter string = "loopback"

IP number replacer: [IPSpace]_[IPReplacerXX] const IPLoopbackReplacerFooter string = "loopback"

View Source
const IPNetworkReplacerFooter string = "net"
View Source
const IPPolicyTypeDefault string = "ip"
View Source
const IPPolicyTypeLoopback string = "loopback"
View Source
const IPPrefixLengthReplacerFooter string = "plen"
View Source
const IPProtocolReplacerFooter string = "protocol"
View Source
const MountSourcePathAbs string = "abs" // absolute path
View Source
const MountSourcePathLocal string = "local"
View Source
const NumberPrefixGroup string = "group" + NumberSeparator
View Source
const NumberPrefixMember string = "m" + NumberSeparator
View Source
const NumberPrefixNeighbor string = "n" + NumberSeparator
View Source
const NumberPrefixNode string = "node" + NumberSeparator
View Source
const NumberPrefixOppositeHeader string = "opp" + NumberSeparator
View Source
const NumberPrefixOppositeInterface string = "opp" + NumberSeparator
View Source
const NumberSeparator string = "_"

namespace related constants

View Source
const OutputAsis string = "command"
View Source
const OutputClab string = "clab"
View Source
const OutputTinet string = "tinet"
View Source
const PathSpecificationDefault string = "default" // search files from working directory
View Source
const PathSpecificationLocal string = "local" // search files from the directory with config file
View Source
const PlaceLabelPrefix string = "@"
View Source
const RelationalClassLabelSeparator string = "#"
View Source
const SelfConfigHeader string = "self" + NumberSeparator
View Source
const ValueLabelSeparator string = "="

Variables

This section is empty.

Functions

func AllOutput

func AllOutput() []string

func ClassTypeMember

func ClassTypeMember(classType string, className string) string

func ClassTypeNeighbor

func ClassTypeNeighbor(layer string) string

func GetRelativeFilePath

func GetRelativeFilePath(path string, cfg *Config) string

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"`
	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 LoadConfig(path string) (*Config, error)

func LoadTemplates

func LoadTemplates(cfg *Config) (*Config, error)

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 (cfg *Config) AddNodeClass(nc *NodeClass)

func (*Config) ConnectionClassByName

func (cfg *Config) ConnectionClassByName(name string) (*ConnectionClass, bool)

func (*Config) DefaultConnectionLayer

func (cfg *Config) DefaultConnectionLayer() []string

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) 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 (cfg *Config) HasManagementLayer() bool

func (*Config) InterfaceClassByName

func (cfg *Config) InterfaceClassByName(name string) (*InterfaceClass, bool)

func (*Config) LayerByName

func (cfg *Config) LayerByName(name string) (*Layer, bool)

func (*Config) MountSourcePath

func (cfg *Config) MountSourcePath(path string) (string, error)

func (*Config) NeighborClassesByName

func (cfg *Config) NeighborClassesByName(iface string, ipspace string) ([]*NeighborClass, bool)

func (*Config) NodeClassByName

func (cfg *Config) NodeClassByName(name string) (*NodeClass, 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"`

	// 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

type Connection struct {
	Name   string
	Src    *Interface
	Dst    *Interface
	Layers mapset.Set[string]

	*ParsedLabels
	*NameSpace
	// contains filtered or unexported fields
}

func (Connection) AddMember added in v0.5.0

func (mr Connection) AddMember(m *Member)

func (Connection) AddMemberClass added in v0.5.0

func (mr Connection) AddMemberClass(mc *MemberClass)

func (Connection) AwareLayer added in v0.5.0

func (a Connection) AwareLayer(layer string) bool

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 (a Connection) GetLayerPolicy(layer string) *IPPolicy

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) 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"`
	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.
	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.
	// 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"`
}

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"`
}

type Group

type Group struct {
	Name  string
	Nodes []*Node

	*NameSpace
	*ParsedLabels
}

func (*Group) BuildRelativeNameSpace

func (g *Group) BuildRelativeNameSpace(globalParams map[string]map[string]string) error

func (*Group) ChildClasses

func (g *Group) ChildClasses() ([]string, error)

func (*Group) Childs

func (g *Group) Childs(c string) ([]NameSpacer, error)

func (*Group) ClassDefinition

func (g *Group) ClassDefinition(cfg *Config, cls string) (interface{}, error)

func (*Group) DependClasses added in v0.5.0

func (g *Group) DependClasses() ([]string, error)

func (*Group) Depends added in v0.5.0

func (g *Group) Depends(c string) ([]NameSpacer, error)

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) SetLabels

func (g *Group) SetLabels(cfg *Config, labels []string, moduleLabels []string) error

func (*Group) StringForMessage

func (g *Group) StringForMessage() string

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) AddMember

func (mr Interface) AddMember(m *Member)

func (Interface) AddMemberClass

func (mr Interface) AddMemberClass(mc *MemberClass)

func (*Interface) AddNeighbor

func (iface *Interface) AddNeighbor(neighbor *Interface, layer string)

add Neighbor object only when the Interface has NeighborClasses of corresponding layer

func (Interface) AwareLayer

func (a Interface) AwareLayer(layer string) bool

func (*Interface) BuildRelativeNameSpace

func (iface *Interface) BuildRelativeNameSpace(globalParams map[string]map[string]string) error

func (*Interface) ChildClasses

func (iface *Interface) ChildClasses() ([]string, error)

func (*Interface) Childs

func (iface *Interface) Childs(c string) ([]NameSpacer, error)

func (*Interface) ClassDefinition

func (iface *Interface) ClassDefinition(cfg *Config, cls string) (interface{}, error)

func (*Interface) DependClasses added in v0.5.0

func (iface *Interface) DependClasses() ([]string, error)

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 (a Interface) GetLayerPolicy(layer string) *IPPolicy

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 (iface *Interface) GivenIPAddress(layer Layerer) (string, bool)

func (*Interface) SetClasses

func (iface *Interface) SetClasses(cfg *Config, nm *NetworkModel) error

func (*Interface) SetLabels

func (iface *Interface) SetLabels(cfg *Config, labels []string, moduleLabels []string) error

func (*Interface) String

func (iface *Interface) String() string

func (*Interface) StringForMessage

func (iface *Interface) StringForMessage() string

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 LabelOwnerClass interface {
	GetGivenValues() map[string]string
}

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 *Layer) IPAddressReplacer() string

func (*Layer) IPLoopbackReplacer

func (layer *Layer) IPLoopbackReplacer() string

func (*Layer) IPNetworkReplacer

func (layer *Layer) IPNetworkReplacer() string

func (*Layer) IPPrefixLengthReplacer

func (layer *Layer) IPPrefixLengthReplacer() string

func (*Layer) IPProtocolReplacer

func (layer *Layer) IPProtocolReplacer() string

type Layerer

type Layerer interface {
	IPAddressReplacer() string
	IPNetworkReplacer() string
	IPPrefixLengthReplacer() string
}

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 (m *Member) BuildRelativeNameSpace(globalParams map[string]map[string]string) error

func (*Member) ChildClasses

func (m *Member) ChildClasses() ([]string, error)

func (*Member) Childs

func (m *Member) Childs(c string) ([]NameSpacer, error)

func (*Member) DependClasses added in v0.5.0

func (m *Member) DependClasses() ([]string, error)

func (*Member) Depends added in v0.5.0

func (m *Member) Depends(c string) ([]NameSpacer, error)

func (*Member) GetConfigTemplates

func (m *Member) GetConfigTemplates(cfg *Config) []*ConfigTemplate

func (*Member) GetPossibleConfigTemplates

func (m *Member) GetPossibleConfigTemplates(cfg *Config) []*ConfigTemplate

func (*Member) StringForMessage

func (m *Member) StringForMessage() string

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) AddParam

func (ns *NameSpace) AddParam(k, v string)

func (*NameSpace) GetParamValue

func (ns *NameSpace) GetParamValue(key string) (string, error)

GetParamValue returns a parameter value from relative namespace

func (*NameSpace) GetParams

func (ns *NameSpace) GetParams() map[string]string

func (*NameSpace) GetRelativeParams

func (ns *NameSpace) GetRelativeParams() map[string]string

func (*NameSpace) HasParam

func (ns *NameSpace) HasParam(k string) bool

func (*NameSpace) HasRelativeParam

func (ns *NameSpace) HasRelativeParam(k string) bool

func (*NameSpace) IterateFlaggedParams

func (ns *NameSpace) IterateFlaggedParams() <-chan string

func (*NameSpace) SetRelativeParam

func (ns *NameSpace) SetRelativeParam(k, v string)

func (*NameSpace) SetRelativeParams

func (ns *NameSpace) SetRelativeParams(given map[string]string)

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 (n *Neighbor) BuildRelativeNameSpace(globalParams map[string]map[string]string) error

func (*Neighbor) ChildClasses

func (n *Neighbor) ChildClasses() ([]string, error)

func (*Neighbor) Childs

func (n *Neighbor) Childs(c string) ([]NameSpacer, error)

func (*Neighbor) DependClasses added in v0.5.0

func (n *Neighbor) DependClasses() ([]string, error)

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

func (n *Neighbor) StringForMessage() string

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) 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) 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) SegmentClassMembers added in v0.5.0

func (nm *NetworkModel) SegmentClassMembers(cls string) []NameSpacer

func (*NetworkModel) StringForMessage

func (nm *NetworkModel) StringForMessage() string

type NetworkSegment added in v0.5.0

type NetworkSegment struct {
	Layer       string
	Interfaces  []*Interface
	Connections []*Connection

	*NameSpace
	*ParsedLabels
	// contains filtered or unexported fields
}

func NewNetworkSegment added in v0.5.0

func NewNetworkSegment() *NetworkSegment

func (NetworkSegment) AddMember added in v0.5.0

func (mr NetworkSegment) AddMember(m *Member)

func (NetworkSegment) AddMemberClass added in v0.5.0

func (mr NetworkSegment) AddMemberClass(mc *MemberClass)

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) 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) 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) AddMember

func (mr Node) AddMember(m *Member)

func (Node) AddMemberClass

func (mr Node) AddMemberClass(mc *MemberClass)

func (Node) AwareLayer

func (a Node) AwareLayer(layer string) bool

func (*Node) BuildRelativeNameSpace

func (n *Node) BuildRelativeNameSpace(globalParams map[string]map[string]string) error

func (*Node) ChildClasses

func (n *Node) ChildClasses() ([]string, error)

func (*Node) Childs

func (n *Node) Childs(c string) ([]NameSpacer, error)

func (*Node) ClassDefinition

func (n *Node) ClassDefinition(cfg *Config, cls string) (interface{}, error)

func (*Node) CreateManagementInterface

func (n *Node) CreateManagementInterface(cfg *Config, name string) (*Interface, error)

func (*Node) DependClasses added in v0.5.0

func (n *Node) DependClasses() ([]string, error)

func (*Node) Depends added in v0.5.0

func (n *Node) Depends(c string) ([]NameSpacer, error)

func (*Node) GetConfigTemplates

func (n *Node) GetConfigTemplates(cfg *Config) []*ConfigTemplate

func (Node) GetLayerPolicy

func (a Node) GetLayerPolicy(layer string) *IPPolicy

func (*Node) GetManagementInterface

func (n *Node) GetManagementInterface() *Interface

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) GivenIPLoopback

func (n *Node) GivenIPLoopback(layer *Layer) (string, bool)

func (*Node) HasAwareInterface

func (n *Node) HasAwareInterface(layer string) bool

func (*Node) InterfaceByName

func (n *Node) InterfaceByName(name string) (*Interface, bool)

func (*Node) NewInterface

func (n *Node) NewInterface(name string) *Interface

func (*Node) RenameInterface

func (n *Node) RenameInterface(iface *Interface, oldName string, newName string)

func (*Node) SetClasses

func (n *Node) SetClasses(cfg *Config, nm *NetworkModel) error

func (*Node) SetLabels

func (n *Node) SetLabels(cfg *Config, labels []string, moduleLabels []string) error

func (*Node) String

func (n *Node) String() string

func (*Node) StringForMessage

func (n *Node) StringForMessage() string

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

func (nc *NodeClass) GetGivenValues() map[string]string

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"`
	Footer string `yaml:"footer" mapstructure:"footer"`
	// for type file
	SourceFile string `yaml:"sourcefile" mapstructure:"soucefile"`
}

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 RelationalClassLabel struct {
	ClassType string
	Name      string
}

type SegmentClass added in v0.5.0

type SegmentClass struct {
	Name            string            `yaml:"name" mapstructure:"name"`
	Layer           string            `yaml:"layer" mapstructure:"layer"`
	ConfigTemplates []*ConfigTemplate `yaml:"config,flow" mapstructure:"config,flow"`
}

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

Jump to

Keyboard shortcuts

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