Skip to content

Commit

Permalink
Merge pull request #265 from srl-wim/vrsros-custom-variants
Browse files Browse the repository at this point in the history
added support for space delimited sros variants
  • Loading branch information
hellt committed Feb 11, 2021
2 parents fdf6a54 + 92ab642 commit 8ccfc27
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (c *CLab) NewNode(nodeName string, nodeCfg NodeConfig, idx int) error {
// mount tftpboot dir
node.Binds = append(node.Binds, fmt.Sprint(path.Join(node.LabDir, "tftpboot"), ":/tftpboot"))

node.Cmd = fmt.Sprintf("--trace --connection-mode %s --hostname %s --variant %s", node.Env["CONNECTION_MODE"], node.ShortName, node.NodeType)
node.Cmd = fmt.Sprintf("--trace --connection-mode %s --hostname %s --variant \"%s\"", node.Env["CONNECTION_MODE"], node.ShortName, node.NodeType)

case "vr-vmx":
node.Image = c.imageInitialization(&nodeCfg, node.Kind)
Expand Down
8 changes: 7 additions & 1 deletion clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/pkg/stdcopy"
"github.com/google/shlex"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -165,10 +166,15 @@ func (c *CLab) CreateContainer(ctx context.Context, node *Node) (err error) {
}
labels["clab-topo-file"] = c.TopoFile.path

cmd, err := shlex.Split(node.Cmd)
if err != nil {
return err
}

cont, err := c.DockerClient.ContainerCreate(nctx,
&container.Config{
Image: node.Image,
Cmd: strings.Fields(node.Cmd),
Cmd: cmd,
Env: convertEnvs(node.Env),
AttachStdout: true,
AttachStderr: true,
Expand Down
32 changes: 32 additions & 0 deletions docs/manual/kinds/vr-sros.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ Data interfaces `eth1+` needs to be configured with IP addressing manually using


## Features and options
### Variants
Virtual SR OS simulator can be run in multiple HW variants as explained in [the vSIM installation guide](https://documentation.nokia.com/cgi-bin/dbaccessfilename.cgi/3HE15836AAADTQZZA01_V1_vSIM%20Installation%20and%20Setup%20Guide%2020.10.R1.pdf).

`vr-sros` container images come with [pre-packaged SR OS variants](https://github.com/hellt/vrnetlab/tree/master/sros#variants) as defined in the upstream repo as well as support [custom variant definition](https://github.com/hellt/vrnetlab/tree/master/sros#custom-variant). The pre-packaged variants are identified by the variant name and come up with cards and mda already configured. Custom variants, on the other hand, give users the full flexibility in emulated hardware configuration, but cards and mdas would need to be configured manually.

To make vr-sros to boot in one of the pacakged variants use its name like that:
```yaml
topology:
nodes:
sros:
kind: vr-sros
image: vrnetlab/vr-sros:20.10.R1
type: sr-1s # if type omitted, the default sr-1 variant will be used
license: license-sros20.txt
```
Custom variant can be defined as simple as that:
```yaml
# for distributed chassis CPM and IOM are indicated with markers cp: and lc:
# notice the delimeter string `___` that MUST be present between CPM and IOM portions
# max_nics value is provided in `lc` part.
# mem is provided in GB
# quote the string value
type: "cp: cpu=2 ram=4 chassis=ixr-e slot=A card=cpm-ixr-e ___ lc: cpu=2 ram=4 max_nics=34 chassis=ixr-e slot=1 card=imm24-sfp++8-sfp28+2-qsfp28 mda/1=m24-sfp++8-sfp28+2-qsfp28"
```
```yaml
# an integrated custom type definition
# note, no `cp:` marker is needed
type: "slot=A chassis=ixr-r6 card=cpiom-ixr-r6 mda/1=m6-10g-sfp++4-25g-sfp28"
```
### Node configuration
vr-sros nodes come up with a basic "blank" configuration where only the card/mda are provisioned, as well as the management interfaces such as Netconf, SNMP, gNMI.
Expand Down
4 changes: 3 additions & 1 deletion docs/manual/vrnetlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Keeping this requirement in mind from the very beginning, we added a kind [`brid
Although this approach has many pros, it doesn't allow users to define the VM based nodes in the same topology file. But not anymore, with [`vrnetlab`](https://github.com/plajjan/vrnetlab) integration containerlab became capable of launching topologies with VM-based routers.

## Vrnetlab
Vrnetlab essentially allows to package a regular VM inside a container and makes it runnable and accessible as if it was a container image all way long.
Vrnetlab essentially allows to package a regular VM inside a container and makes it runnable and accessible as if it was a container image.

To make this work, vrnetlab provides a set of scripts that will build the container image taking a user provided qcow file as an input. This enables containerlab to build topologies which consist both of native containerized NOSes and the VMs:

Expand All @@ -19,6 +19,8 @@ To make this work, vrnetlab provides a set of scripts that will build the contai
Although multiple vendors are supported in vrnetlab, to make these images work with container-based networking, we needed to [fork](https://github.com/hellt/vrnetlab) the project and provide the necessary improvements.
Thus, the VM based products will appear in the supported list gradually.

Make sure, that the VM that containerlab runs on have [Nested virtualization enabled](https://stafwag.github.io/blog/blog/2018/06/04/nested-virtualization-in-kvm/) to support vrnetlab based containers.

### Supported VM products


Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.3.1
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.1.2
github.com/mitchellh/go-homedir v1.1.0
github.com/olekukonko/tablewriter v0.0.5-0.20201029120751-42e21c7531a3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
Expand Down

0 comments on commit 8ccfc27

Please sign in to comment.