Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link-labeling #45

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}