Generate tutorial p4vm with a specific ONOS version
Also:
- Updated Bazel version
- Removed non-working code to auto-login user and disable screen saver
- Reduce size by doing a shallow clone of ONOS
Change-Id: Ie6efc3ebd6766164e7051f28dff89046141afa7f
diff --git a/tools/dev/p4vm/README.md b/tools/dev/p4vm/README.md
index 96cac47..b55793e 100644
--- a/tools/dev/p4vm/README.md
+++ b/tools/dev/p4vm/README.md
@@ -1,7 +1,7 @@
# ONOS-P4 Developer Virtual Machine
This directory contains files necessary to build and provision a VM to test and
-develop ONOS support for P4 Runtime.
+develop ONOS support for P4Runtime.
For more information on P4 support in ONOS please visit the following web page:
<https://wiki.onosproject.org/x/FYnV>
@@ -20,7 +20,7 @@
### Tutorial VM
It is possible to generate a variant of the VM to be used during tutorials. This
-version of the VM comes with a Lubuntu desktop environment and various code
+version of the VM comes with a desktop environment and various code
editors with P4 syntax highlighting (vim, Sublime Text, and Atom).
## Recommended system requirements
@@ -66,8 +66,8 @@
To build the VM you will need the following software installed in your host
machine:
-- [Vagrant](https://www.vagrantup.com/) (tested v2.1.1)
-- [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (tested with v5.2.10)
+- [Vagrant](https://www.vagrantup.com/) (tested v2.2.2)
+- [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (tested with v5.2.22)
Optionally, to export the VM as an OVA package you will also need
[sshpass](https://gist.github.com/arunoda/7790979).
diff --git a/tools/dev/p4vm/root-bootstrap.sh b/tools/dev/p4vm/root-bootstrap.sh
index cf90ea2..0c3302c 100755
--- a/tools/dev/p4vm/root-bootstrap.sh
+++ b/tools/dev/p4vm/root-bootstrap.sh
@@ -1,10 +1,19 @@
#!/bin/bash
set -xe
+ONOS_BRANCH_DEV="master"
+ONOS_BRANCH_TUTORIAL="onos-1.14"
+BAZEL_VER="0.19.2"
+
VM_TYPE=${1:-dev}
-BAZEL_VER="0.15.2"
-BAZEL_SH="bazel-${BAZEL_VER}-installer-linux-x86_64.sh"
+if [[ ${VM_TYPE} = "tutorial" ]]
+then
+ ONOS_BRANCH=${ONOS_BRANCH_TUTORIAL}
+else
+ ONOS_BRANCH=${ONOS_BRANCH_DEV}
+fi
+
# Create user sdn
useradd -m -d /home/sdn -s /bin/bash sdn
echo "sdn:rocks" | chpasswd
@@ -13,7 +22,7 @@
usermod -aG vboxsf sdn
update-locale LC_ALL="en_US.UTF-8"
-if [ ${VM_TYPE} = "tutorial" ]
+if [[ ${VM_TYPE} = "tutorial" ]]
then
su sdn <<'EOF'
cd /home/sdn
@@ -58,6 +67,7 @@
DEBIAN_FRONTEND=noninteractive apt-get -yq install wireshark
# Install Bazel
+BAZEL_SH="bazel-${BAZEL_VER}-installer-linux-x86_64.sh"
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_SH}
chmod +x ${BAZEL_SH}
./${BAZEL_SH}
@@ -76,5 +86,5 @@
su sdn <<'EOF'
cd /home/sdn
-bash /vagrant/user-bootstrap.sh
+bash /vagrant/user-bootstrap.sh ${ONOS_BRANCH}
EOF
diff --git a/tools/dev/p4vm/tutorial-bootstrap.sh b/tools/dev/p4vm/tutorial-bootstrap.sh
index 8f4b5b8..6cff71b 100755
--- a/tools/dev/p4vm/tutorial-bootstrap.sh
+++ b/tools/dev/p4vm/tutorial-bootstrap.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Installs Lubuntu desktop and code editors.
+# Installs desktop utilities and code editors.
# Largely inspired by the P4.org tutorial VM scripts:
# https://github.com/p4lang/tutorials/
@@ -54,26 +54,7 @@
sublime-text-installer \
vim
-# Disable screensaver
-gsettings set org.gnome.desktop.screensaver lock-delay 3600
-gsettings set org.gnome.desktop.screensaver lock-enabled false
-gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
-
-# Automatically log into the SDN user
-cat << EOF | sudo tee /etc/lightdm/lightdm.conf
-[SeatDefaults]
-autologin-user=sdn
-EOF
-
-# Vim
-cd /home/sdn
-mkdir -p .vim
-mkdir -p .vim/ftdetect
-mkdir -p .vim/syntax
-echo "au BufRead,BufNewFile *.p4 set filetype=p4" >> .vim/ftdetect/p4.vim
-echo "set bg=dark" >> .vimrc
-wget https://github.com/p4lang/tutorials/blob/master/vm/p4.vim
-mv p4.vim .vim/syntax/p4.vim
+# TODO: Disable screensaver and automatically log into the SDN user
# Sublime
cd /home/sdn
diff --git a/tools/dev/p4vm/user-bootstrap.sh b/tools/dev/p4vm/user-bootstrap.sh
index a3af30b..17d3b10 100755
--- a/tools/dev/p4vm/user-bootstrap.sh
+++ b/tools/dev/p4vm/user-bootstrap.sh
@@ -1,12 +1,14 @@
#!/bin/bash
set -xe
+ONOS_BRANCH=${1:-master}
+
cp /etc/skel/.bashrc ~/
cp /etc/skel/.profile ~/
cp /etc/skel/.bash_logout ~/
# ONOS
-git clone https://github.com/opennetworkinglab/onos.git
+git clone https://github.com/opennetworkinglab/onos.git --depth 1 -b ${ONOS_BRANCH}
tee -a ~/.bashrc <<EOF
# ONOS
@@ -49,7 +51,7 @@
git clone https://github.com/opennetworkinglab/fabric-p4test.git
# Set Python path for bmv2 in fabric.p4
-echo 'export PYTHONPATH=$PYTHONPATH:~/onos/tools/dev/mininet/bmv2.py' >> ~/.bashrc
+echo 'export PYTHONPATH=$PYTHONPATH:$ONOS_ROOT/tools/dev/mininet' >> ~/.bashrc
# FIXME: for some reason protobuf python bindings are not properly installed
cd ~/p4tools/protobuf/python