From 031c60b892ef6006043e0a23e0e130e342cb7695 Mon Sep 17 00:00:00 2001 From: henderiw Date: Wed, 9 Sep 2020 16:16:10 +0200 Subject: [PATCH] link-labeling change from slice to map --- clab/config.go | 34 +++++++++++++++++----------------- lab-examples/wan-topo.yml | 12 ++++++------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clab/config.go b/clab/config.go index c4963cfbe..3624627d4 100644 --- a/clab/config.go +++ b/clab/config.go @@ -28,8 +28,8 @@ type dutInfo struct { } type link struct { - Endpoints []string `yaml:"endpoints"` - Labels []map[string]string `yaml:"labels,omitempty"` + Endpoints []string `yaml:"endpoints"` + Labels map[string]string `yaml:"labels,omitempty"` } // Conf holds the configuration file input @@ -96,7 +96,7 @@ type Link struct { Kind string Type string Vlan string - Labels []map[string]string + Labels map[string]string } // Endpoint is a sttruct that contains information of a link endpoint @@ -377,21 +377,21 @@ func (c *cLab) NewLink(l link) *Link { link.Type = "p2p" link.Vlan = "0" - for _, label := range l.Labels { - // Kind is either a backbone facing or customer facing interface - // wan is customer facing, client - if _, exists := label["kind"]; exists { - link.Kind = label["kind"] - } - // Type is either a lag or a p2p link - if _, exists := label["type"]; exists { - link.Type = label["type"] - } - // Vlan is a string which is 0 for untagged and >0 for tagged - if _, exists := label["vlan"]; exists { - link.Vlan = label["vlan"] - } + //for _, label := range l.Labels { + // Kind is either a backbone facing or customer facing interface + // wan is customer facing, client + if _, exists := l.Labels["kind"]; exists { + link.Kind = l.Labels["kind"] + } + // Type is either a lag or a p2p link + if _, exists := l.Labels["type"]; exists { + link.Type = l.Labels["type"] + } + // Vlan is a string which is 0 for untagged and >0 for tagged + if _, exists := l.Labels["vlan"]; exists { + link.Vlan = l.Labels["vlan"] } + //} link.Labels = l.Labels for i, d := range l.Endpoints { diff --git a/lab-examples/wan-topo.yml b/lab-examples/wan-topo.yml index 0a9c41261..34f3cad06 100644 --- a/lab-examples/wan-topo.yml +++ b/lab-examples/wan-topo.yml @@ -37,9 +37,9 @@ Duts: Links: - endpoints: ["wan1:e1-1", "wan2:e1-1"] - labels: ["kind": "wan", "type": "lag", "vlan": "0"] + labels: {"kind": "wan", "type": "lag", "vlan": "0"} - endpoints: ["wan1:e1-2", "wan2:e1-2"] - labels: ["kind": "wan", "type": "lag", "vlan": "0"] + labels: {"kind": "wan", "type": "lag", "vlan": "0"} - endpoints: ["wan1:e1-3", "wan2:e1-3"] - endpoints: ["wan1:e1-4", "wan2:e1-4"] - endpoints: ["wan3:e1-1", "wan1:e1-5"] @@ -51,10 +51,10 @@ Links: - endpoints: ["wan4:e1-3", "wan2:e1-7"] - endpoints: ["wan4:e1-4", "wan2:e1-8"] - endpoints: ["client1:eth1", "wan3:e1-5"] - labels: ["kind": "lan", "type": "irb", "vlan": "10"] + labels: {"kind": "lan", "type": "irb", "vlan": "10"} - endpoints: ["client2:eth1", "wan3:e1-6"] - labels: ["kind": "lan", "type": "irb", "vlan": "10"] + labels: {"kind": "lan", "type": "irb", "vlan": "10"} - endpoints: ["client3:eth1", "wan4:e1-5"] - labels: ["kind": "lan", "type": "irb", "vlan": "10"] + labels: {"kind": "lan", "type": "irb", "vlan": "10"} - endpoints: ["client4:eth1", "wan4:e1-6"] - labels: ["kind": "lan", "type": "irb", "vlan": "10"] \ No newline at end of file + labels: {"kind": "lan", "type": "irb", "vlan": "10"} \ No newline at end of file