-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfrr_compiled.py
108 lines (88 loc) · 3.51 KB
/
frr_compiled.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from base import *
from frr import FRRoutingTarget
class FRRoutingCompiled(Container):
CONTAINER_NAME = None
GUEST_DIR = '/root/config'
def __init__(self, host_dir, conf, image='bgperf/frr_c'):
super(FRRoutingCompiled, self).__init__(self.CONTAINER_NAME, image, host_dir, self.GUEST_DIR, conf)
@classmethod
def build_image(cls, force=False, tag='bgperf/frr_c', checkout='stable/8.0', nocache=False):
# copied from https://github.com/FRRouting/frr/blob/master/docker/ubuntu20-ci/Dockerfile
cls.dockerfile = '''
FROM ubuntu:20.04
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
# Update Ubuntu Software repository
RUN apt update && \
apt-get install -y \
git autoconf automake libtool make libreadline-dev texinfo \
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \
libc-ares-dev python3-dev python-ipaddress python3-sphinx \
install-info build-essential libsnmp-dev perl \
libcap-dev python2 libelf-dev \
sudo gdb curl iputils-ping time \
libgrpc++-dev libgrpc-dev protobuf-compiler-grpc \
lua5.3 liblua5.3-dev \
mininet iproute2 iperf \
linux-tools-common linux-tools-generic linux-tools-5.11.0-38-generic && \
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output /tmp/get-pip.py && \
python2 /tmp/get-pip.py && \
rm -f /tmp/get-pip.py && \
pip2 install ipaddr && \
pip2 install "pytest<5" && \
pip2 install "scapy>=2.4.2" && \
pip2 install exabgp==3.4.17
RUN groupadd -r -g 92 frr && \
groupadd -r -g 85 frrvty && \
adduser --system --ingroup frr --home /home/frr \
--gecos "FRR suite" --shell /bin/bash frr && \
usermod -a -G frrvty frr && \
useradd -d /var/run/exabgp/ -s /bin/false exabgp && \
echo 'frr ALL = NOPASSWD: ALL' | tee /etc/sudoers.d/frr && \
mkdir -p /home/frr && chown frr.frr /home/frr
#for libyang 2
RUN apt-get install -y cmake libpcre2-dev
#USER frr:frr
# build and install libyang2
RUN cd && \
git clone https://github.com/CESNET/libyang.git && \
cd libyang && \
git checkout v2.0.0 && \
mkdir build; cd build && \
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_BUILD_TYPE:String="Release" .. && \
make -j $(nproc) && \
sudo make install
RUN cd && git clone https://github.com/FRRouting/frr.git -b frr-8.0 frr
RUN cd && ls -al && ls -al frr
RUN ls ~/frr/
RUN cd ~/frr && \
./bootstrap.sh && \
./configure \
--prefix=/usr \
--localstatedir=/var/run/frr \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
--enable-vtysh \
--enable-grpc \
--enable-pimd \
--enable-sharpd \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
--enable-vty-group=frrvty \
--enable-snmp=agentx \
--enable-scripting \
--with-pkg-extra-version=-bgperf && \
make -j $(nproc) && \
sudo make install
#RUN sudo mkdir /etc/frr && sudo chown frr:frr /etc/frr && \
# sudo mkdir -p /root/config && sudo chown frr:frr /root/config
'''.format(checkout)
print("FRRoutingCompiled")
super(FRRoutingCompiled, cls).build_image(force, tag, nocache)
class FRRoutingCompiledTarget(FRRoutingCompiled, FRRoutingTarget):
CONTAINER_NAME = 'bgperf_frrouting_compiled_target'
def __init__(self, host_dir, conf, image='bgperf/frr_c'):
super(FRRoutingTarget, self).__init__(host_dir, conf, image='bgperf/frr_c')