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

adds ceos support for extras #819

Merged
merged 5 commits into from
Mar 16, 2022
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
24 changes: 21 additions & 3 deletions docs/manual/kinds/ceos.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ In addition to cli commands such as `write memory` user can take advantage of th
To start an Arista cEOS node containerlab uses the configuration instructions described in Arista Forums[^1]. The exact parameters are outlined below.

=== "Startup command"
`/sbin/init systemd.setenv=INTFTYPE=eth systemd.setenv=ETBA=4 systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 systemd.setenv=CEOS=1 systemd.setenv=EOS_PLATFORM=ceoslab systemd.setenv=container=docker systemd.setenv=MAPETH0=1 systemd.setenv=MGMT_INTF=eth0`
`/sbin/init systemd.setenv=INTFTYPE=eth systemd.setenv=ETBA=1 systemd.setenv=SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT=1 systemd.setenv=CEOS=1 systemd.setenv=EOS_PLATFORM=ceoslab systemd.setenv=container=docker systemd.setenv=MAPETH0=1 systemd.setenv=MGMT_INTF=eth0`
=== "Environment variables"
`CEOS:1`
`EOS_PLATFORM":ceoslab`
`container:docker`
`ETBA:4`
`ETBA:1`
`SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT:1`
`INTFTYPE:eth`
`MAPETH0:1`
Expand Down Expand Up @@ -215,9 +215,27 @@ clab-srlceos01/ceos

9 directories, 11 files
```
## Copy to `flash`

If there is a need to copy ceos-specific configuration or override files to the ceos node in the topology use `.extras.ceos-copy-to-flash` config option. These files will be copied to the node's flash directory and evaluated on startup.

```yaml
name: ceos
topology:
nodes:
ceos1:
kind: ceos
...
extras:
ceos-copy-to-flash:
- ceos-config # (1)!
- toggle_override
```

1. Paths are relative to the topology file. Absolute paths like `~/some/path` or `/some/path` are also possible.

## Lab examples
The following labs feature cEOS node:
The following labs feature a cEOS node:

- [SR Linux and cEOS](../../lab-examples/srl-ceos.md)

Expand Down
18 changes: 17 additions & 1 deletion nodes/ceos/ceos.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
"CEOS": "1",
"EOS_PLATFORM": "ceoslab",
"container": "docker",
"ETBA": "4",
"ETBA": "1",
"SKIP_ZEROTOUCH_BARRIER_IN_SYSDBINIT": "1",
"INTFTYPE": "eth",
"MAPETH0": "1",
Expand Down Expand Up @@ -136,6 +136,22 @@ func createCEOSFiles(node *types.NodeConfig) error {
return err
}

// if extras have been provided copy these into the flash directory
if node.Extras != nil && len(node.Extras.CeosCopyToFlash) != 0 {
extras := node.Extras.CeosCopyToFlash
flash := filepath.Join(node.LabDir, "flash")

for _, extrapath := range extras {
basename := filepath.Base(extrapath)
dest := filepath.Join(flash, basename)

topoDir := filepath.Dir(filepath.Dir(node.LabDir)) // topo dir is needed to resolve extrapaths
if err := utils.CopyFile(utils.ResolvePath(extrapath, topoDir), dest, 0644); err != nil {
return fmt.Errorf("extras: copy-to-flash %s -> %s failed %v", extrapath, dest, err)
}
}
}

// sysmac is a system mac that is +1 to Ma0 mac
m, err := net.ParseMAC(node.MacAddress)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func (cd *ConfigDispatcher) GetVars() map[string]interface{} {

// Extras contains extra node parameters which are not entitled to be part of a generic node config
type Extras struct {
SRLAgents []string `yaml:"srl-agents,omitempty"` // Nokia SR Linux agents. As of now just the agents spec files can be provided here
MysocketProxy string `yaml:"mysocket-proxy,omitempty"` // Proxy address that mysocketctl will use
SRLAgents []string `yaml:"srl-agents,omitempty"` // Nokia SR Linux agents. As of now just the agents spec files can be provided here
MysocketProxy string `yaml:"mysocket-proxy,omitempty"` // Proxy address that mysocketctl will use
CeosCopyToFlash []string `yaml:"ceos-copy-to-flash,omitempty"` // paths to files which are to be copied to ceos flash dir
}