Skip to content

Commit d215bdb

Browse files
kaelemchellt
andauthored
Add vscode-containerlab docs (#2427)
* Docs draft 1 * added graphics --------- Co-authored-by: Roman Dodin <dodin.roman@gmail.com>
1 parent 4d62379 commit d215bdb

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

docs/manual/vsc-extension.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Containerlab VS Code Extension
2+
3+
The lab-as-code approach taken by Containerlab means labs are "written" in YAML in a text editor or IDE. It also means you have to manage your labs via the command-line.
4+
5+
[VS Code](https://code.visualstudio.com/download) is a powerful text editor used by many for this purpose, and with the YAML schema provided by Containerlab the topology writing experience is made even easier.
6+
7+
We decided to further improve the experience with VS Code with a Containerlab [VS Code extension](https://marketplace.visualstudio.com/items?itemName=srl-labs.vscode-containerlab).
8+
9+
The Containerlab VS Code extension aims to greatly simplify and improve the labbing workflow, allowing you to perform essential lab operations within VS Code.
10+
11+
If you prefer to sit back and watch a video about this extension, say no more!
12+
13+
-{{youtube(url='https://www.youtube.com/embed/NIw1PbfCyQ4')}}-
14+
15+
/// admonition | Support
16+
If you have any questions about this extension, please join us in the [Containerlab Discord](https://discord.gg/vAyddtaEV9).
17+
///
18+
19+
## Features
20+
21+
The Containerlab extension packs a lot of features hidden under the icons or context menus. Here is a list of the main features, and we are always looking for new feature requests:
22+
23+
### Explorer
24+
25+
In the activity bar of VS Code, you will notice a Containerlab icon. Clicking on this icon will open the explorer.
26+
27+
The explorer is similar to the VS Code file explorer but instead of finding files, it discovers Containerlab topologies, running labs, containers and their interfaces.
28+
29+
The explorer will discover all labs in your local directory (and subdirectories), as well as any running labs on the system.
30+
31+
The explorer is a Treeview and for running labs, you can expand the labs to see running containers and you can expand running containers to see their interfaces.
32+
33+
### Editor
34+
35+
In the editor title actions when a Containerlab topology is open, there is a 'run' action and a 'graph' button.
36+
37+
This allows easy deployment and graphing of the lab from within the editor context.
38+
39+
![editor-actions](https://gitlab.com/rdodin/pics/-/wikis/uploads/c095d277e032ad0754b5f61f4a9057f2/CleanShot_2025-02-04_at_13.56.21_2x.png)
40+
41+
#### Command palette
42+
43+
When you have a topology open and active in the editor you can execute common actions from the command palette that you can open up with `CTRL+SHIFT+P`/`CMD+SHIFT+P`.
44+
45+
![palette](https://gitlab.com/rdodin/pics/-/wikis/uploads/be8d2c2d7d806dedd76c2b7a924d153d/CleanShot_2025-02-04_at_13.58.39_2x.png)
46+
47+
#### Keybindings
48+
49+
We have also set some default keybindings you can use to interact with the lab when you are editing a topology.
50+
51+
| Keys | Action |
52+
| ------------ | -------- |
53+
| `CTRL+ALT+D` | Deploy |
54+
| `CTRL+ALT+R` | Redeploy |
55+
| `CTRL+ALT+K` | Destroy |
56+
| `CTRL+ALT+G` | Graph |
57+
58+
### TopoViewer
59+
60+
Integrated into the extension as a 'graph' action is the [TopoViewer](https://github.com/asadarafat/topoViewer) project by @asadarafat.
61+
62+
TopoViewer is an interactive way to visualize your containerlab topologies. The topology must be running for the TopoViewer to be able to visualize it.
63+
64+
### Packet capture
65+
66+
In the explorer you can expand running labs and containers to view all the discovered interfaces for that container. You can either right click on the interface and start a packet capture or click the shark icon on the interface label.
67+
68+
Packet capture relies on the [Edgeshark integration](wireshark.md#edgeshark-integration). Install Edgeshark first, and then use the context menu or the fin icon next to the interface name.
69+
70+
## Settings reference
71+
72+
Below is a reference to the available settings that can be modified in the Containerlab VS Code extension.
73+
74+
### `containerlab.defaultSshUser`
75+
76+
The default username used to connect to a node via SSH.
77+
78+
| Type | Default |
79+
| -------- | ------- |
80+
| `string` | `admin` |
81+
82+
### `containerlab.sudoEnabledByDefault`
83+
84+
Whether or not to append `sudo` to any commands executed by the extension.
85+
86+
| Type | Default |
87+
| --------- | ------- |
88+
| `boolean` | `true` |
89+
90+
### `containerlab.refreshInterval`
91+
92+
The time interval (in milliseconds) for which the extension automatically refreshes.
93+
94+
On each refresh the extension will discover all local and running labs, as well as containers and interfaces of containers belonging to running labs.
95+
96+
By default this is 10 seconds.
97+
98+
| Type | Default |
99+
| -------- | ------- |
100+
| `number` | `10000` |
101+
102+
### `containerlab.node.execCommandMapping`
103+
104+
The a mapping between the node kind and command executed on the 'node attach' action.
105+
106+
The 'node attach' action performs the `docker exec -it <node> <command>` command. The `execCommandMapping` allows you to change the command executed by default on a per-kind basis.
107+
108+
By default this setting is empty, it should be used to override the [default mappings](https://github.com/srl-labs/vscode-containerlab/blob/main/resources/exec_cmd.json).
109+
110+
| Type | Default |
111+
| -------- | ----------- |
112+
| `object` | `undefined` |
113+
114+
#### Example
115+
116+
```json
117+
{
118+
"nokia_srl": "sr_cli",
119+
}
120+
```
121+
122+
In the settings UI, simply set the 'Item' field to the kind and the 'Value' field to `nokia_srl` and the command to `sr_cli`.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ nav:
7575
- Inventory: manual/inventory.md
7676
- Image management: manual/images.md
7777
- Labs and Codespaces: manual/codespaces.md
78+
- VS Code Extension: manual/vsc-extension.md
7879
- Link Impairments: manual/impairments.md
7980
- Developers guide:
8081
- manual/dev/index.md

0 commit comments

Comments
 (0)