summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/Dockerfile30
-rw-r--r--docker/Readme.txt15
-rwxr-xr-xdocker/copy_packages.sh4
-rwxr-xr-xdocker/create_image.sh4
-rwxr-xr-xdocker/honeycomb/kill.sh3
-rwxr-xr-xdocker/honeycomb/start.sh4
-rw-r--r--docker/packages/.gitignore2
-rwxr-xr-xdocker/remove_all_containers.sh9
-rwxr-xr-xdocker/remove_all_images.sh4
-rwxr-xr-xdocker/remove_hc2vpp_containers.sh11
-rwxr-xr-xdocker/remove_hc2vpp_image.sh4
-rwxr-xr-xdocker/start_hc2vpp_container.sh6
-rwxr-xr-xdocker/test/docker_ip.sh5
-rwxr-xr-xdocker/test/show_interfaces_state.sh15
-rwxr-xr-xdocker/utils.sh63
-rwxr-xr-xdocker/vpp/kill.sh3
-rwxr-xr-xdocker/vpp/start.sh3
17 files changed, 185 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100755
index 000000000..89be700a8
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,30 @@
+FROM ubuntu:16.04
+
+WORKDIR /hc2vpp
+
+ADD . /hc2vpp
+
+RUN apt-get update && apt-get install -y \
+ `# Networking utils` \
+ iproute2 iputils-ping net-tools \
+ `# VPP package dependencies` \
+ libnuma1 libssl1.0.0 \
+ `# Honeycomb package dependencies` \
+ openjdk-8-jre-headless \
+\
+`# Install packages` \
+\
+&& dpkg -i packages/vpp-lib_*.deb \
+&& dpkg -i packages/vpp_*.deb \
+&& dpkg -i packages/vpp-plugins_*.deb \
+&& dpkg -i packages/vpp-api-java*.deb \
+&& dpkg -i packages/honeycomb_*.deb \
+\
+`# Disable DPDK for PCI devices` \
+\
+&& echo "dpdk {\n no-pci\n}" >> /etc/vpp/startup.conf \
+\
+`# Reduce image size` \
+\
+&& rm -rf /var/lib/apt/lists/* `# clear apt cache` \
+&& rm -rf packages
diff --git a/docker/Readme.txt b/docker/Readme.txt
new file mode 100644
index 000000000..e6bd19578
--- /dev/null
+++ b/docker/Readme.txt
@@ -0,0 +1,15 @@
+# 1) Copy vpp and hc2vpp packages to docker/packages dir
+
+# 2) Build hc2vpp image
+./create_image.sh
+
+# 3) Create & start container
+./start_hc2vpp_container.sh vpp1
+
+# 4) Start vpp & honeycomb
+docker exec -it vpp1 bash
+./vpp/start.sh
+./honeycomb/start.sh
+
+# 5) Test
+./test/show_interfaces_state.sh vpp1
diff --git a/docker/copy_packages.sh b/docker/copy_packages.sh
new file mode 100755
index 000000000..79d1ed5d1
--- /dev/null
+++ b/docker/copy_packages.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Copies locally-built vpp and hc2vpp packages
+cp ~/vpp/build-root/*.deb ../packaging/deb/xenial/*.deb packages/ \ No newline at end of file
diff --git a/docker/create_image.sh b/docker/create_image.sh
new file mode 100755
index 000000000..e00a48cd6
--- /dev/null
+++ b/docker/create_image.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Build docker image with vpp and hc2vpp installed
+docker build -t hc2vpp -f Dockerfile .
diff --git a/docker/honeycomb/kill.sh b/docker/honeycomb/kill.sh
new file mode 100755
index 000000000..5d6d40bcb
--- /dev/null
+++ b/docker/honeycomb/kill.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+/opt/honeycomb/honeycomb-kill
diff --git a/docker/honeycomb/start.sh b/docker/honeycomb/start.sh
new file mode 100755
index 000000000..3aca79dd8
--- /dev/null
+++ b/docker/honeycomb/start.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Start honeycomb in background
+/opt/honeycomb/honeycomb-start
diff --git a/docker/packages/.gitignore b/docker/packages/.gitignore
new file mode 100644
index 000000000..6708b4347
--- /dev/null
+++ b/docker/packages/.gitignore
@@ -0,0 +1,2 @@
+# Do not store packages used by Dockerfile in the repo
+*.deb \ No newline at end of file
diff --git a/docker/remove_all_containers.sh b/docker/remove_all_containers.sh
new file mode 100755
index 000000000..7327f91e6
--- /dev/null
+++ b/docker/remove_all_containers.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+ids=$(docker ps -aq)
+
+# Stop all containers
+docker stop $ids
+
+# Delete all containers
+docker rm $ids
diff --git a/docker/remove_all_images.sh b/docker/remove_all_images.sh
new file mode 100755
index 000000000..c38cd7613
--- /dev/null
+++ b/docker/remove_all_images.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Delete all images
+docker rmi $(docker images -q)
diff --git a/docker/remove_hc2vpp_containers.sh b/docker/remove_hc2vpp_containers.sh
new file mode 100755
index 000000000..c1fbf705a
--- /dev/null
+++ b/docker/remove_hc2vpp_containers.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+ids=$(docker ps -aq --filter ancestor=hc2vpp)
+
+# Stop all hc2vpp based containers
+echo "Stopping containers: $ids"
+docker stop $ids
+
+# Delete all hc2vpp based containers
+echo "Removing containers: $ids"
+docker rm $ids
diff --git a/docker/remove_hc2vpp_image.sh b/docker/remove_hc2vpp_image.sh
new file mode 100755
index 000000000..f08bc5fe0
--- /dev/null
+++ b/docker/remove_hc2vpp_image.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Delete all images
+docker rmi hc2vpp
diff --git a/docker/start_hc2vpp_container.sh b/docker/start_hc2vpp_container.sh
new file mode 100755
index 000000000..820fa021d
--- /dev/null
+++ b/docker/start_hc2vpp_container.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Create & start container
+# $1 - container name
+docker run -dt --privileged --name=$1 hc2vpp
+docker start $1
diff --git a/docker/test/docker_ip.sh b/docker/test/docker_ip.sh
new file mode 100755
index 000000000..1e3bc997d
--- /dev/null
+++ b/docker/test/docker_ip.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Obtain IP address of the container
+# See http://blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker/
+docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
diff --git a/docker/test/show_interfaces_state.sh b/docker/test/show_interfaces_state.sh
new file mode 100755
index 000000000..dc868dbea
--- /dev/null
+++ b/docker/test/show_interfaces_state.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Obtain IP of the container
+# $1 - container name
+ip=$($(dirname $0)/docker_ip.sh $1)
+url="https://$ip:8445/restconf/operational/ietf-interfaces:interfaces-state/"
+echo "GET $url"
+
+# Show interfaces-state
+curl --insecure -X GET $url \
+ -H 'authorization: Basic YWRtaW46YWRtaW4=' \
+ -H 'cache-control: no-cache' \
+ -H 'content-type: application/json'
+
+echo
diff --git a/docker/utils.sh b/docker/utils.sh
new file mode 100755
index 000000000..7b4674752
--- /dev/null
+++ b/docker/utils.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# Creates named container from given image.
+#
+# $1 - container name
+# $2 - image name
+#
+function create_container {
+ container_name=$1
+ image_name=$2
+ echo "Creating $container_name from $image_name"
+ docker run -dt --privileged --name=$container_name $image_name
+}
+
+# Starts container
+# and adds container's network namespace
+# to the linux runtime data (/var/run).
+#
+# $1 - container name
+#
+# See:
+# https://platform9.com/blog/container-namespaces-deep-dive-container-networking/
+#
+function start_container {
+ container_name=$1
+ echo "Starting container $container_name"
+
+ # Remove namespace if it was present
+ ip netns del $container_name
+
+ # Start container
+ docker start $container_name
+
+ # Make container's network namespaces accessible using ip netns
+ pid=$(docker inspect -f '{{.State.Pid}}' $container_name)
+ ln -s /proc/$pid/ns/net /var/run/netns/$container_name
+ echo "Container $container_name started sucessfully (pid=$pid)"
+}
+
+# Links two containers using a veth pair.
+#
+# $1 - name of the container A
+# $2 - name of the veth endpoint that belongs to A
+# $3 - name of the veth endpoint that belongs to B
+# $4 - name of the container B
+#
+function create_link {
+ container1=$1
+ if1=$2
+ if2=$3
+ container2=$4
+ echo "Creating link from $container1($if1) to $container2($if2)"
+ ip link add $if1 type veth peer name $if2
+
+ # Move veth endpoints to corresponding namespaces
+ ip link set $if1 netns $container1
+ ip link set $if2 netns $container2
+
+ # Bring interfaces up
+ ip netns exec $container1 ip link set $if1 up
+ ip netns exec $container2 ip link set $if2 up
+ echo "Link created successfully"
+}
diff --git a/docker/vpp/kill.sh b/docker/vpp/kill.sh
new file mode 100755
index 000000000..329d201ec
--- /dev/null
+++ b/docker/vpp/kill.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ps -ef | grep vpp | awk '{print $2}'| xargs kill
diff --git a/docker/vpp/start.sh b/docker/vpp/start.sh
new file mode 100755
index 000000000..6b1899fdd
--- /dev/null
+++ b/docker/vpp/start.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+vpp -c /etc/vpp/startup.conf &