Skip to content

Commit

Permalink
Merge branch 'aristanetworks:main' into campus-evpnvxlan-dg
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchV85 authored Aug 20, 2024
2 parents 083631b + 16cee82 commit 1e65c1a
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 28 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"name": "AVD Universal",
"image": "ghcr.io/aristanetworks/avd/universal:python3.11-avd-devel"
"image": "ghcr.io/aristanetworks/aclabs/dev:latest"
}
22 changes: 0 additions & 22 deletions .github/workflows/container_build_acl_dev.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/container_build_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Create pre-built container for acLabs development

on:
push:
branches: ['**'] # branches will be filtered in the jobs
paths:
- .github/workflows/container_build_dev.yml
- .github/workflows/container_build_child.yml
- containers/dev/**
workflow_dispatch:
branches: ['**'] # branches will be filtered in the jobs

jobs:
build-demo-container:
# fork - build container from any branch for testing
# parent repo - build on main branch only
if: github.repository != 'aristanetworks/acLabs' || github.ref == 'refs/heads/main'
uses: ./.github/workflows/container_build_child.yml
with:
container_name: "dev"
image_tags: "latest"
from_image: "mcr.microsoft.com/devcontainers/base"
from_variant: "ubuntu-22.04"
username: "vscode"
24 changes: 24 additions & 0 deletions .github/workflows/container_build_host_alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Create alpine host container image

on:
push:
branches: ['**'] # branches will be filtered in the jobs
paths:
- .github/workflows/container_build_host_alpine.yml
- .github/workflows/container_build_child.yml
- containers/host-alpine/**
workflow_dispatch:
branches: ['**'] # branches will be filtered in the jobs

jobs:
build-demo-container:
# fork - build container from any branch for testing
# parent repo - build on main branch only
if: github.repository != 'aristanetworks/acLabs' || github.ref == 'refs/heads/main'
uses: ./.github/workflows/container_build_child.yml
with:
container_name: "host-alpine"
image_tags: "latest"
from_image: "alpine"
from_variant: "latest"
11 changes: 7 additions & 4 deletions .github/workflows/container_build_parent_matrix.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
---
name: build container for CVaaS and AVD Demo, EVPN MLAG
name: build techlib-labs containers

on:
push:
branches: [main]
branches: ['**'] # branches will be filtered in the jobs
paths:
- .github/workflows/container_build_child.yml
- .github/workflows/container_build_parent_matrix.yml
- containers/**
- containers/techlib-labs/**
workflow_dispatch:
branches: [main]
branches: ['**'] # branches will be filtered in the jobs

permissions:
packages: write

jobs:
build-lab-containers:
# fork - build container from any branch for testing
# parent repo - build on main branch only
if: github.repository != 'aristanetworks/acLabs' || github.ref == 'refs/heads/main'
uses: ./.github/workflows/container_build_child.yml
strategy:
matrix:
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions containers/host-alpine/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG FROM_IMAGE
ARG FROM_VARIANT

FROM ${FROM_IMAGE}:${FROM_VARIANT}

RUN apk update && \
apk add libteam && \
apk add open-lldp && \
apk add sudo && \
apk add tcpdump && \
apk add scapy && \
apk add iperf3

RUN adduser -u 1000 -G wheel -D alpine && \
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

COPY ./entrypoint.sh /bin/entrypoint.sh
RUN chmod +x /bin/entrypoint.sh

USER alpine

ENTRYPOINT [ "/bin/entrypoint.sh" ]

CMD []
11 changes: 11 additions & 0 deletions containers/host-alpine/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"build": {
"dockerfile": "./Dockerfile",
"context": ".",
"args": {
"FROM_IMAGE": "${localEnv:FROM_IMAGE}",
"FROM_VARIANT": "${localEnv:FROM_VARIANT}",
"USERNAME": "${localEnv:USERNAME}"
}
}
}
131 changes: 131 additions & 0 deletions containers/host-alpine/.devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/sh

UPLINK='eth'

# TMODE is expected to be set via the containerlab topology file prior to deployment
# Expected values are "lacp" or "static" or "active-backup" which will bond eth1 and eth2
if [ -z "$TMODE" ]; then
TMODE='none'
fi

# TACTIVE and TBACKUP to be set via the containerlab topology file for active-backup runner
# expected values are "eth1" or "eth2" default is "eth1" active and "eth2" backup
if [ -z "$TACTIVE" ]; then
TACTIVE='eth1'
TBACKUP='eth2'
elif [ "$TACTIVE" == 'eth1' ]; then
TBACKUP='eth2'
elif [ "$TACTIVE" == 'eth2' ]; then
TBACKUP='eth1'
fi

echo "teaming mode is " $TMODE

#######################
# Re-run script as sudo
#######################

if [ "$(id -u)" != "0" ]; then
exec sudo --preserve-env=TMODE,TACTIVE,TBACKUP "$0" "$@"
fi

##########################
# Check operation status
##########################

check=$( cat /sys/class/net/eth1/operstate 2>/dev/null )

while [ "up" != "$check" ] ; do
echo "waiting for interface to come up"
check=$( cat /sys/class/net/eth1/operstate 2>/dev/null )
done

check=$( cat /sys/class/net/eth2/operstate 2>/dev/null )

while [ "up" != "$check" ] ; do
echo "waiting for interface to come up"
check=$( cat /sys/class/net/eth1/operstate 2>/dev/null )
done

cat /sys/class/net/eth1/operstate
cat /sys/class/net/eth1/operstate

###############
# Enabling LLDP
###############

lldpad -d
for i in `ls /sys/class/net/ | grep 'eth\|ens\|eno'`
do
lldptool set-lldp -i $i adminStatus=rxtx
lldptool -T -i $i -V sysName enableTx=yes
lldptool -T -i $i -V portDesc enableTx=yes
lldptool -T -i $i -V sysDesc enableTx=yes
done

################
# Teaming setup
################

cat << EOF > /home/alpine/teamd-lacp.conf
{
"device": "team0",
"runner": {
"name": "lacp",
"active": true,
"fast_rate": true,
"tx_hash": ["eth", "ipv4", "ipv6"]
},
"link_watch": {"name": "ethtool"},
"ports": {"eth1": {}, "eth2": {}}
}
EOF

cat << EOF > /home/alpine/teamd-static.conf
{
"device": "team0",
"runner": {"name": "roundrobin"},
"ports": {"eth1": {}, "eth2": {}}
}
EOF

cat << EOF > /home/alpine/teamd-active-backup.conf
{
"device": "team0",
"runner": {"name": "activebackup"},
"link_watch": {"name": "ethtool"},
"ports": {
"$TACTIVE": {
"prio": 100
},
"$TBACKUP": {
"prio": -10
}
}
}
EOF

if [ "$TMODE" == 'lacp' ]; then
TARG='/home/alpine/teamd-lacp.conf'
elif [ "$TMODE" == 'static' ]; then
TARG='/home/alpine/teamd-static.conf'
elif [ "$TMODE" == 'active-backup' ]; then
TARG='/home/alpine/teamd-active-backup.conf'
fi

if [ "$TMODE" == 'lacp' ] || [ "$TMODE" == 'static' ] || [ "$TMODE" == 'active-backup' ]; then
teamd -v
teamd -k -f $TARG
ip link set eth1 down
ip link set eth2 down
teamd -d -r -f $TARG

ip link set team0 up
UPLINK="team"
fi

#####################
# Enter sleeping loop
#####################

while sleep 3600; do :; done

0 comments on commit 1e65c1a

Please sign in to comment.