Skip to content

Commit

Permalink
align node interface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Jun 29, 2021
1 parent a3e121c commit dc2396d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions clab/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
jT "github.com/kellerza/template"

log "github.com/sirupsen/logrus"
"github.com/srl-labs/containerlab/nodes"
"github.com/srl-labs/containerlab/types"
)

Expand All @@ -26,7 +27,7 @@ type NodeConfig struct {
Info []string
}

func RenderAll(nodes map[string]*types.NodeConfig, links map[int]*types.Link) (map[string]*NodeConfig, error) {
func RenderAll(nodes map[string]nodes.Node, links map[int]*types.Link) (map[string]*NodeConfig, error) {
res := make(map[string]*NodeConfig)

if len(TemplateNames) == 0 {
Expand All @@ -43,7 +44,7 @@ func RenderAll(nodes map[string]*types.NodeConfig, links map[int]*types.Link) (m

for nodeName, vars := range PrepareVars(nodes, links) {
res[nodeName] = &NodeConfig{
TargetNode: nodes[nodeName],
TargetNode: nodes[nodeName].Config(),
Vars: vars,
}

Expand Down
10 changes: 6 additions & 4 deletions clab/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

log "github.com/sirupsen/logrus"
"github.com/srl-labs/containerlab/nodes"
"github.com/srl-labs/containerlab/types"
"inet.af/netaddr"
)
Expand All @@ -17,24 +18,25 @@ const (
type Dict map[string]interface{}

// Prepare variables for all nodes. This will also prepare all variables for the links
func PrepareVars(nodes map[string]*types.NodeConfig, links map[int]*types.Link) map[string]Dict {
func PrepareVars(nodes map[string]nodes.Node, links map[int]*types.Link) map[string]Dict {

res := make(map[string]Dict)

// preparing all nodes vars
for _, node := range nodes {
name := node.ShortName
nodeCfg := node.Config()
name := nodeCfg.ShortName
// Init array for this node
res[name] = make(map[string]interface{})
nc := GetNodeConfigFromLabels(node.Labels)
nc := GetNodeConfigFromLabels(nodeCfg.Labels)
for key := range nc.Vars {
res[name][key] = nc.Vars[key]
}
// Create link array
res[name]["links"] = []interface{}{}
// Ensure role or Kind
if _, ok := res[name]["role"]; !ok {
res[name]["role"] = node.Kind
res[name]["role"] = nodeCfg.Kind
}
}

Expand Down
5 changes: 1 addition & 4 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ var configCmd = &cobra.Command{
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
var err error
if err = topoSet(); err != nil {
return err
}

transport.DebugCount = debugCount

Expand All @@ -35,7 +32,7 @@ var configCmd = &cobra.Command{
clab.WithTopoFile(topo),
)

setFlags(c.Config)
// setFlags(c.Config)
log.Debugf("Topology definition: %+v", c.Config)
// Parse topology information
if err = c.ParseTopology(); err != nil {
Expand Down

0 comments on commit dc2396d

Please sign in to comment.