Skip to content

Commit

Permalink
Dell Enterprise Sonic support (#2125)
Browse files Browse the repository at this point in the history
* init dell_sonic

* docs
  • Loading branch information
hellt committed Jul 5, 2024
1 parent f33db2a commit 80722a6
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 3 deletions.
2 changes: 2 additions & 0 deletions clab/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
checkpoint_cloudguard "github.com/srl-labs/containerlab/nodes/checkpoint_cloudguard"
crpd "github.com/srl-labs/containerlab/nodes/crpd"
cvx "github.com/srl-labs/containerlab/nodes/cvx"
"github.com/srl-labs/containerlab/nodes/dell_sonic"
ext_container "github.com/srl-labs/containerlab/nodes/ext_container"
fortinet_fortigate "github.com/srl-labs/containerlab/nodes/fortinet_fortigate"
generic_vm "github.com/srl-labs/containerlab/nodes/generic_vm"
Expand Down Expand Up @@ -68,6 +69,7 @@ func (c *CLab) RegisterNodes() {
vr_c8000v.Register(c.Reg)
vr_freebsd.Register(c.Reg)
generic_vm.Register(c.Reg)
dell_sonic.Register(c.Reg)
vr_ftosv.Register(c.Reg)
vr_n9kv.Register(c.Reg)
vr_pan.Register(c.Reg)
Expand Down
88 changes: 88 additions & 0 deletions docs/manual/kinds/dell_sonic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
search:
boost: 4
---
# Dell Enterprise SONiC

Dell Enterprise SONiC VM is identified with `dell_sonic` kind in the [topology file](../topo-def-file.md). It is built using [vrnetlab](../vrnetlab.md) project and essentially is a Qemu VM packaged in a docker container format.

## Managing Dell SONiC nodes

Dell SONiC node launched with containerlab can be managed via the following interfaces:

/// note

1. Dell SONiC node will take ~2min to fully boot.
You can monitor the progress with `docker logs -f <container-name>`.

2. Default credentials are `admin:admin`
///

/// tab | SSH
To open a linux shell simply type in

```bash
ssh <node-name>
```

You will enter the bash shell of the VM:

```
❯ ssh <node name>
Debian GNU/Linux 10
admin@clab-dell_sonic-ds's password:
Linux ds 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64
You are on
____ ___ _ _ _ ____
/ ___| / _ \| \ | (_)/ ___|
\___ \| | | | \| | | |
___) | |_| | |\ | | |___
|____/ \___/|_| \_|_|\____|
-- Software for Open Networking in the Cloud --
Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.
Help: http://azure.github.io/SONiC/
admin@sonic:~$
```

From within the Linux shell users can perform system configuration using linux utilities, or connect to the SONiC CLI using `vtysh` command.

```
admin@sonic:~$ vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic#
```

///
/// tab | Telnet
to connect to sonic-vm CLI via telnet

```bash
telnet <container-name/id> 5000
```

///

## Interfaces mapping

Dell SONiC container uses the following mapping rules for its interfaces:

* `eth0` - management interface connected to the containerlab management network
* `eth1` - first data (front-panel port) interface that is mapped to Ethernet0 port
* `eth2` - second data interface that is mapped to Ethernet4 port. Any new port will result in a "previous interface + 4" (Ethernet4) mapping.

When containerlab launches sonic-vs node, it will assign IPv4/6 address to the `eth0` interface. Data interface `eth1` mapped to `Ethernet0` port and needs to be configured with IP addressing manually.

## Features and options

### Startup configuration

VM-based SONiC supports the [`startup-config`](../nodes.md#startup-config) feature. The startup configuration file is a JSON file that is available in the VM's filesystem by the `/etc/sonic/config_db.json` path.

Extracting the config from a running node is possible with `containerlab save` command. The config will be available in the lab directory.
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ nav:
- SONiC:
- Container: manual/kinds/sonic-vs.md
- VM: manual/kinds/sonic-vm.md
- Dell FTOS10v: manual/kinds/vr-ftosv.md
- Dell:
- FTOS10v: manual/kinds/vr-ftosv.md
- Enterprise SONiC: manual/kinds/dell_sonic.md
- MikroTik RouterOS: manual/kinds/vr-ros.md
- IPInfusion OcNOS: manual/kinds/ipinfusion-ocnos.md
- OpenBSD: manual/kinds/openbsd.md
Expand Down
79 changes: 79 additions & 0 deletions nodes/dell_sonic/dell_sonic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2020 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause

package dell_sonic

import (
"context"
"fmt"
"path"

"github.com/srl-labs/containerlab/nodes"
"github.com/srl-labs/containerlab/types"
"github.com/srl-labs/containerlab/utils"
)

var (
kindnames = []string{"dell_sonic"}
defaultCredentials = nodes.NewCredentials("admin", "admin")
)

const (
configDirName = "config"
startupCfgFName = "startup-config.cfg"
)

// Register registers the node in the NodeRegistry.
func Register(r *nodes.NodeRegistry) {
r.Register(kindnames, func() nodes.Node {
return new(dell_sonic)
}, defaultCredentials)
}

type dell_sonic struct {
nodes.DefaultNode
}

func (n *dell_sonic) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
// Init DefaultNode
n.DefaultNode = *nodes.NewDefaultNode(n)
// set virtualization requirement
n.HostRequirements.VirtRequired = true

n.Cfg = cfg
for _, o := range opts {
o(n)
}
// env vars are used to set launch.py arguments in vrnetlab container
defEnv := map[string]string{
"CONNECTION_MODE": nodes.VrDefConnMode,
"USERNAME": defaultCredentials.GetUsername(),
"PASSWORD": defaultCredentials.GetPassword(),
"DOCKER_NET_V4_ADDR": n.Mgmt.IPv4Subnet,
"DOCKER_NET_V6_ADDR": n.Mgmt.IPv6Subnet,
}
n.Cfg.Env = utils.MergeStringMaps(defEnv, n.Cfg.Env)

// mount config dir to support startup-config functionality
n.Cfg.Binds = append(n.Cfg.Binds, fmt.Sprint(path.Join(n.Cfg.LabDir, configDirName), ":/config"))

n.Cfg.Cmd = fmt.Sprintf("--username %s --password %s --hostname %s --connection-mode %s --trace",
n.Cfg.Env["USERNAME"], n.Cfg.Env["PASSWORD"], n.Cfg.ShortName, n.Cfg.Env["CONNECTION_MODE"])

return nil
}

func (n *dell_sonic) PreDeploy(_ context.Context, params *nodes.PreDeployParams) error {
utils.CreateDirectory(n.Cfg.LabDir, 0777)
_, err := n.LoadOrGenerateCertificate(params.Cert, params.TopologyName)
if err != nil {
return nil
}
return nodes.LoadStartupConfigFileVr(n, configDirName, startupCfgFName)
}

// CheckInterfaceName checks if a name of the interface referenced in the topology file is correct.
func (n *dell_sonic) CheckInterfaceName() error {
return nodes.GenericVMInterfaceCheck(n.Cfg.ShortName, n.Endpoints)
}
9 changes: 7 additions & 2 deletions schemas/clab.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@
"vr-cisco_n9kv",
"cisco_n9kv",
"cisco_ftdv",
"vr-ftosv",
"vr-dell_ftosv",
"dell_ftosv",
"dell_sonic",
"vr-aoscx",
"vr-aruba_aoscx",
"aruba_aoscx",
Expand Down Expand Up @@ -888,6 +887,12 @@
"sonic-vm": {
"$ref": "#/definitions/node-config"
},
"dell_ftosv": {
"$ref": "#/definitions/node-config"
},
"dell_sonic": {
"$ref": "#/definitions/node-config"
},
"vr-nokia_sros": {
"$ref": "#/definitions/node-config"
},
Expand Down

0 comments on commit 80722a6

Please sign in to comment.