summaryrefslogtreecommitdiffstats
path: root/examples/docker/utils.sh
diff options
context:
space:
mode:
authorMichal Cmarada <michal.cmarada@pantheon.tech>2018-06-15 10:37:14 +0200
committerMichal Cmarada <michal.cmarada@pantheon.tech>2018-06-20 08:29:14 +0200
commit1528ed5d01ddd8a0de14711de59861d16f727a3e (patch)
treedefc318c886c8673161b2cae43d6fa097b8a0772 /examples/docker/utils.sh
parentb77a5725338dc700873b36c98af85d70acd7bbe4 (diff)
Add SRv6 5 node docker demo
This demo is intended to test SRv6 implementation. There are two options how to run the demo. First one is to use VPP only configuration and the second one uses honeycomb to configure SRv6 on nodes. For detailed information about the demo read documentation in ./asciidoc/Readme.adoc file. Follow the instructions to run the demo and use provided commands to verify the operation of VPP nodes. Change-Id: I7d17db0096cc48b06e9148e7c78faaf9d7b8a97d Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'examples/docker/utils.sh')
-rwxr-xr-xexamples/docker/utils.sh88
1 files changed, 74 insertions, 14 deletions
diff --git a/examples/docker/utils.sh b/examples/docker/utils.sh
index 91e18a6b6..6c90e88c4 100755
--- a/examples/docker/utils.sh
+++ b/examples/docker/utils.sh
@@ -4,12 +4,19 @@
#
# $1 - container name
# $2 - image name
+# $3 - cpu allocation (default = 1.0)
#
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
+ if [ -z "$3" ]
+ then
+ cpu="1.0"
+ else
+ cpu=$3
+ fi
+ echo "Creating $container_name from $image_name, cpu allocation: $cpu"
+ docker run -dt --cpus=${cpu} --privileged --name=${container_name} ${image_name} /bin/bash
}
# Starts container
@@ -26,15 +33,67 @@ function start_container {
echo "Starting container $container_name"
# Remove namespace if it was present
- ip netns del $container_name
+ ip netns del ${container_name} 2> /dev/null
# Start container
- docker start $container_name
+ 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)"
+ pid=$(docker inspect -f '{{.State.Pid}}' ${container_name})
+ sudo mkdir -p /var/run/netns
+ sudo ln -sf /proc/${pid}/ns/net /var/run/netns/${container_name}
+ echo "Container $container_name started successfully (pid=$pid)"
+}
+
+# Starts vpp in container
+#
+# $1 - container name
+#
+function start_vpp_in_container {
+ container=$1
+ echo "Starting vpp in $container"
+
+ # Start VPP in container
+ sudo docker exec -d ${container} ./vpp/start.sh
+ result="stopped"
+ echo -e "Waiting for vpp in ${container} to start\n"
+ while [ "$result" != "started" ]
+ do
+ found=`sudo docker exec ${container} vppctl sh int 2> /dev/null |grep "local0"`
+ if [[ ${found} = *"local0"* ]]; then
+ result="started"
+ fi
+ echo -ne "."
+ sleep 1
+ done
+
+ echo -e "\nVPP in $container started successfully"
+}
+
+# Starts vpp in container
+#
+# $1 - container name
+#
+function start_hc_in_container {
+ container=$1
+ echo "Starting hc in $container"
+
+ # Start HC in container
+ sudo docker exec -d ${container} ./honeycomb/start.sh
+ match="Honeycomb started successfully!"
+ result="stopped"
+ echo "Waiting for hc in ${container} to start"
+ while [ "$result" != "started" ]
+ do
+ found=`sudo docker exec ${container} tail /var/log/honeycomb/honeycomb.log 2> /dev/null | grep "${match}"`
+
+ if [[ ${found} = *"${match}"* ]]; then
+ result="started"
+ fi
+ echo -ne "."
+ sleep 1
+ done
+ echo -e "\nHC in $container started successfully"
}
# Links two containers using a veth pair.
@@ -49,19 +108,20 @@ function create_link {
if1=$2
if2=$3
container2=$4
- echo "Creating link from $container1($if1) to $container2($if2)"
- ip link add $if1 type veth peer name $if2
+ echo -ne "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
+ 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
+ ip netns exec ${container1} ip link set ${if1} up
+ ip netns exec ${container2} ip link set ${if2} up
# Set interfaces mtu to 9000 to match default VPP mtu values
ip netns exec ${container1} ifconfig ${if1} mtu 9000
ip netns exec ${container2} ifconfig ${if2} mtu 9000
- echo "Link created successfully"
+
+ echo " -> done."
}