Skip to content

Commit

Permalink
SONiC 202311 (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvolkmann authored Jul 25, 2024
1 parent 872652e commit 3ae7f59
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 46 deletions.
20 changes: 10 additions & 10 deletions images/sonic/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
FROM ubuntu:22.04
FROM debian:bookworm-slim

ENV LIBGUESTFS_BACKEND=direct
# Check: https://sonic-build.azurewebsites.net/ui/sonic/pipelines
ENV SONIC_REMOTE_IMG=https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202211&platform=vs&target=target%2Fsonic-vs.img.gz
ARG SONIC_BASE_URL=https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202311&platform=vs
ARG SONIC_IMG_URL=${SONIC_BASE_URL}&target=target%2Fsonic-vs.img.gz
ARG FRR_RELOAD_URL=${SONIC_BASE_URL}&target=target%2Fdebs%2Fbullseye%2Ffrr-pythontools_8.5.1-sonic-0_all.deb

RUN apt-get update && \
apt-get --no-install-recommends install --yes \
curl \
linux-image-5.15.0-102-generic \
linux-image-cloud-amd64 \
net-tools \
ovmf \
python3 \
python3-guestfs \
qemu-system-x86 \
telnet \
tini && \
curl --location --output - "${SONIC_REMOTE_IMG}" | gunzip > sonic-vs.img
telnet

ENTRYPOINT ["/usr/bin/tini", "--"]
RUN curl --location --output - "${SONIC_IMG_URL}" | gunzip > sonic-vs.img && \
curl --location --output /frr-pythontools.deb "${FRR_RELOAD_URL}"

COPY config_db.json mirror_tap_to_eth.sh sonic_entrypoint.py /
ENTRYPOINT ["/launch.py"]

CMD ["/usr/bin/python3", "-u", "/sonic_entrypoint.py"]
COPY config_db.json mirror_tap_to_eth.sh launch.py /
10 changes: 9 additions & 1 deletion images/sonic/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
}
},
"FEATURE": {
"gnmi": {
"state": "disabled"
},
"mgmt-framework": {
"state": "disabled"
},
Expand All @@ -24,7 +27,7 @@
"snmp": {
"state": "disabled"
},
"telemetry": {
"teamd": {
"state": "disabled"
}
},
Expand Down Expand Up @@ -68,5 +71,10 @@
"admin_status": "up",
"mtu": "9100"
}
},
"VERSIONS": {
"DATABASE": {
"VERSION": "version_202311_03"
}
}
}
14 changes: 11 additions & 3 deletions images/sonic/sonic_entrypoint.py → images/sonic/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@


class Qemu:
def __init__(self, name: str, memory: str, interfaces: int):
def __init__(self, name: str, smp: str, memory: str, interfaces: int):
self._name = name
self._smp = smp
self._memory = memory
self._interfaces = interfaces
self._p = None
Expand Down Expand Up @@ -46,6 +47,7 @@ def start(self) -> None:
cmd = [
'qemu-system-x86_64',
'-cpu', 'host',
'-smp', self._smp,
'-display', 'none',
'-enable-kvm',
'-machine', 'q35',
Expand Down Expand Up @@ -78,10 +80,15 @@ def initial_configuration(g: GuestFS) -> None:
sonic_target_wants = systemd_system + 'sonic.target.wants/'
g.mkdir_p(sonic_target_wants)

# Copy frr-pythontools into the image
g.copy_in(localpath='/frr-pythontools.deb', remotedir=image + 'rw/')

# Workaround: Speed up lldp startup by remove hardcoded wait of 90 seconds
g.ln_s(linkname=systemd_system + 'aaastatsd.timer', target='/dev/null') # Radius
g.ln_s(linkname=systemd_system + 'featured.timer', target='/dev/null') # Feature handling not necessary
g.ln_s(linkname=systemd_system + 'hostcfgd.timer', target='/dev/null') # After boot Host configuration
g.ln_s(linkname=systemd_system + 'rasdaemon.timer', target='/dev/null') # After boot Host configuration
g.ln_s(linkname=systemd_system + 'tacacs-config.timer', target='/dev/null') # After boot Host configuration
# Started by featured
g.ln_s(linkname=sonic_target_wants + 'lldp.service', target='/lib/systemd/system/lldp.service')

Expand Down Expand Up @@ -137,10 +144,11 @@ def main():
logger = logging.getLogger()

name = os.getenv('CLAB_LABEL_CLAB_NODE_NAME', default='switch')
memory = os.getenv('VM_MEMORY', default='2048')
smp = os.getenv('QEMU_SMP', default='2')
memory = os.getenv('QEMU_MEMORY', default='2048')
interfaces = int(os.getenv('CLAB_INTFS', 0)) + 1

vm = Qemu(name, memory, interfaces)
vm = Qemu(name, smp, memory, interfaces)

logger.info('Prepare disk')
vm.prepare_overlay(BASE_IMG)
Expand Down
7 changes: 4 additions & 3 deletions images/sonic/mirror_tap_to_eth.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Script is taken from https://netdevops.me/2021/transparently-redirecting-packets/frames-between-interfaces/
# Script is taken from https://netdevops.me/2021/transparently-redirecting-packetsframes-between-interfaces/
# Read it for better understanding

set -o errexit
Expand All @@ -12,10 +12,11 @@ TAP_IF=$1
INDEX=${TAP_IF:3:3}

ip link set $TAP_IF up
ip link set $TAP_IF mtu 65000

# create tc eth<->tap redirect rules
tc qdisc add dev eth$INDEX ingress
tc filter add dev eth$INDEX parent ffff: protocol all matchall action mirred egress redirect dev $TAP_IF
tc filter add dev eth$INDEX parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev $TAP_IF

tc qdisc add dev $TAP_IF ingress
tc filter add dev $TAP_IF parent ffff: protocol all matchall action mirred egress redirect dev eth$INDEX
tc filter add dev $TAP_IF parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev eth$INDEX
1 change: 1 addition & 0 deletions inventories/group_vars/sonic/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metal_core_spine_uplinks:

sonic_docker_routing_config_mode: split-unified
sonic_frr_mgmt_framework_config: false
sonic_frr_render: false

sonic_loopback_address: "{{ lo }}"
sonic_mgmtif_ip: "{{ ansible_host }}/16`"
Expand Down
5 changes: 0 additions & 5 deletions roles/sonic/defaults/main.yaml

This file was deleted.

41 changes: 17 additions & 24 deletions roles/sonic/tasks/frr-reload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,27 @@
port: 2605
state: started

- name: Download frr-reload.py
community.docker.docker_container_exec:
- name: Copy frr-pythontools into container
community.docker.docker_container_copy_into:
container: bgp
argv:
- curl
- --location
- "{{ frr_python_url }}"
- --output
- frr-reload.py
chdir: /usr/lib/frr
path: /frr-pythontools.deb
container_path: /root/frr-pythontools.deb
mode: "0655"

- name: Download frr-reload
- name: Install frr-pythontools
community.docker.docker_container_exec:
container: bgp
argv:
- curl
- --location
- "{{ frr_url }}"
- --output
- frr-reload
chdir: /usr/lib/frr
- dpkg
- -i
- frr-pythontools.deb
chdir: /root

- name: Change frr file permissions
community.docker.docker_container_exec:
- name: Place frr-reload
community.docker.docker_container_copy_into:
container: bgp
argv:
- chmod
- "0755"
- frr-reload.py
- frr-reload
chdir: /usr/lib/frr
content: |
#!/bin/sh
exec python3 /usr/lib/frr/frr-reload.py --reload /etc/frr/frr.conf
container_path: /usr/lib/frr/frr-reload
mode: "0755"

0 comments on commit 3ae7f59

Please sign in to comment.