From 88ed50db44f202c2dd595e5ac33c64925ff635bf Mon Sep 17 00:00:00 2001 From: steiler Date: Fri, 28 Apr 2023 12:02:12 +0200 Subject: [PATCH] Store information about NodeGeneration in registry. So far generate.go contained two lists indenpendent from the nodes, that would describe nodes that (1) can be generated and (b) what the interface naming convention would be for the node kind. This will introduce seperate fields in the NodeRegistry for this information, such that the information for this sort of node generation can be defined as part of the node definition --- clab/clab.go | 2 +- clab/config/utils.go | 2 +- clab/register.go | 63 +++++++------- cmd/generate.go | 47 +++++----- nodes/bridge/bridge.go | 9 +- nodes/c8000/c8000.go | 3 +- nodes/ceos/ceos.go | 8 +- .../checkpoint_cloudguard.go | 3 +- nodes/crpd/crpd.go | 8 +- nodes/ipinfusion_ocnos/ipinfusion_ocnos.go | 8 +- nodes/linux/linux.go | 10 ++- nodes/node_registry.go | 85 +++++++++++++++++-- nodes/rare/rare.go | 10 ++- nodes/sonic/sonic.go | 10 ++- nodes/srl/srl.go | 9 +- nodes/vr_csr/vr-csr.go | 3 +- nodes/vr_ftosv/vr-ftosv.go | 3 +- nodes/vr_n9kv/vr-n9kv.go | 3 +- nodes/vr_nxos/vr-nxos.go | 3 +- nodes/vr_pan/vr-pan.go | 3 +- nodes/vr_ros/vr-ros.go | 3 +- nodes/vr_sros/vr-sros.go | 7 +- nodes/vr_veos/vr-veos.go | 8 +- nodes/vr_vmx/vr-vmx.go | 8 +- nodes/vr_vqfx/vr-vqfx.go | 7 +- nodes/vr_vsrx/vr-vsrx.go | 8 +- nodes/vr_xrv/vr-xrv.go | 3 +- nodes/vr_xrv9k/vr-xrv9k.go | 7 +- nodes/xrd/xrd.go | 8 +- 29 files changed, 263 insertions(+), 88 deletions(-) diff --git a/clab/clab.go b/clab/clab.go index c2c3fe0a8..9335254c8 100644 --- a/clab/clab.go +++ b/clab/clab.go @@ -202,7 +202,7 @@ func NewContainerLab(opts ...ClabOption) (*CLab, error) { c.Reg = nodes.NewNodeRegistry() // register all nodes - c.RegisterNodes() + RegisterNodes(c.Reg) for _, opt := range opts { err := opt(c) diff --git a/clab/config/utils.go b/clab/config/utils.go index 5972e2f0f..86123b5e8 100644 --- a/clab/config/utils.go +++ b/clab/config/utils.go @@ -64,7 +64,7 @@ func PrepareVars(c *clab.CLab) map[string]*NodeConfig { vars[vkRole] = nodeCfg.Kind } - creds := c.Reg.Kind(nodeCfg.Kind).Credentials().Slice() + creds := c.Reg.Kind(nodeCfg.Kind).GetCredentials().Slice() res[name] = &NodeConfig{ TargetNode: nodeCfg, diff --git a/clab/register.go b/clab/register.go index 7f2a07901..0a758f556 100644 --- a/clab/register.go +++ b/clab/register.go @@ -5,6 +5,7 @@ package clab import ( + "github.com/srl-labs/containerlab/nodes" border0 "github.com/srl-labs/containerlab/nodes/border0" bridge "github.com/srl-labs/containerlab/nodes/bridge" c8000 "github.com/srl-labs/containerlab/nodes/c8000" @@ -38,35 +39,35 @@ import ( ) // RegisterNodes registers all the nodes/kinds supported by containerlab. -func (c *CLab) RegisterNodes() { - bridge.Register(c.Reg) - ceos.Register(c.Reg) - checkpoint_cloudguard.Register(c.Reg) - crpd.Register(c.Reg) - cvx.Register(c.Reg) - ext_container.Register(c.Reg) - host.Register(c.Reg) - ipinfusion_ocnos.Register(c.Reg) - keysight_ixiacone.Register(c.Reg) - linux.Register(c.Reg) - ovs.Register(c.Reg) - sonic.Register(c.Reg) - srl.Register(c.Reg) - vr_csr.Register(c.Reg) - vr_ftosv.Register(c.Reg) - vr_n9kv.Register(c.Reg) - vr_nxos.Register(c.Reg) - vr_pan.Register(c.Reg) - vr_ros.Register(c.Reg) - vr_sros.Register(c.Reg) - vr_veos.Register(c.Reg) - vr_vmx.Register(c.Reg) - vr_vsrx.Register(c.Reg) - vr_vqfx.Register(c.Reg) - vr_xrv.Register(c.Reg) - vr_xrv9k.Register(c.Reg) - xrd.Register(c.Reg) - rare.Register(c.Reg) - c8000.Register(c.Reg) - border0.Register(c.Reg) +func RegisterNodes(r *nodes.NodeRegistry) { + bridge.Register(r) + ceos.Register(r) + checkpoint_cloudguard.Register(r) + crpd.Register(r) + cvx.Register(r) + ext_container.Register(r) + host.Register(r) + ipinfusion_ocnos.Register(r) + keysight_ixiacone.Register(r) + linux.Register(r) + ovs.Register(r) + sonic.Register(r) + srl.Register(r) + vr_csr.Register(r) + vr_ftosv.Register(r) + vr_n9kv.Register(r) + vr_nxos.Register(r) + vr_pan.Register(r) + vr_ros.Register(r) + vr_sros.Register(r) + vr_veos.Register(r) + vr_vmx.Register(r) + vr_vsrx.Register(r) + vr_vqfx.Register(r) + vr_xrv.Register(r) + vr_xrv9k.Register(r) + xrd.Register(r) + rare.Register(r) + c8000.Register(r) + border0.Register(r) } diff --git a/cmd/generate.go b/cmd/generate.go index f90d57ce1..13bfde1b9 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -15,34 +15,12 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/srl-labs/containerlab/clab" + "github.com/srl-labs/containerlab/nodes" "github.com/srl-labs/containerlab/types" "gopkg.in/yaml.v2" ) -var interfaceFormat = map[string]string{ - "srl": "e1-%d", - "ceos": "eth%d", - "crpd": "eth%d", - "sonic-vs": "eth%d", - "linux": "eth%d", - "bridge": "veth%d", - "vr-sros": "eth%d", - "vr-vmx": "eth%d", - "vr-vsrx": "eth%d", - "vr-vqfx": "eth%d", - "vr-xrv9k": "eth%d", - "vr-veos": "eth%d", - "xrd": "eth%d", - "rare": "eth%d", -} - -var supportedKinds = []string{ - "srl", "ceos", "linux", "bridge", "sonic-vs", "crpd", "vr-sros", - "vr-vmx", "vr-vsrx", "vr-vqfx", "vr-xrv9k", "vr-veos", "xrd", "rare", -} - const ( - defaultSRLType = "ixrd2" defaultNodePrefix = "node" defaultGroupPrefix = "tier" ) @@ -61,6 +39,7 @@ var ( groupPrefix string file string deploy bool + reg *nodes.NodeRegistry ) type nodesDef struct { @@ -128,6 +107,21 @@ var generateCmd = &cobra.Command{ } func init() { + // init a new NodeRegistry + reg = nodes.NewNodeRegistry() + // register all nodes + clab.RegisterNodes(reg) + + generateNodesAttributes := reg.GetGenerateNodeAttributes() + supportedKinds := []string{} + + // prepare list of generateable node kinds + for k, v := range generateNodesAttributes { + if v.IsGenerateable() { + supportedKinds = append(supportedKinds, k) + } + } + rootCmd.AddCommand(generateCmd) generateCmd.Flags().StringVarP(&mgmtNetName, "network", "", "", "management network name") generateCmd.Flags().IPNetVarP(&mgmtIPv4Subnet, "ipv4-subnet", "4", net.IPNet{}, "management network IPv4 subnet range") @@ -191,6 +185,9 @@ func generateTopologyConfig(name, network, ipv4range, ipv6range string, } } } + + generateNodesAttributes := reg.GetGenerateNodeAttributes() + for i := 0; i < numStages-1; i++ { interfaceOffset := uint(0) if i > 0 { @@ -216,8 +213,8 @@ func generateTopologyConfig(name, network, ipv4range, ipv6range string, } config.Topology.Links = append(config.Topology.Links, &types.LinkConfig{ Endpoints: []string{ - node1 + ":" + fmt.Sprintf(interfaceFormat[nodes[i].kind], k+1+interfaceOffset), - node2 + ":" + fmt.Sprintf(interfaceFormat[nodes[i+1].kind], j+1), + node1 + ":" + fmt.Sprintf(generateNodesAttributes[nodes[i].kind].GetInterfaceFormat(), k+1+interfaceOffset), + node2 + ":" + fmt.Sprintf(generateNodesAttributes[nodes[i+1].kind].GetInterfaceFormat(), j+1), }, }) } diff --git a/nodes/bridge/bridge.go b/nodes/bridge/bridge.go index a517916dd..19fa5289d 100644 --- a/nodes/bridge/bridge.go +++ b/nodes/bridge/bridge.go @@ -24,13 +24,20 @@ var kindnames = []string{"bridge"} const ( iptCheckCmd = "-vL FORWARD -w 5" iptAllowCmd = "-I FORWARD -i %s -j ACCEPT -w 5" + + generateable = true + generateIfFornamt = "eth%d" ) // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(nil, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(bridge) - }, nil) + }, nrea) } type bridge struct { diff --git a/nodes/c8000/c8000.go b/nodes/c8000/c8000.go index 2cf91a68b..ac5149230 100644 --- a/nodes/c8000/c8000.go +++ b/nodes/c8000/c8000.go @@ -33,9 +33,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(c8000) - }, defaultCredentials) + }, nrea) } type c8000 struct { diff --git a/nodes/ceos/ceos.go b/nodes/ceos/ceos.go index 8d932ad0c..d3b0ec319 100644 --- a/nodes/ceos/ceos.go +++ b/nodes/ceos/ceos.go @@ -26,6 +26,8 @@ import ( const ( ifWaitScriptContainerPath = "/mnt/flash/if-wait.sh" + generateable = true + generateIfFornamt = "eth%d" ) var ( @@ -50,9 +52,13 @@ var ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(nil, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(ceos) - }, nil) + }, nrea) } type ceos struct { diff --git a/nodes/checkpoint_cloudguard/checkpoint_cloudguard.go b/nodes/checkpoint_cloudguard/checkpoint_cloudguard.go index 2a140bef4..ca0aff59c 100644 --- a/nodes/checkpoint_cloudguard/checkpoint_cloudguard.go +++ b/nodes/checkpoint_cloudguard/checkpoint_cloudguard.go @@ -20,9 +20,10 @@ var ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(CheckpointCloudguard) - }, defaultCredentials) + }, nrea) } type CheckpointCloudguard struct { diff --git a/nodes/crpd/crpd.go b/nodes/crpd/crpd.go index 347c55f33..2d611ce8d 100644 --- a/nodes/crpd/crpd.go +++ b/nodes/crpd/crpd.go @@ -20,6 +20,9 @@ import ( const ( licDir = "/config/license/safenet" + + generateable = true + generateIfFornamt = "eth%d" ) var ( @@ -38,9 +41,12 @@ var ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(crpd) - }, defaultCredentials) + }, nrea) } type crpd struct { diff --git a/nodes/ipinfusion_ocnos/ipinfusion_ocnos.go b/nodes/ipinfusion_ocnos/ipinfusion_ocnos.go index 9d7e7b52d..1a00de108 100644 --- a/nodes/ipinfusion_ocnos/ipinfusion_ocnos.go +++ b/nodes/ipinfusion_ocnos/ipinfusion_ocnos.go @@ -22,13 +22,19 @@ var ( const ( scrapliPlatformName = "ipinfusion_ocnos" + generateable = false + generateIfFornamt = "" ) // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(IPInfusionOcNOS) - }, defaultCredentials) + }, nrea) } type IPInfusionOcNOS struct { diff --git a/nodes/linux/linux.go b/nodes/linux/linux.go index 2d1697d61..899de33e7 100644 --- a/nodes/linux/linux.go +++ b/nodes/linux/linux.go @@ -14,13 +14,21 @@ import ( "github.com/weaveworks/ignite/pkg/operations" ) +const ( + generateable = true + generateIfFornamt = "eth%d" +) + var kindnames = []string{"linux"} // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(nil, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(linux) - }, nil) + }, nrea) } type linux struct { diff --git a/nodes/node_registry.go b/nodes/node_registry.go index 0f2359028..3bc5f26c1 100644 --- a/nodes/node_registry.go +++ b/nodes/node_registry.go @@ -21,8 +21,8 @@ func NewNodeRegistry() *NodeRegistry { } // Register registers the node' init function for all provided names. -func (r *NodeRegistry) Register(names []string, initf Initializer, credentials *Credentials) error { - newEntry := newRegistryEntry(names, initf, credentials) +func (r *NodeRegistry) Register(names []string, initf Initializer, attributes *NodeRegistryEntryAttributes) error { + newEntry := newRegistryEntry(names, initf, attributes) return r.addEntry(newEntry) } @@ -63,6 +63,14 @@ func (r *NodeRegistry) GetRegisteredNodeKindNames() []string { return result } +func (r *NodeRegistry) GetGenerateNodeAttributes() map[string]*GenerateNodeAttributes { + result := map[string]*GenerateNodeAttributes{} + for k, v := range r.nodeIndex { + result[k] = v.GetGenerateAttributes() + } + return result +} + func (r *NodeRegistry) Kind(kind string) *NodeRegistryEntry { return r.nodeIndex[kind] } @@ -70,11 +78,26 @@ func (r *NodeRegistry) Kind(kind string) *NodeRegistryEntry { type NodeRegistryEntry struct { nodeKindNames []string initFunction Initializer - credentials *Credentials + attributes *NodeRegistryEntryAttributes +} + +func (nre *NodeRegistryEntry) GetCredentials() *Credentials { + if nre.attributes == nil { + return nil + } + return nre.attributes.credentials +} + +func (nre *NodeRegistryEntry) GetGenerateAttributes() *GenerateNodeAttributes { + if nre.attributes == nil { + return nil + } + return nre.attributes.generateAttributes } // Credentials returns entry's credentials. -func (e *NodeRegistryEntry) Credentials() *Credentials { +// might return nil if no default credentials present +func (e *NodeRegistryEntryAttributes) Credentials() *Credentials { if e == nil { return nil } @@ -82,12 +105,62 @@ func (e *NodeRegistryEntry) Credentials() *Credentials { return e.credentials } -func newRegistryEntry(nodeKindNames []string, initFunction Initializer, credentials *Credentials) *NodeRegistryEntry { +func newRegistryEntry(nodeKindNames []string, initFunction Initializer, attributes *NodeRegistryEntryAttributes) *NodeRegistryEntry { return &NodeRegistryEntry{ nodeKindNames: nodeKindNames, initFunction: initFunction, - credentials: credentials, + attributes: attributes, + } +} + +type NodeRegistryEntryAttributes struct { + credentials *Credentials + generateAttributes *GenerateNodeAttributes +} + +func NewNodeRegistryEntryAttributes(c *Credentials, ga *GenerateNodeAttributes) *NodeRegistryEntryAttributes { + // set default value for GenerateNodeAttributes + if ga == nil { + ga = NewGenerateNodeAttributes(false, "") + } + return &NodeRegistryEntryAttributes{ + credentials: c, + generateAttributes: ga, + } +} + +func (nrea *NodeRegistryEntryAttributes) GetCredentials() *Credentials { + return nrea.credentials +} + +func (nrea *NodeRegistryEntryAttributes) GetGenerateAttributes() *GenerateNodeAttributes { + return nrea.generateAttributes +} + +type GenerateNodeAttributes struct { + generateable bool + interfaceFormat string +} + +func NewGenerateNodeAttributes(generateable bool, ifFormat string) *GenerateNodeAttributes { + return &GenerateNodeAttributes{ + generateable: generateable, + interfaceFormat: ifFormat, + } +} + +func (ga *GenerateNodeAttributes) IsGenerateable() bool { + if ga == nil { + return false + } + return ga.generateable +} + +func (ga *GenerateNodeAttributes) GetInterfaceFormat() string { + if ga == nil { + return "" } + return ga.interfaceFormat } // Credentials defines NOS SSH credentials. diff --git a/nodes/rare/rare.go b/nodes/rare/rare.go index 9dab4e6c0..647a2da1c 100644 --- a/nodes/rare/rare.go +++ b/nodes/rare/rare.go @@ -16,11 +16,19 @@ import ( var kindnames = []string{"rare"} +const ( + generateable = true + generateIfFornamt = "eth%d" +) + // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(nil, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(rare) - }, nil) + }, nrea) } type rare struct { diff --git a/nodes/sonic/sonic.go b/nodes/sonic/sonic.go index eb020f58e..cac3f44be 100644 --- a/nodes/sonic/sonic.go +++ b/nodes/sonic/sonic.go @@ -15,13 +15,21 @@ import ( "github.com/srl-labs/containerlab/utils" ) +const ( + generateable = true + generateIfFornamt = "eth%d" +) + var kindnames = []string{"sonic-vs"} // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(nil, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(sonic) - }, nil) + }, nrea) } type sonic struct { diff --git a/nodes/srl/srl.go b/nodes/srl/srl.go index 28bc0d733..055b6e595 100644 --- a/nodes/srl/srl.go +++ b/nodes/srl/srl.go @@ -32,6 +32,9 @@ import ( const ( srlDefaultType = "ixrd2" + generateable = true + generateIfFornamt = "e1-%d" + readyTimeout = time.Minute * 2 // max wait time for node to boot retryTimer = time.Second // additional config that clab adds on top of the factory config. @@ -113,9 +116,13 @@ var ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(srl) - }, defaultCredentials) + }, nrea) } type srl struct { diff --git a/nodes/vr_csr/vr-csr.go b/nodes/vr_csr/vr-csr.go index 583a52dca..711ded2da 100644 --- a/nodes/vr_csr/vr-csr.go +++ b/nodes/vr_csr/vr-csr.go @@ -30,9 +30,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrCsr) - }, defaultCredentials) + }, nrea) } type vrCsr struct { diff --git a/nodes/vr_ftosv/vr-ftosv.go b/nodes/vr_ftosv/vr-ftosv.go index 9f6e6d34a..b05385696 100644 --- a/nodes/vr_ftosv/vr-ftosv.go +++ b/nodes/vr_ftosv/vr-ftosv.go @@ -26,9 +26,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrFtosv) - }, defaultCredentials) + }, nrea) } type vrFtosv struct { diff --git a/nodes/vr_n9kv/vr-n9kv.go b/nodes/vr_n9kv/vr-n9kv.go index ed3196c65..66cabc9f8 100644 --- a/nodes/vr_n9kv/vr-n9kv.go +++ b/nodes/vr_n9kv/vr-n9kv.go @@ -27,9 +27,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrN9kv) - }, defaultCredentials) + }, nrea) } type vrN9kv struct { diff --git a/nodes/vr_nxos/vr-nxos.go b/nodes/vr_nxos/vr-nxos.go index 0b4d10528..dfc9cfa63 100644 --- a/nodes/vr_nxos/vr-nxos.go +++ b/nodes/vr_nxos/vr-nxos.go @@ -26,9 +26,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrNXOS) - }, defaultCredentials) + }, nrea) } type vrNXOS struct { diff --git a/nodes/vr_pan/vr-pan.go b/nodes/vr_pan/vr-pan.go index b8c4e18ce..ec3e7b7ab 100644 --- a/nodes/vr_pan/vr-pan.go +++ b/nodes/vr_pan/vr-pan.go @@ -26,9 +26,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrPan) - }, defaultCredentials) + }, nrea) } type vrPan struct { diff --git a/nodes/vr_ros/vr-ros.go b/nodes/vr_ros/vr-ros.go index 1e59e3b22..4b7347e61 100644 --- a/nodes/vr_ros/vr-ros.go +++ b/nodes/vr_ros/vr-ros.go @@ -26,9 +26,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrRos) - }, defaultCredentials) + }, nrea) } type vrRos struct { diff --git a/nodes/vr_sros/vr-sros.go b/nodes/vr_sros/vr-sros.go index 76952582e..0c241ee30 100644 --- a/nodes/vr_sros/vr-sros.go +++ b/nodes/vr_sros/vr-sros.go @@ -33,6 +33,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + vrsrosDefaultType = "sr-1" scrapliPlatformName = "nokia_sros" configDirName = "tftpboot" @@ -42,9 +45,11 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) r.Register(kindnames, func() nodes.Node { return new(vrSROS) - }, defaultCredentials) + }, nrea) } type vrSROS struct { diff --git a/nodes/vr_veos/vr-veos.go b/nodes/vr_veos/vr-veos.go index 347cc6200..73c39c48f 100644 --- a/nodes/vr_veos/vr-veos.go +++ b/nodes/vr_veos/vr-veos.go @@ -22,6 +22,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + scrapliPlatformName = "arista_eos" configDirName = "config" @@ -30,9 +33,12 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(vrVEOS) - }, defaultCredentials) + }, nrea) } type vrVEOS struct { diff --git a/nodes/vr_vmx/vr-vmx.go b/nodes/vr_vmx/vr-vmx.go index ad3301aa0..d4db5e18c 100644 --- a/nodes/vr_vmx/vr-vmx.go +++ b/nodes/vr_vmx/vr-vmx.go @@ -22,6 +22,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + configDirName = "config" startupCfgFName = "startup-config.cfg" @@ -30,9 +33,12 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(vrVMX) - }, defaultCredentials) + }, nrea) } type vrVMX struct { diff --git a/nodes/vr_vqfx/vr-vqfx.go b/nodes/vr_vqfx/vr-vqfx.go index 5430cd10f..fa819f075 100644 --- a/nodes/vr_vqfx/vr-vqfx.go +++ b/nodes/vr_vqfx/vr-vqfx.go @@ -22,6 +22,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + scrapliPlatformName = "juniper_junos" configDirName = "config" @@ -30,9 +33,11 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) r.Register(kindnames, func() nodes.Node { return new(vrVQFX) - }, defaultCredentials) + }, nrea) } type vrVQFX struct { diff --git a/nodes/vr_vsrx/vr-vsrx.go b/nodes/vr_vsrx/vr-vsrx.go index 12eff38e2..757d43c7b 100644 --- a/nodes/vr_vsrx/vr-vsrx.go +++ b/nodes/vr_vsrx/vr-vsrx.go @@ -22,6 +22,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + scrapliPlatformName = "juniper_junos" configDirName = "config" @@ -30,9 +33,12 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(vrVSRX) - }, defaultCredentials) + }, nrea) } type vrVSRX struct { diff --git a/nodes/vr_xrv/vr-xrv.go b/nodes/vr_xrv/vr-xrv.go index 09d5a81c9..5c6a278c6 100644 --- a/nodes/vr_xrv/vr-xrv.go +++ b/nodes/vr_xrv/vr-xrv.go @@ -30,9 +30,10 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, nil) r.Register(kindnames, func() nodes.Node { return new(vrXRV) - }, defaultCredentials) + }, nrea) } type vrXRV struct { diff --git a/nodes/vr_xrv9k/vr-xrv9k.go b/nodes/vr_xrv9k/vr-xrv9k.go index b59604d89..b9883c5aa 100644 --- a/nodes/vr_xrv9k/vr-xrv9k.go +++ b/nodes/vr_xrv9k/vr-xrv9k.go @@ -22,6 +22,9 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + scrapliPlatformName = "cisco_iosxr" configDirName = "config" @@ -30,9 +33,11 @@ const ( // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) r.Register(kindnames, func() nodes.Node { return new(vrXRV9K) - }, defaultCredentials) + }, nrea) } type vrXRV9K struct { diff --git a/nodes/xrd/xrd.go b/nodes/xrd/xrd.go index 2ce263131..d940d40d3 100644 --- a/nodes/xrd/xrd.go +++ b/nodes/xrd/xrd.go @@ -33,14 +33,20 @@ var ( ) const ( + generateable = true + generateIfFornamt = "eth%d" + scrapliPlatformName = "cisco_iosxr" ) // Register registers the node in the NodeRegistry. func Register(r *nodes.NodeRegistry) { + generateNodeAttributes := nodes.NewGenerateNodeAttributes(generateable, generateIfFornamt) + nrea := nodes.NewNodeRegistryEntryAttributes(defaultCredentials, generateNodeAttributes) + r.Register(kindnames, func() nodes.Node { return new(xrd) - }, defaultCredentials) + }, nrea) } type xrd struct {