Skip to content

Commit

Permalink
add node names const
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Jun 23, 2021
1 parent b057754 commit eca0987
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 75 deletions.
2 changes: 1 addition & 1 deletion clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (c *CLab) CheckTopologyDefinition(ctx context.Context) error {
// VerifyBridgeExists verifies if every node of kind=bridge/ovs-bridge exists on the lab host
func (c *CLab) verifyBridgesExist() error {
for name, node := range c.Nodes {
if node.Config().Kind == "bridge" || node.Config().Kind == "ovs-bridge" {
if node.Config().Kind == nodes.NodeKindBridge || node.Config().Kind == nodes.NodeKindOVS {
if _, err := netlink.LinkByName(name); err != nil {
return fmt.Errorf("bridge %s is referenced in the endpoints section but was not found in the default network namespace", name)
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import (
"github.com/srl-labs/containerlab/types"
)

const (
nodeKind = "bridge"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindBridge, func() nodes.Node {
return new(bridge)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/ceos/ceos.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "ceos"
)

// defined env vars for the ceos
var ceosEnv = map[string]string{
"CEOS": "1",
Expand All @@ -37,7 +33,7 @@ var ceosEnv = map[string]string{
}

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindCEOS, func() nodes.Node {
return new(ceos)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/crpd/crpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "crpd"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindCRPD, func() nodes.Node {
return new(crpd)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import (
"github.com/srl-labs/containerlab/types"
)

const (
nodeKind = "host"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindHOST, func() nodes.Node {
return new(host)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ import (
"github.com/srl-labs/containerlab/types"
)

const (
nodeKind = "linux"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindLinux, func() nodes.Node {
return new(linux)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/mysocketio/mysocketio.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ import (
"github.com/srl-labs/containerlab/types"
)

const (
nodeKind = "mysocketio"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindMySocketIO, func() nodes.Node {
return new(mySocketIO)
})
}
Expand Down
21 changes: 21 additions & 0 deletions nodes/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ const (
VrDefConnMode = "tc"
)

var NodeKind string

const (
NodeKindBridge = "bridge"
NodeKindCEOS = "ceos"
NodeKindCRPD = "crpd"
NodeKindHOST = "host"
NodeKindLinux = "linux"
NodeKindMySocketIO = "mysocketio"
NodeKindOVS = "bridge-ovs"
NodeKindSonic = "sonic"
NodeKindSRL = "srl"
NodeKindVrCSR = "vr-csr"
NodeKindVrROS = "vr-ros"
NodeKindVrSROS = "vr-sros"
NodeKindVrVEOS = "vr-veos"
NodeKindVrVMX = "vr-vmx"
NodeKindVrXRV = "vr-xrv"
NodeKindVrXRV9K = "vr-xrv9k"
)

type Node interface {
Init(*types.NodeConfig, ...NodeOption) error
Config() *types.NodeConfig
Expand Down
6 changes: 1 addition & 5 deletions nodes/ovs/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import (
"github.com/srl-labs/containerlab/types"
)

const (
nodeKind = "ovs-bridge"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindOVS, func() nodes.Node {
return new(ovs)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/sonic/sonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "sonic-vs"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindSonic, func() nodes.Node {
return new(sonic)
})
}
Expand Down
3 changes: 1 addition & 2 deletions nodes/srl/srl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
)

const (
nodeKind = "srl"
srlDefaultType = "ixr6"
baseConfigDir = "/etc/containerlab/templates/srl/"
)
Expand All @@ -49,7 +48,7 @@ var srlSysctl = map[string]string{
}

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindSRL, func() nodes.Node {
return new(srl)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_csr/vr-csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-csr"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrCSR, func() nodes.Node {
return new(vrCsr)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_ros/vr-ros.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-ros"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrROS, func() nodes.Node {
return new(vrRos)
})
}
Expand Down
3 changes: 1 addition & 2 deletions nodes/vr_sros/vr-sros.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import (
)

const (
nodeKind = "vr-sros"
vrsrosDefaultType = "sr-1"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrSROS, func() nodes.Node {
return new(vrSROS)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_veos/vr-veos.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-veos"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrVEOS, func() nodes.Node {
return new(vrVEOS)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_vmx/vr-vmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-vmx"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrVMX, func() nodes.Node {
return new(vrVMX)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_xrv/vr-xrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-xrv"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrXRV, func() nodes.Node {
return new(vrXRV)
})
}
Expand Down
6 changes: 1 addition & 5 deletions nodes/vr_xrv9k/vr-xrv9k.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import (
"github.com/srl-labs/containerlab/utils"
)

const (
nodeKind = "vr-xrv9k"
)

func init() {
nodes.Register(nodeKind, func() nodes.Node {
nodes.Register(nodes.NodeKindVrXRV9K, func() nodes.Node {
return new(vrXRV9K)
})
}
Expand Down

0 comments on commit eca0987

Please sign in to comment.