Skip to content

Commit

Permalink
Merge pull request #45 from srl-wim/link-labeling
Browse files Browse the repository at this point in the history
link-labeling
  • Loading branch information
henderiw authored Sep 9, 2020
2 parents cc2bca3 + 031c60b commit 5b87055
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
34 changes: 17 additions & 17 deletions clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions lab-examples/wan-topo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
labels: {"kind": "lan", "type": "irb", "vlan": "10"}

0 comments on commit 5b87055

Please sign in to comment.