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

Switch to D2L as SR Linux default type #2094

Merged
merged 24 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
14 changes: 7 additions & 7 deletions clab/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestTypeInit(t *testing.T) {
"undefined_type_returns_default": {
got: "test_data/topo1.yml",
node: "node2",
want: "ixrd2",
want: "ixrd2l",
},
"node_type_override_kind_type": {
got: "test_data/topo2.yml",
Expand All @@ -165,12 +165,12 @@ func TestTypeInit(t *testing.T) {
"node_inherits_kind_type": {
got: "test_data/topo2.yml",
node: "node1",
want: "ixrd2",
want: "ixrd2l",
},
"node_inherits_default_type": {
got: "test_data/topo3.yml",
node: "node2",
want: "ixrd2",
want: "ixrd2l",
},
}

Expand Down Expand Up @@ -394,7 +394,7 @@ func TestLabelsInit(t *testing.T) {
labels.Containerlab: "topo1",
labels.NodeName: "node1",
labels.NodeKind: "nokia_srlinux",
labels.NodeType: "ixrd2",
labels.NodeType: "ixrd2l",
labels.NodeGroup: "",
labels.NodeLabDir: "../clab-topo1/node1",
labels.TopoFile: "topo1.yml",
Expand All @@ -407,7 +407,7 @@ func TestLabelsInit(t *testing.T) {
labels.Containerlab: "topo1",
labels.NodeName: "node2",
labels.NodeKind: "nokia_srlinux",
labels.NodeType: "ixrd2",
labels.NodeType: "ixrd2l",
labels.NodeGroup: "",
labels.NodeLabDir: "../clab-topo1/node2",
labels.TopoFile: "topo1.yml",
Expand All @@ -421,7 +421,7 @@ func TestLabelsInit(t *testing.T) {
labels.Containerlab: "topo2",
labels.NodeName: "node1",
labels.NodeKind: "nokia_srlinux",
labels.NodeType: "ixrd2",
labels.NodeType: "ixrd2l",
labels.NodeGroup: "",
labels.NodeLabDir: "../clab-topo2/node1",
labels.TopoFile: "topo2.yml",
Expand All @@ -435,7 +435,7 @@ func TestLabelsInit(t *testing.T) {
labels.Containerlab: "topo3",
labels.NodeName: "node2",
labels.NodeKind: "nokia_srlinux",
labels.NodeType: "ixrd2",
labels.NodeType: "ixrd2l",
labels.NodeGroup: "",
labels.NodeLabDir: "../clab-topo3/node2",
labels.TopoFile: "topo3.yml",
Expand Down
2 changes: 1 addition & 1 deletion clab/test_data/topo2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ topology:
kinds:
nokia_srlinux:
license: kind.lic
type: ixrd2
type: ixrd2l
env:
env1: val1
user: customkind
Expand Down
4 changes: 2 additions & 2 deletions clab/test_data/topo3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ topology:
license: default.lic
binds:
- default.lic:/dst
type: ixrd2
type: ixrd2l
env:
env1: val1
user: customglobal
Expand All @@ -13,6 +13,6 @@ topology:
nodes:
node1:
kind: nokia_srlinux
type: ixrd3
type: ixrd3l
node2:
kind: nokia_srlinux
3 changes: 2 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/spf13/cobra"
"github.com/srl-labs/containerlab/clab"
"github.com/srl-labs/containerlab/links"
"github.com/srl-labs/containerlab/nodes/srl"
"github.com/srl-labs/containerlab/types"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -44,7 +45,7 @@ var supportedKinds = []string{
}

const (
defaultSRLType = "ixrd2"
defaultSRLType = srl.SRLinuxDefaultType
defaultNodePrefix = "node"
defaultGroupPrefix = "tier"
)
Expand Down
3 changes: 1 addition & 2 deletions docs/lab-examples/templated02.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pods:
prefix: spine
leaves:
# SRL leaf type
type: ixrd2
type: ixrd2l
# number of leaves per pod
num: 4
# prefix of leaf name: ${prefix}${index}
Expand All @@ -61,5 +61,4 @@ bash configure.sh
[topofile]: https://github.com/srl-labs/containerlab/tree/main/lab-examples/templated01/templated01.clab.gotmpl
[topovarfile]: https://github.com/srl-labs/containerlab/tree/main/lab-examples/templated01/templated01.clab_vars.yaml


<script type="text/javascript" src="https://viewer.diagrams.net/js/viewer-static.min.js" async></script>
2 changes: 1 addition & 1 deletion docs/manual/kinds/bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ name: br01
topology:
kinds:
nokia_srlinux:
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
nodes:
srl1:
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/kinds/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ topology:
nodes:
node1:
kind: nokia_srlinux # node1 is of srl kind
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
node2:
kind: ceos # node2 is of ceos kind
Expand Down
4 changes: 2 additions & 2 deletions docs/manual/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ topology:
nodes:
node1: # node name
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
startup-config: /root/mylab/node1.cfg
binds:
Expand Down Expand Up @@ -48,7 +48,7 @@ The `kind` property selects which kind this node is of. Kinds are essentially a

### type

With `type` the user sets a type of the node. Types work in combination with the kinds, such as the type value of `ixrd2` sets the chassis type for SR Linux node, thus this value only makes sense to nodes of kind `srl`.
With `type` the user sets a type of the node. Types work in combination with the kinds, such as the type value of `ixrd2l` sets the chassis type for SR Linux node, thus this value only makes sense to nodes of kind `nokia_srlinux`.

Other nodes might treat `type` field differently, that will depend on the kind of the node. The `type` values and effects defined in the documentation for a specific kind.

Expand Down
12 changes: 6 additions & 6 deletions docs/manual/topo-def-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ topology:
nodes:
srl: # this is a name of the 1st node
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
ceos: # this is a name of the 2nd node
kind: ceos
Expand All @@ -115,7 +115,7 @@ Each node can have multiple configuration properties which make containerlab qui
```yaml
srl:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
```

Expand Down Expand Up @@ -305,7 +305,7 @@ Kinds define the behavior and the nature of a node, it says if the node is a spe
topology:
kinds:
nokia_srlinux:
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
nodes:
srl1:
Expand All @@ -327,15 +327,15 @@ topology:
nodes:
srl1:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
srl2:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
srl3:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
```

Expand Down
1 change: 1 addition & 0 deletions docs/manual/wireshark.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Every lab emulation software must provide its users with the packet capturing ab
Containerlab offers a simple way to capture the packets from any interface of any node in the lab. This article will explain how to do that.

///tip

If you are looking for a free Web UI for packet capture with Wireshark, check out our [Edgeshark integration](#edgeshark-integration).
///

Expand Down
2 changes: 1 addition & 1 deletion lab-examples/br01/br01.clab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: br01
topology:
kinds:
nokia_srlinux:
type: ixrd2
type: ixrd2l
image: ghcr.io/nokia/srlinux
nodes:
srl1:
Expand Down
6 changes: 3 additions & 3 deletions lab-examples/clos01/clos01.clab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ topology:
nodes:
leaf1:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
leaf2:
kind: nokia_srlinux
type: ixrd2
type: ixrd2l
spine:
kind: nokia_srlinux
type: ixrd3
type: ixrd3l
client1:
kind: linux
client2:
Expand Down
6 changes: 3 additions & 3 deletions lab-examples/templated02/templated02.clab_vars.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
super_spines:
# SRL super spine type
type: ixrd3
type: ixrd3l
# number of super spines
num: 2
# prefix of super spines name: ${prefix}${index}
Expand All @@ -11,14 +11,14 @@ pods:
num: 4
spines:
# SRL spine type
type: ixrd3
type: ixrd3l
# number of spines per pod
num: 2
# prefix of spines name: ${prefix}${pod_index}-${index}
prefix: spine
leaves:
# SRL leaf type
type: ixrd2
type: ixrd2l
# number of leaves per pod
num: 4
# prefix of leaf name: ${prefix}${pod_index}-${index}
Expand Down
4 changes: 2 additions & 2 deletions nodes/srl/srl.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

const (
srlDefaultType = "ixrd2" // default srl node type
SRLinuxDefaultType = "ixrd2l" // default srl node type

readyTimeout = time.Minute * 5 // max wait time for node to boot
retryTimer = time.Second
Expand Down Expand Up @@ -147,7 +147,7 @@ func (n *srl) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
}

if n.Cfg.NodeType == "" {
n.Cfg.NodeType = srlDefaultType
n.Cfg.NodeType = SRLinuxDefaultType
}

if _, found := srlTypes[n.Cfg.NodeType]; !found {
Expand Down
28 changes: 17 additions & 11 deletions runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,24 @@ func (d *DockerRuntime) WithMgmtNet(n *types.MgmtNet) {
return
}

// detect default MTU if this config parameter was not provided in the clab file
netRes, err := d.Client.NetworkInspect(context.TODO(), defaultDockerNetwork, dockerTypes.NetworkInspectOptions{})
if err != nil {
d.mgmt.MTU = 1500
log.Debugf("an error occurred when trying to detect docker default network mtu")
}

if mtu, ok := netRes.Options["com.docker.network.driver.mtu"]; ok {
log.Debugf("detected docker network mtu value - %s", mtu)
d.mgmt.MTU, err = strconv.Atoi(mtu)
// if the network name is not "clab", which is a default network name used by containerlab
// then likely a user wants to keep the custom network mtu value.
// however, if the network name is "clab" and mtu is not provided in the topology file
// we should detect the mtu value of the default docker network and set it for the clab network
// as most often this is desired.
if n.Network == "clab" {
netRes, err := d.Client.NetworkInspect(context.TODO(), defaultDockerNetwork, dockerTypes.NetworkInspectOptions{})
if err != nil {
log.Errorf("Error parsing MTU value of %q as int", mtu)
d.mgmt.MTU = 1500
log.Debugf("an error occurred when trying to detect docker default network mtu")
}

if mtu, ok := netRes.Options["com.docker.network.driver.mtu"]; ok {
log.Debugf("detected docker network mtu value - %s", mtu)
d.mgmt.MTU, err = strconv.Atoi(mtu)
if err != nil {
log.Errorf("Error parsing MTU value of %q as int", mtu)
}
}
}

Expand Down
Loading
Loading