aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay Kinsella <ray.kinsella@intel.com>2016-12-04 18:21:16 +0000
committerRay Kinsella <ray.kinsella@intel.com>2017-03-29 17:41:57 +0100
commiteae889b38209f58f169356cc2229658fbb616bbd (patch)
tree7d6e1c55d9113b686e2876b77987ef37e27dd276
parentf71b5f990114c0af2b96700a18b397db4ff26c82 (diff)
vpp-bootstrap:
* Updated to VPP 17.01 * Updated README.md * Reduced image requirements to 2 cores & 2048 megs of ram. * Fixed VPP Binary on host to have more modest resource requirements. * XConnect the Containers automagically in VPP on the host. * Added support for python `pip` packages, updated scapy to 2.3.x for VXLAN support. * Using the VPP Binaries from 17.01 stable, instead of head. * Added gdb package to ctwo, so `make debug` will work. * Renamed veth backend interfaces on the host to `veth-c[one,two]`. Change-Id: Ie1a86989733c1eb18041e20a4d268a308ffaebb3 Signed-off-by: Ray Kinsella <ray.kinsella@intel.com>
-rw-r--r--vpp-bootstrap/README.md26
-rw-r--r--vpp-bootstrap/Vagrantfile11
-rw-r--r--vpp-bootstrap/containers/cone.cntr3
-rw-r--r--vpp-bootstrap/containers/ctwo.cntr2
-rwxr-xr-xvpp-bootstrap/containers/ctwo.provision.sh16
-rwxr-xr-xvpp-bootstrap/provision.sh170
6 files changed, 178 insertions, 50 deletions
diff --git a/vpp-bootstrap/README.md b/vpp-bootstrap/README.md
index 67b80ed..a8204e3 100644
--- a/vpp-bootstrap/README.md
+++ b/vpp-bootstrap/README.md
@@ -13,6 +13,30 @@
*
* Copyright (c) 2016 Intel Corporation
*/
+
+# GOAL
+
+The aim of the project is provide a lightweight development environment
+for those looking to quickly start VPP development. Including but not
+limited to training events and workshops.
+
+# COMMITTERS
+
+Ray Kinsella <ray.kinsella@intel.com>
+
# INTRO
+vpp-bootstrap is a vagrant image to create an environment to rapidly
+bootstrap vpp development. All required sources, dependencies and test
+tools are included in the environment.
+
+To build the image, simple do
+
+ vagrant up
+
+# CURRENT STATE
+
+Supports VPP 17.01 on VirtualBox and AWS
+
+# Evolution
-<insert useful content here>
+Support for VPP 17.04.
diff --git a/vpp-bootstrap/Vagrantfile b/vpp-bootstrap/Vagrantfile
index 9438156..fc93751 100644
--- a/vpp-bootstrap/Vagrantfile
+++ b/vpp-bootstrap/Vagrantfile
@@ -2,17 +2,22 @@
# vi: set ft=ruby :
# Copyright (c) 2016 Intel Corporation
+unless Vagrant.has_plugin?("vagrant-reload")
+ raise 'vagrant-reload (plugin) is not installed!'
+end
+
Vagrant.configure(2) do |config|
# Pick the right distro and bootstrap, default is ubuntu1404
- config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
- vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 8)
- vmram=(ENV['VPP_VAGRANT_VMRAM'] || 16384)
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
+ vmram=(ENV['VPP_VAGRANT_VMRAM'] || 2048)
# Define some physical ports for your VMs to be used by DPDK
config.vm.network "private_network", type: "dhcp"
config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"provision.sh") , privileged: false
+ config.vm.provision :reload
# vagrant-cachier caches apt/yum etc to speed subsequent
# vagrant up
diff --git a/vpp-bootstrap/containers/cone.cntr b/vpp-bootstrap/containers/cone.cntr
index 237496c..9c00ec0 100644
--- a/vpp-bootstrap/containers/cone.cntr
+++ b/vpp-bootstrap/containers/cone.cntr
@@ -1,4 +1,5 @@
DESC: This container is used for vpp testing with scapy.
DIST: ubuntu
VER: trusty
-PACKAGES: python-scapy
+PACKAGES: python-pip
+PIP: scapy
diff --git a/vpp-bootstrap/containers/ctwo.cntr b/vpp-bootstrap/containers/ctwo.cntr
index 56a83c8..2a764e2 100644
--- a/vpp-bootstrap/containers/ctwo.cntr
+++ b/vpp-bootstrap/containers/ctwo.cntr
@@ -1,4 +1,4 @@
DESC: This is the vpp build/test container.
DIST: ubuntu
VER: trusty
-PACKAGES: make gcc autotools-dev autoconf linux-headers-kernver
+PACKAGES: make gcc autotools-dev autoconf linux-headers-kernver gdb
diff --git a/vpp-bootstrap/containers/ctwo.provision.sh b/vpp-bootstrap/containers/ctwo.provision.sh
index 2ba66c6..d8e5796 100755
--- a/vpp-bootstrap/containers/ctwo.provision.sh
+++ b/vpp-bootstrap/containers/ctwo.provision.sh
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+VPP_VERSION=v17.01
VPP_DIR=~/vpp
VPP_GIT="https://git.fd.io/vpp"
-#PLATFORM=vpp_lite
-PLATFORM=vpp
+PLATFORM=vpp_lite
echo Cloning $VPP_GIT
git clone $VPP_GIT $VPP_DIR
@@ -23,6 +23,7 @@ git clone $VPP_GIT $VPP_DIR
# Install dependencies
echo Building $VPP_DIR
cd $VPP_DIR
+git checkout -b $VPP_VERSION $VPP_VERSION
make UNATTENDED=yes install-dep
make wipe
@@ -31,10 +32,7 @@ rm -f build-root/.bootstrap.ok
# Build and install packaging
make PLATFORM=$PLATFORM bootstrap
-make PLATFORM=$PLATFORM pkg-deb
-
-# Install VPPP
-(cd ${VPP_DIR}/build-root/;sudo dpkg -i *.deb)
-
-sudo sed -i 's/dpdk {/dpdk {\n\tno-pci\n/' /etc/vpp/startup.conf
-sudo service vpp start
+make PLATFORM=$PLATFORM build
+#not sure why this is needed to called explicitly
+make PLATFORM=$PLATFORM build-vpp-api
+make PLATFORM=$PLATFORM plugins
diff --git a/vpp-bootstrap/provision.sh b/vpp-bootstrap/provision.sh
index 7b52782..d913489 100755
--- a/vpp-bootstrap/provision.sh
+++ b/vpp-bootstrap/provision.sh
@@ -13,58 +13,107 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+PACKAGE_REPO="https://nexus.fd.io/content/repositories/fd.io.stable.1701.ubuntu.trusty.main/"
HOME_DIR="/home/$USER"
+RC_LOCAL="/etc/rc.local"
SSH_OPTIONS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
APT_PROXY_CONF="/etc/apt/apt.conf.d/01proxy"
ENV_FILE="/etc/environment"
UNAMER=$(uname -r)
-DEV_BRIDGE="lxcbr1"
-sudo sysctl -w vm.nr_hugepages=1024
-HUGEPAGES=`sudo sysctl -n vm.nr_hugepages`
-if [ $HUGEPAGES != 1024 ]; then
- echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES. Cannot finish."
- exit
-fi
+# LXC gives backend interfaces horrible names, give them a better name.
+function rename_veth_interface() {
-sudo apt-get -qq update
-sudo apt-get -qq install -y --force-yes lxc bridge-utils
+ local cntr="$1"
+ local nifname="$2"
-echo -e "lxc.network.name=veth0" | sudo tee -a /etc/lxc/default.conf
-echo -e "lxc.network.type = veth" | sudo tee -a /etc/lxc/default.conf
-echo -e "lxc.network.link = lxcbr1" | sudo tee -a /etc/lxc/default.conf
-echo -e "lxc.network.flags = up" | sudo tee -a /etc/lxc/default.conf
-echo -e "lxc.network.hwaddr = 00:17:3e:xx:xx:xx\n" | sudo tee -a /etc/lxc/default.conf
-echo -e "lxc.network.name=veth_link1" | sudo tee -a /etc/lxc/default.conf
+ ifr_index=`sudo lxc-attach -n $cntr -- ip -o link | tail -n 1 | awk -F : '{print $1}'`
+ ifr_index=$((ifr_index+1))
-sudo lxc-checkconfig
+ for dir in /sys/class/net/*/
+ do
+ ifindex=`cat $dir/ifindex`
+ if [ $ifindex == $ifr_index ]
+ then ifname=`basename $dir`
+ fi
+ done
-sudo brctl addbr $DEV_BRIDGE
-sudo ip link set $DEV_BRIDGE up
+ sudo ip link set $ifname down
+ sudo ip link set $ifname name $nifname
+ sudo ip link set $nifname up
+}
-ssh-keygen -t rsa -b 1024 -N "" -f ~/.ssh/id_rsa
-openssh_pubkey=`cat ~/.ssh/id_rsa.pub`
+function add_to_rc_local()
+{
+ local str="$1"
+
+ echo -e "$str" | sudo tee -a $RC_LOCAL
+}
+
+function sudo_exec() {
+
+ CMD="$1"
+ add_to_rc_local="${2:-0}"
+
+ if [ "$add_to_rc_local" == "1" ]; then
+ add_to_rc_local "$CMD"
+ fi
+
+ CMD="sudo $CMD"
+
+ eval "${CMD}"
+}
function lxc_exec() {
cntr="$1"
rCMD="$2"
-
- CMD="sudo lxc-attach -n $cntr -- $rCMD"
+ add_to_rc_local="${3:-0}"
+
+ CMD="lxc-attach -n $cntr -- $rCMD"
echo "$CMD"
- eval "${CMD}"
+ sudo_exec "$CMD" $add_to_rc_local
}
function get_field() {
file="$1"
field="$2"
-
+
value=$(grep $field $file | awk -F : '{print $2}' | sed -e 's/^[ ]*//' | sed -e 's/kernver/"$UNAMER"/')
echo $value
}
-# LXC gives backend interfaces horrible names, give them a better name.
+sudo sysctl -w vm.nr_hugepages=128
+HUGEPAGES=`sudo sysctl -n vm.nr_hugepages`
+if [ $HUGEPAGES != 128 ]; then
+ echo "ERROR: Unable to get 128 hugepages, only got $HUGEPAGES. Cannot finish."
+ exit
+fi
+
+echo "deb $PACKAGE_REPO ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
+sudo apt-get -qq update
+sudo apt-get -qq install -y --force-yes lxc bridge-utils tmux vpp vpp vpp-dpdk-dkms
+
+#Fix VPP on the host to use 128 hugepages
+sudo sed -i 's/vm.nr_hugepages=1024/vm.nr_hugepages=128/' /etc/sysctl.d/80-vpp.conf
+sudo sed -i 's/kernel.shmmax=2147483648/kernel.shmmax=268435456/' /etc/sysctl.d/80-vpp.conf
+
+#Provision containers with two network connections, second connection is unconnected
+echo -e "lxc.network.name=veth0" | sudo tee -a /etc/lxc/default.conf
+echo -e "lxc.network.type = veth" | sudo tee -a /etc/lxc/default.conf
+echo -e "lxc.network.hwaddr = 00:17:3e:xx:xx:xx\n" | sudo tee -a /etc/lxc/default.conf
+echo -e "lxc.network.name=veth_link1" | sudo tee -a /etc/lxc/default.conf
+
+sudo lxc-checkconfig
+
+# update rc.local to be interpreted with bash
+sudo sed -i '1 s/^.*$/#!\/bin\/bash/g' $RC_LOCAL
+# remove the exit 0 from rc.local.
+sudo sed -i 's/exit 0//' $RC_LOCAL
+
+# add rename_veth_interface to /etc/rc.local
+read -r -d '' TMP_RVI <<'EOF'
function rename_veth_interface() {
local cntr="$1"
@@ -85,6 +134,29 @@ function rename_veth_interface() {
sudo ip link set $ifname name $nifname
sudo ip link set $nifname up
}
+EOF
+add_to_rc_local "$TMP_RVI"
+
+# For the moment just cross connect the host, will more clever later.
+read -r -d '' TMP_CCI <<'EOF'
+function cross_connect_interfaces() {
+
+ sudo vppctl create host-interface name veth-cone
+ sudo vppctl create host-interface name veth-ctwo
+ sudo vppctl set int l2 xconnect host-veth-cone host-veth-ctwo
+ sudo vppctl set int l2 xconnect host-veth-ctwo host-veth-cone
+ sudo vppctl set int state host-veth-cone up
+ sudo vppctl set int state host-veth-ctwo up
+}
+EOF
+add_to_rc_local "$TMP_CCI"
+
+ssh-keygen -t rsa -b 1024 -N "" -f ~/.ssh/id_rsa
+openssh_pubkey=`cat ~/.ssh/id_rsa.pub`
+
+#Ensure that virtual bridge comes up after boot
+add_to_rc_local "#autostart vpp on the host"
+sudo_exec "service vpp start" 1
for f in $(ls /vagrant/containers/*.cntr)
do
@@ -92,13 +164,23 @@ do
dist=$(get_field $f DIST)
ver=$(get_field $f VER)
packages=$(get_field $f PACKAGES)
+ pip=$(get_field $f PIP)
provision_file="/vagrant/containers/"$i".provision.sh"
sudo lxc-create -t download -n $i -- --dist $dist --release $ver --arch amd64
- sudo lxc-start -n $i -d
+
+ #autostart container after a reboot (standard lxc way doesn't work).
+ add_to_rc_local "#autostart container $i"
+
+ sudo_exec "lxc-start -n $i -d" 1
lxc_exec $i "resolvconf -d veth0"
- lxc_exec $i "dhclient veth0"
+
+ #dhcp after boot
+ lxc_exec $i "dhclient veth0" 1
+
+ #insert delay to allow completion before starting ssh service
+ add_to_rc_local "sleep 1"
lxc_exec $i "apt-get -qq install -y git openssh-server"
lxc_exec $i "apt-get -qq update"
@@ -122,7 +204,9 @@ do
lxc_exec $i "apt-get -qq install $packages"
- ip_address=$(sudo lxc-ls -f | grep $i | awk '{print $3}')
+ lxc_exec $i "service ssh restart" 1
+
+ ip_address=$(sudo lxc-ls -f | grep $i | awk '{print $5}')
echo $ip_address $i | sudo tee -a /etc/hosts
if [ -s $APT_PROXY_CONF ]
@@ -135,24 +219,40 @@ do
scp $SSH_OPTIONS $ENV_FILE root@$i:$ENV_FILE
fi
-# backend_intr="link_"$cntr
-# rename_veth_interface $i $backend_intr
-# sudo brctl addif $DEV_BRIDGE $backend_intr
+ #rename the backend interface to something sensible
+ rename_veth_interface $i "veth-$i"
+ add_to_rc_local "rename_veth_interface $i 'veth-$i'"
if [ -s $provision_file ]
then
tmpname=$(mktemp)".sh"
scp $SSH_OPTIONS $provision_file $USER@$i:$tmpname
ssh $SSH_OPTIONS $USER@$i "sh -c $tmpname"
- fi
+ fi
+
+ #install any pip packages
+ if [ ! -z "$pip" ]
+ then
+ ssh -t $SSH_OPTIONS $USER@$i "sudo -E pip install $pip"
+ fi
+
done
-echo "List of containers deployed in the dev environment:"
+#cross connect the containers
+add_to_rc_local "sleep 1"
+add_to_rc_local "cross_connect_interfaces"
+
+add_to_rc_local "exit 0"
+
+#setting password to username
+echo "$USER:$USER" | sudo chpasswd
+
+echo -e "List of containers deployed in the dev environment:" | sudo tee -a /etc/motd
for f in $(ls /vagrant/containers/*.cntr)
do
i=$(basename $f | sed s/.cntr//)
desc=$(get_field $f DESC)
- echo $i":\t"$desc
+ echo -e $i":\t"$desc | sudo tee -a /etc/motd
done
-echo "To get access the dev environment, type 'vagrant ssh'"
+echo "To access the environment, type 'vagrant ssh'"