-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Cisco Catalyst 9000v kind. (#2133)
* Add support for Cisco Catalyst 9000v kind. * Add cat9kv relevant information to schema * Add initial Cat9kv documentation. * added parametrized docs * added macros and glightbox plugin to public mkdocs container * Add interface aliasing feature. * Update documentation to reflect interface aliases. * Remove asic tagged image in example configuration. * keep a single kind definition * Minor fixes and additions re: interfaces. --------- Co-authored-by: Roman Dodin <dodin.roman@gmail.com>
- Loading branch information
Showing
8 changed files
with
267 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
--- | ||
search: | ||
boost: 4 | ||
kind_code_name: cisco_cat9kv | ||
kind_display_name: Cisco Catalyst 9000v | ||
kind_short_display_name: Cat9kv | ||
--- | ||
# Cisco Catalyst 9000v | ||
|
||
The [[[ kind_display_name ]]] (or [[[ kind_short_display_name ]]] for short) is a virtualised form of the Cisco Catalyst 9000 series switches. It is identified with `[[[ kind_code_name ]]]` 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. | ||
|
||
The [[[ kind_display_name ]]] performs simulation of the dataplane ASICs that are present in the physical hardware. The two simulated ASICs are: | ||
|
||
- Cisco UADP (Unified Access Data-Plane). This is the default ASIC that's simulated. | ||
- Silicon One Q200 (referred to as Q200). | ||
|
||
/// note | ||
The Q200 simulation has a limited featureset compared to the UADP simulation. | ||
/// | ||
|
||
## Resource requirements | ||
|
||
| | UADP | Q200 | | ||
| --------- | ----- | ----- | | ||
| vCPU | 4 | 4 | | ||
| RAM (MB) | 18432 | 12288 | | ||
| Disk (GB) | 4 | 4 | | ||
|
||
## Managing [[[ kind_display_name ]]] nodes | ||
|
||
You can manage the [[[ kind_display_name ]]] with containerlab via the following interfaces: | ||
|
||
/// tab | bash | ||
to connect to a `bash` shell of a running Cisco CSR1000v container: | ||
|
||
```bash | ||
docker exec -it <container-name/id> bash | ||
``` | ||
|
||
/// | ||
/// tab | CLI | ||
to connect to the Catalyst 9000v CLI | ||
|
||
```bash | ||
ssh admin@<container-name/id> | ||
``` | ||
|
||
/// | ||
/// tab | NETCONF | ||
NETCONF server is running over port 830 | ||
|
||
```bash | ||
ssh admin@<container-name> -p 830 -s netconf | ||
``` | ||
|
||
/// | ||
/// note | ||
Default credentials: `admin:admin` | ||
/// | ||
|
||
## Interface naming convention | ||
|
||
You can use [interfaces names](../topo-def-file.md#interface-naming) in the topology file like they appear in the [[[ kind_display_name ]]] CLI. | ||
|
||
The interface naming convention is: `GigabitEthernet1/0/X` (or `Gi1/0/X`), where `X` is the port number. | ||
|
||
With that naming convention in mind: | ||
|
||
* `Gi1/0/1` - first data port available | ||
* `Gi1/0/2` - second data port, and so on... | ||
|
||
The example ports above would be mapped to the following Linux interfaces inside the container running the [[[ kind_display_name ]]] VM: | ||
|
||
- `eth0` - management interface connected to the containerlab management network. | ||
- `eth1` - First data-plane interface. Mapped to `GigabitEthernet1/0/1` interface. | ||
- `eth2` - Second data-plane interface. Mapped to `GigabitEthernet1/0/2` interface and so on. | ||
|
||
/// note | ||
Data interfaces may take 5+ minutes to function correctly after the node boots. | ||
/// | ||
|
||
You must define interfaces in a contigous manner in your toplogy file. For example, if you want to use `Gi1/0/4` you must define `Gi1/0/1`, `Gi1/0/2` and `Gi1/0/3`. See the example below. | ||
|
||
```yaml | ||
name: my-cat9kv-lab | ||
topology: | ||
nodes: | ||
cat9kv1: | ||
kind: cisco_cat9kv | ||
image: vrnetlab/vr-cat9kv:17.12.01p | ||
cat9kv2: | ||
kind: cisco_cat9kv | ||
image: vrnetlab/vr-cat9kv:17.12.01p | ||
|
||
links: | ||
- endpoints: ["cat9kv1:Gi1/0/1","cat9kv2:GigabitEthernet1/0/1"] | ||
- endpoints: ["cat9kv1:Gi1/0/2","cat9kv2:GigabitEthernet1/0/2"] | ||
- endpoints: ["cat9kv1:Gi1/0/3", "cat9kv2:GigabitEthernet1/0/3"] | ||
- endpoints: ["cat9kv1:Gi1/0/4", "cat9kv2:GigabitEthernet1/0/4"] | ||
``` | ||
/// warning | ||
Regardless of how many links are defined in your containerlab topology, the Catalyst 9000v will always display 8 data-plane interfaces. Links/interfaces that you did not define in your containerlab topology will *not* pass any traffic. | ||
/// | ||
## Features and options | ||
### ASIC data-plane simulation configuration | ||
The default ASIC simulation of the node will be UADP. To enable the Q200 simulation or to enable specific features for the UADP simulation, you must provide a `vswitch.xml` file (with the relevant configuration). | ||
|
||
You can do this when building the image with [vrnetlab](../vrnetlab.md), Please refer to the README file in vrnetlab/cat9kv for more information. | ||
|
||
You can also use supply the vswitch.xml file via `binds` in the containerlab topology file. Refer to the example below. | ||
|
||
```yaml | ||
name: my-cat9kv-lab | ||
topology: | ||
nodes: | ||
node1: | ||
kind: cisco_cat9kv | ||
image: vrnetlab/vr-cat9kv:17.12.01p | ||
binds: | ||
- /path/to/vswitch.xml:/vswitch.xml | ||
``` | ||
|
||
/// note | ||
You can obtain a `vswitch.xml` file from the relevant Cisco CML node definitions. | ||
/// | ||
|
||
### Environment variables | ||
|
||
There are `VCPU` and `RAM` environment variables defined. It is not recommended reduce the resources below the required amount. The node will be unable to boot in this case. | ||
|
||
The example below assigns 6vCPUs and 20 gigabytes of RAM to the node. | ||
|
||
```yaml | ||
name: my-cat9kv-lab | ||
topology: | ||
nodes: | ||
node1: | ||
kind: cisco_cat9kv | ||
image: vrnetlab/vr-cat9kv:17.12.01p | ||
env: | ||
VCPU: 6 | ||
RAM: 20480 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright 2020 Nokia | ||
// Licensed under the BSD 3-Clause License. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
package vr_cat9kv | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path" | ||
"regexp" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/srl-labs/containerlab/netconf" | ||
"github.com/srl-labs/containerlab/nodes" | ||
"github.com/srl-labs/containerlab/types" | ||
"github.com/srl-labs/containerlab/utils" | ||
) | ||
|
||
var ( | ||
kindnames = []string{"cisco_cat9kv"} | ||
defaultCredentials = nodes.NewCredentials("admin", "admin") | ||
|
||
InterfaceRegexp = regexp.MustCompile(`(?:Gi|GigabitEthernet)\s?1/0/(?P<port>\d+)$`) | ||
InterfaceOffset = 1 | ||
InterfaceHelp = "Gi1/0/X or GigabitEthernet1/0/X (where X >= 1) or ethX (where X >= 1)" | ||
) | ||
|
||
const ( | ||
scrapliPlatformName = "cisco_iosxe" | ||
|
||
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(vrCat9kv) | ||
}, defaultCredentials) | ||
} | ||
|
||
type vrCat9kv struct { | ||
nodes.VRNode | ||
} | ||
|
||
func (n *vrCat9kv) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error { | ||
// Init VRNode | ||
n.VRNode = *nodes.NewVRNode(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, | ||
"VCPU": "4", | ||
"RAM": "18432", | ||
} | ||
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")) | ||
|
||
if n.Cfg.Env["CONNECTION_MODE"] == "macvtap" { | ||
// mount dev dir to enable macvtap | ||
n.Cfg.Binds = append(n.Cfg.Binds, "/dev:/dev") | ||
} | ||
|
||
n.Cfg.Cmd = fmt.Sprintf("--username %s --password %s --hostname %s --connection-mode %s --vcpu %s --ram %s --trace", | ||
n.Cfg.Env["USERNAME"], n.Cfg.Env["PASSWORD"], n.Cfg.ShortName, n.Cfg.Env["CONNECTION_MODE"], n.Cfg.Env["VCPU"], n.Cfg.Env["RAM"]) | ||
|
||
n.InterfaceRegexp = InterfaceRegexp | ||
n.InterfaceOffset = InterfaceOffset | ||
n.InterfaceHelp = InterfaceHelp | ||
|
||
return nil | ||
} | ||
|
||
func (s *vrCat9kv) PreDeploy(_ context.Context, params *nodes.PreDeployParams) error { | ||
utils.CreateDirectory(s.Cfg.LabDir, 0777) | ||
_, err := s.LoadOrGenerateCertificate(params.Cert, params.TopologyName) | ||
if err != nil { | ||
return nil | ||
} | ||
return nodes.LoadStartupConfigFileVr(s, configDirName, startupCfgFName) | ||
} | ||
|
||
func (n *vrCat9kv) SaveConfig(_ context.Context) error { | ||
err := netconf.SaveConfig(n.Cfg.LongName, | ||
defaultCredentials.GetUsername(), | ||
defaultCredentials.GetPassword(), | ||
scrapliPlatformName, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Infof("saved %s running configuration to startup configuration file\n", n.Cfg.ShortName) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters