Skip to content

Commit

Permalink
Add terminals and minor improvements (#65)
Browse files Browse the repository at this point in the history
* add terminals extension to base container and update CVaaS lab
  • Loading branch information
ankudinov authored Jan 13, 2025
1 parent 2a34470 commit 95cef9f
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 18 deletions.
15 changes: 8 additions & 7 deletions .cp/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ lab_features:
- git
- slides
- addAliases
- terminals

lab_author:
type: str
Expand All @@ -76,13 +77,13 @@ avd_version:
type: str
help: Pick required AVD version.
when: "{{ 'lab' | _in(templates) }}"
choices: ["5.0.0", "4.10.2"]
choices: ["5.0.0", "4.10.2", "5.1.0"]

lab_container_revision:
type: str
help: Please select lab container revision.
choices: ["1.1"]
default: "1.1"
choices: ["1.1", "1.2"]
default: "1.2"
when: false # no need to display this question due to a single choice

container_size:
Expand All @@ -108,7 +109,7 @@ clab_version:
type: str
help: Please select the Containerlab version.
when: "{{ 'lab' | _in(templates) }}"
choices: ["0.59.0", "0.57.5"]
choices: ["0.59.0", "0.60.1", "0.61.0"]

clab_user:
type: str
Expand All @@ -124,19 +125,19 @@ clab_password:

clab_mgmt_subnet:
type: str
help: Password for all lab devices.
help: cLab management subnet.
when: "{{ 'lab' | _in(templates) }}"
default: "10.0.0.0"

clab_mgmt_mask:
type: str
help: Password for all lab devices.
help: cLab management subnet mask.
when: "{{ 'lab' | _in(templates) }}"
default: "16"

clab_mgmt_gw:
type: str
help: Password for all lab devices.
help: cLab management subnet gateway.
when: "{{ 'lab' | _in(templates) }}"
default: "10.0.0.1"

Expand Down
5 changes: 5 additions & 0 deletions .cp/extra-vars/default/terminals.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hostname,terminals_icon,terminals_color,terminals_split
l01,bookmark,terminal.ansiRed
l02,bookmark,terminal.ansiRed,l01
h01,,terminal.ansiGreen
h02,,terminal.ansiGreen,h01
5 changes: 5 additions & 0 deletions .cp/extra-vars/small-l3ls-aa/terminals.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hostname,terminals_icon,terminals_color,terminals_split
l01,bookmark,terminal.ansiRed
l02,bookmark,terminal.ansiRed,l01
h01,,terminal.ansiGreen
h02,,terminal.ansiGreen,h01
5 changes: 5 additions & 0 deletions .cp/extra-vars/small-l3ls-mlag/terminals.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hostname,terminals_icon,terminals_color,terminals_split
l01,bookmark,terminal.ansiRed
l02,bookmark,terminal.ansiRed,l01
h01,,terminal.ansiGreen
h02,,terminal.ansiGreen,h01
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Temporary Items
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
{%- if 'terminals' | _in(lab_features) %}!.vscode/terminals.json{% endif %}

# Local History for Visual Studio Code
.history/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% raw %}{{% endraw %}
"autorun": true,
"autokill": true,
"env": {% raw %}{{% endraw %}
"TERMINAL_READY_MESSAGE": "Please check the README.md and the lab documentation before using the lab.",
"TERMINAL_SHELL": "bash",
"TERMINAL_STATUS_COMMAND": "Cli -p 15 -c 'show version'",
"TERMINAL_READY_COMMAND": "Cli -p 15"
{% raw %}},{% endraw %}
"terminals": {% raw %}[{% endraw %}
{%- for node in terminals %}
{% raw %}{{% endraw %}
"name": "{{ node.hostname }}",
{%- if node.terminals_description | default(false, true) %}
"description": "{{ node.terminals_description | default("", true) }}",
{%- endif %}
{%- if node.terminals_icon is defined %}
"icon": "{{ node.terminals_icon | default("code", true) }}",
{%- endif %}
{%- if node.terminals_color | default(false, true) %}
"color": "{{ node.terminals_color }}",
{%- endif %}
{%- if node.terminals_split | default(false, true) %}
"split": "{{ node.terminals_split }}",
{%- endif %}
"command": "terminals.sh {{ node.hostname }}",
"recycle": false,
"open": true,
"focus": true
{%- if not loop.last %}
{% raw %}},{% endraw %}
{%- else %}
{% raw %}}{% endraw %}
{%- endif %}
{%- endfor %}
{% raw %}]{% endraw %}
{% raw %}}{% endraw %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "ghcr.io/${localEnv:GITHUB_REPOSITORY}/lab-base:python3.11-avd-v5.0.0-clab0.59.0-rev1.1",
"image": "ghcr.io/${localEnv:GITHUB_REPOSITORY}/lab-base:python3.11-avd-v5.1.0-clab0.61.0-rev1.2",
// containerEnv set the variables applied to entire container
"containerEnv": {
"ARISTA_TOKEN": "${localEnv:ARTOKEN}",
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/container_build_parent_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ jobs:
matrix:
from_image: ["ghcr.io/aristanetworks/avd/universal"]
from_variant: ["python3.11-avd-v4.10.2", "python3.11-avd-v5.0.0", "python3.11-avd-v5.1.0"]
clab_version: ["0.57.5", "0.59.0", "0.60.1"]
clab_version: ["0.57.5", "0.59.0", "0.60.1", "0.61.0"]
with:
from_image: ${{ matrix.from_image }}
from_variant: ${{ matrix.from_variant }}
clab_version: ${{ matrix.clab_version }}
# the rev number will be updated with each run
container_revision: "1.1"
# 1.1 - initial version
# 1.2:
# - added fabiospampinato.vscode-terminals extension and templates
container_revision: "1.2"
4 changes: 4 additions & 0 deletions containers/dev/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"oderwat.indent-rainbow",
"AykutSarac.jsoncrack-vscode",
"hilleer.yaml-plus-json",
// spell checker
"streetsidesoftware.code-spell-checker",
// marp preview extension
"marp-team.marp-vscode",
// errors and highlighters
Expand All @@ -28,6 +30,8 @@
"yzhang.markdown-all-in-one",
"bierner.markdown-checkbox",
"DavidAnson.vscode-markdownlint",
// jinja
"samuelcolvin.jinjahtml",
// various tools
"tuxtina.json2yaml",
"mutantdino.resourcemonitor"
Expand Down
3 changes: 3 additions & 0 deletions containers/lab-base/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ RUN apt-get update \
# copy postCreate script
COPY ./postCreate.sh /bin/postCreate.sh
RUN chmod +x /bin/postCreate.sh
# copy terminals script
COPY ./terminals.sh /bin/terminals.sh
RUN chmod +x /bin/terminals.sh

USER ${USERNAME}

Expand Down
4 changes: 4 additions & 0 deletions containers/lab-base/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"yzhang.markdown-all-in-one",
"bierner.markdown-checkbox",
"DavidAnson.vscode-markdownlint",
// jinja
"samuelcolvin.jinjahtml",
// terminals manager
"fabiospampinato.vscode-terminals",
// various tools
"tuxtina.json2yaml",
"mutantdino.resourcemonitor"
Expand Down
17 changes: 17 additions & 0 deletions containers/lab-base/.devcontainer/terminals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# This script requires VSCode `fabiospampinato.vscode-terminals` extension
# The script will wait for docker exec to be ready before making the terminal available to user input

clear
echo 'Waiting for the lab to start...'
until docker exec -it $1 ${TERMINAL_SHELL} -c "${TERMINAL_STATUS_COMMAND} 2> /dev/null" >/dev/null 2>&1; do
sleep 5
done
clear
echo "$1 is ready."
# Print additional instructions for the user if env var is set
if [ "${TERMINAL_READY_MESSAGE}" ]; then
echo ${TERMINAL_READY_MESSAGE}
fi
docker exec -it $1 ${TERMINAL_READY_COMMAND}
6 changes: 3 additions & 3 deletions docs/cvaas-cvaas-and-avd-demo--evpn-mlag.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ To run the lab on your own machine, you can download all required files using th

This lab has following devices:

| Hostname | Type | OS | Management Address | Login | Password |
| -------- | ---- | -- | ------------------ | ----- | -------- |
| Hostname | Type | OS | Management Address | Username | Password |
| -------- | ---- | -- | ------------------ | -------- | -------- |
| s01 | switch | cEOS-lab, 4.32.3M | 10.0.1.1 | arista | arista |
| s02 | switch | cEOS-lab, 4.32.3M | 10.0.1.2 | arista | arista |
| l01 | switch | cEOS-lab, 4.32.3M | 10.0.2.1 | arista | arista |
Expand All @@ -61,7 +61,7 @@ This lab has following devices:
## Last Updated

!!! Info "Last reviewed: 26/11/2024"
!!! Info "Last reviewed: 13/01/2025"

Demos and labs reviewed over 6 month age may be outdated.

Expand Down
1 change: 1 addition & 0 deletions labs/cvaas-cvaas-and-avd-demo--evpn-mlag/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Temporary Items
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
!.vscode/terminals.json

# Local History for Visual Studio Code
.history/
Expand Down
50 changes: 50 additions & 0 deletions labs/cvaas-cvaas-and-avd-demo--evpn-mlag/.vscode/terminals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"autorun": true,
"autokill": true,
"env": {
"TERMINAL_READY_MESSAGE": "Please check the README.md and the lab documentation before using the lab.",
"TERMINAL_SHELL": "bash",
"TERMINAL_STATUS_COMMAND": "Cli -p 15 -c 'show version'",
"TERMINAL_READY_COMMAND": "Cli -p 15"
},
"terminals": [
{
"name": "l01",
"icon": "bookmark",
"color": "terminal.ansiRed",
"command": "terminals.sh l01",
"recycle": false,
"open": true,
"focus": true
},
{
"name": "l02",
"icon": "bookmark",
"color": "terminal.ansiRed",
"split": "l01",
"command": "terminals.sh l02",
"recycle": false,
"open": true,
"focus": true
},
{
"name": "h01",
"icon": "code",
"color": "terminal.ansiGreen",
"command": "terminals.sh h01",
"recycle": false,
"open": true,
"focus": true
},
{
"name": "h02",
"icon": "code",
"color": "terminal.ansiGreen",
"split": "h01",
"command": "terminals.sh h02",
"recycle": false,
"open": true,
"focus": true
}
]
}
8 changes: 4 additions & 4 deletions labs/cvaas-cvaas-and-avd-demo--evpn-mlag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
This lab is tested for:

cEOS-lab version: 4.32.3M
Containerlab Version: 0.59.0
Containerlab Version: 0.61.0
Codespace Container Size
CPUs: 8
memory: 32 GB
storage: 64 GB

Last reviewed: 26/11/2024
Last reviewed: 13/01/2025

> Lab Credentials
    Username: arista
Expand All @@ -25,8 +25,8 @@ Please check the lab materials:

This lab has following devices:

| Hostname | Type | OS | Management Address | Login | Password |
| -------- | ---- | -- | ------------------ | ----- | -------- |
| Hostname | Type | OS | Management Address | Username | Password |
| -------- | ---- | -- | ------------------ | -------- | -------- |
| s01 | switch | cEOS-lab, 4.32.3M | 10.0.1.1 | arista | arista |
| s02 | switch | cEOS-lab, 4.32.3M | 10.0.1.2 | arista | arista |
| l01 | switch | cEOS-lab, 4.32.3M | 10.0.2.1 | arista | arista |
Expand Down
2 changes: 1 addition & 1 deletion slides/cvaas-cvaas-and-avd-demo--evpn-mlag.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _paginate: false
```text
Provisioning Workflow Demo
Petr Ankudinov
19/11/2024
13/01/2025
```

![bg right fit](assets/img/avd-logo.webp)
Expand Down

0 comments on commit 95cef9f

Please sign in to comment.