diff --git a/clab/register.go b/clab/register.go index efd3bc934..2c579fe52 100644 --- a/clab/register.go +++ b/clab/register.go @@ -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" @@ -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) diff --git a/docs/manual/kinds/dell_sonic.md b/docs/manual/kinds/dell_sonic.md new file mode 100644 index 000000000..c53c900bf --- /dev/null +++ b/docs/manual/kinds/dell_sonic.md @@ -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 `. + +2. Default credentials are `admin:admin` +/// + +/// tab | SSH +To open a linux shell simply type in + +```bash +ssh +``` + +You will enter the bash shell of the VM: + +``` +❯ ssh +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 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. diff --git a/mkdocs.yml b/mkdocs.yml index 9f575f1ee..e1d71a746 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 diff --git a/nodes/dell_sonic/dell_sonic.go b/nodes/dell_sonic/dell_sonic.go new file mode 100644 index 000000000..7fa7e24a4 --- /dev/null +++ b/nodes/dell_sonic/dell_sonic.go @@ -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) +} diff --git a/schemas/clab.schema.json b/schemas/clab.schema.json index 3ffacf7f1..2075e25df 100644 --- a/schemas/clab.schema.json +++ b/schemas/clab.schema.json @@ -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", @@ -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" },