Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Adding Cumulus Image and Proof of Concept Lesson #253

Merged
merged 10 commits into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

## In development

- Added Cumulus PTR demo [#253](https://github.com/nre-learning/nrelabs-curriculum/pull/253)
- Updated collection in BASH lesson file to 9 (PacketPushers)

## v1.0.0 - August 08, 2019


- Replaced all individual snippet indices with 'this' keyword [#221](https://github.com/nre-learning/nrelabs-curriculum/pull/221)
- Rename syringe.yaml to lesson.meta.yaml, and move lessons into descriptive subdirs [#222](https://github.com/nre-learning/nrelabs-curriculum/pull/222)
- Prepare curriculum for collections [#224](https://github.com/nre-learning/nrelabs-curriculum/pull/224)
Expand Down
26 changes: 26 additions & 0 deletions images/cvx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM debian:stable

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qy \
&& apt-get upgrade -qy \
&& apt-get install -y \
bridge-utils \
iproute2 \
python3-ipy \
socat \
screen \
qemu-kvm \
ssh \
tcpdump \
ethtool \
telnet \
procps \
&& rm -rf /var/lib/apt/lists/*

COPY cvx.qcow2 /cvx.qcow2
COPY launch.sh /

EXPOSE 22 161/udp 830 5000 10000-10099
ENTRYPOINT ["/launch.sh"]

11 changes: 11 additions & 0 deletions images/cvx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SHELL=/bin/bash

TARGET_VERSION ?= latest

all: docker

docker:
gsutil cp "gs://nrelabs-curriculum-base-images/cvx/cvx.qcow2" "./cvx.qcow2"
docker build -t antidotelabs/cvx:$(TARGET_VERSION) .
docker push antidotelabs/cvx:$(TARGET_VERSION)

61 changes: 61 additions & 0 deletions images/cvx/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

mount -o rw,remount /sys


ethlist=$(ls /sys/class/net | grep 'net' | grep -v 'eth0')

NETDEVS=""

COUNTER=0
for eth in $ethlist
do

let COUNTER1=COUNTER+1

net="net$COUNTER1"
tap="tap$COUNTER"
bridge=br$net$tap

ip link add $bridge type bridge
ip addr flush dev $net
ip link set $net master $bridge
ip tuntap add dev $tap mode tap
ip link set $tap master $bridge
ip link set $bridge up
ip link set $tap up

# Enable LLDP
echo 16384 > /sys/class/net/$bridge/bridge/group_fwd_mask

NETDEVS="$NETDEVS -netdev tap,id=dev$COUNTER,ifname=$tap,script=no,downscript=no -device virtio-net-pci,netdev=dev$COUNTER,id=swp$COUNTER1,mac=$(random_mac),multifunction=on,addr=6.$COUNTER"
let COUNTER=COUNTER+1
done


screen -d -m socat TCP-LISTEN:22,fork TCP:127.0.0.1:2022
screen -d -m socat UDP-LISTEN:161,fork UDP:127.0.0.1:2161
screen -d -m socat TCP-LISTEN:830,fork TCP:127.0.0.1:2830
screen -d -m socat TCP-LISTEN:8080,fork TCP:127.0.0.1:2880

random_mac () {
hexchars="0123456789abcdef"
end=$( for i in {1..6} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' )

# QEMU OUI space - important to use this
echo 52:54:00$end
}


/usr/bin/qemu-system-x86_64 \
--enable-kvm \
-cpu host \
-display none \
-machine pc \
-m 2048 \
-serial telnet:0.0.0.0:5000,server,nowait \
-drive if=ide,file=/cvx.qcow2,index=0 \
-net nic,model=virtio-net-pci,macaddr=$(random_mac) \
-net user,net=10.0.0.0/24,tftp=/tftpboot,hostfwd=tcp::2022-10.0.0.15:22,hostfwd=udp::2161-10.0.0.15:161,hostfwd=tcp::2830-10.0.0.15:830,hostfwd=tcp::2880-10.0.0.15:8080 \
$NETDEVS

69 changes: 69 additions & 0 deletions lessons/fundamentals/lesson-99-cumulus-demo/lesson.meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
lessonName: Cumulus in NRELabs
lessonId: 90
category: fundamentals
lessondiagram: https://raw.githubusercontent.com/nre-learning/nrelabs-curriculum/v0.3.2/lessons/lesson-99/lessondiagram.png
tier: ptr
prereqs:
- 22 # Python
- 23 # Linux
description: Cumulus in NRELabs
slug: Cumulus demo
tags:
- troubleshooting
- tshoot

endpoints:
- name: linux1
image: antidotelabs/utility
presentations:
- name: cli
port: 22
type: ssh

- name: linux2
image: antidotelabs/utility
presentations:
- name: cli
port: 22
type: ssh

- name: leaf1
image: antidotelabs/cvx
configurationType: python
presentations:
- name: cli
port: 22
type: ssh

- name: leaf2
image: antidotelabs/cvx
configurationType: python
presentations:
- name: cli
port: 22
type: ssh

- name: spine
image: antidotelabs/cvx
configurationType: python
presentations:
- name: cli
port: 22
type: ssh

connections:
- a: spine
b: leaf1
- a: spine
b: leaf2
- a: leaf1
b: linux1
- a: leaf2
b: linux2


stages:
- id: 1
description: Cumulus in NRELabs

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import paramiko
import os
from scp import SCPClient

host=os.environ['SYRINGE_TARGET_HOST']

def createSSHClient(server, port, user, password):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(server, port, user, password)
return client

ssh=createSSHClient(host,22,"root","antidotepassword")
scp=SCPClient(ssh.get_transport())

scp.put('/antidote/stage1/configs/leaf1/interfaces', '/etc/network/interfaces')
scp.put('/antidote/stage1/configs/leaf1/daemons', '/etc/frr/daemons')
scp.put('/antidote/stage1/configs/leaf1/frr.conf', '/etc/frr/frr.conf')


ssh.exec_command('systemctl restart frr.service')
ssh.exec_command('ifreload -a')

scp.close()
ssh.close()



Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zebra=yes
bgpd=yes

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
router bgp 65002
bgp router-id 10.1.1.2
address-family ipv4 unicast
neighbor 10.10.10.1 remote-as 65001
neighbor 10.10.10.1 activate
redistribute connected

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
auto lo
iface lo inet loopback
address 10.1.1.2/32

auto eth0
iface eth0 inet dhcp
vrf mgmt

auto mgmt
iface mgmt
address 127.0.0.1/8
vrf-table auto

auto swp1
allow-uplink swp1
iface swp1 inet static
address 10.10.10.2/30

auto swp2
allow-uplink swp2
iface swp2 inet static
address 10.10.100.1/30

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import paramiko
import os
from scp import SCPClient

host=os.environ['SYRINGE_TARGET_HOST']

def createSSHClient(server, port, user, password):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(server, port, user, password)
return client

ssh=createSSHClient(host,22,"root","antidotepassword")
scp=SCPClient(ssh.get_transport())

scp.put('/antidote/stage1/configs/leaf2/interfaces', '/etc/network/interfaces')
scp.put('/antidote/stage1/configs/leaf2/daemons', '/etc/frr/daemons')
scp.put('/antidote/stage1/configs/leaf2/frr.conf', '/etc/frr/frr.conf')


ssh.exec_command('systemctl restart frr.service')
ssh.exec_command('ifreload -a')

scp.close()
ssh.close()



Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zebra=yes
bgpd=yes

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
router bgp 65003
bgp router-id 10.1.1.3
address-family ipv4 unicast
neighbor 10.10.20.1 remote-as 65001
neighbor 10.10.20.1 activate
redistribute connected

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
auto lo
iface lo inet loopback
address 10.1.1.3/32

auto eth0
iface eth0 inet dhcp
vrf mgmt

auto mgmt
iface mgmt
address 127.0.0.1/8
vrf-table auto

auto swp1
allow-uplink swp1
iface swp1 inet static
address 10.10.20.2/30

auto swp2
allow-uplink swp2
iface swp2 inet static
address 10.10.200.1/30

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import paramiko
import os
from scp import SCPClient

host=os.environ['SYRINGE_TARGET_HOST']

def createSSHClient(server, port, user, password):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(server, port, user, password)
return client

ssh=createSSHClient(host,22,"root","antidotepassword")
scp=SCPClient(ssh.get_transport())

scp.put('/antidote/stage1/configs/spine/interfaces', '/etc/network/interfaces')
scp.put('/antidote/stage1/configs/spine/daemons', '/etc/frr/daemons')
scp.put('/antidote/stage1/configs/spine/frr.conf', '/etc/frr/frr.conf')

ssh.exec_command('systemctl restart frr.service')
ssh.exec_command('ifreload -a')


scp.close()
ssh.close()



Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zebra=yes
bgpd=yes

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
router bgp 65001
bgp router-id 10.1.1.1
address-family ipv4 unicast
neighbor 10.10.10.2 remote-as 65002
neighbor 10.10.10.2 activate
neighbor 10.10.20.2 remote-as 65003
neighbor 10.10.20.2 activate
redistribute connected

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
auto lo
iface lo inet loopback
address 10.1.1.1/32

auto eth0
iface eth0 inet dhcp
vrf mgmt

auto mgmt
iface mgmt
address 127.0.0.1/8
vrf-table auto

auto swp1
allow-uplink swp1
iface swp1 inet static
address 10.10.10.1/30

auto swp2
allow-uplink swp2
iface swp2 inet static
address 10.10.20.1/30

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cumulus in NRELabs!