From 4bd6de59955eeb3c5b42340bbb7c0d718de8bcad Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 11 Apr 2016 15:28:11 +0100 Subject: [PATCH] Extract out CNI setup so we can call it from a test --- weave | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/weave b/weave index 17eab19b..709f589a 100755 --- a/weave +++ b/weave @@ -118,7 +118,7 @@ docker_run_options() { } cni_volume_options() { - [ "$1" = "setup" ] && echo -v /etc/cni:/etc/cni -v /opt/cni:/opt/cni + [ "$1" = "setup" -o "$1" = "setup-cni" ] && echo -v /etc/cni:/etc/cni -v /opt/cni:/opt/cni } create_cni_script() { @@ -127,7 +127,7 @@ create_cni_script() { docker run --rm $(docker_run_options) --pid=host -i \\ -e CNI_VERSION -e CNI_COMMAND -e CNI_CONTAINERID -e CNI_NETNS \\ -e CNI_IFNAME -e CNI_ARGS -e CNI_PATH $(cni_volume_options setup) \\ - $PLUGIN_IMAGE "$2" + $PLUGIN_IMAGE $COVERAGE_ARGS $2 EOF chmod a+x "$1" } @@ -141,6 +141,16 @@ create_cni_config() { EOF } +setup_cni() { + if [ -d /opt/cni/bin ] ; then + create_cni_script /opt/cni/bin/weave-net --cni-net + create_cni_script /opt/cni/bin/weave-ipam --cni-ipam + fi + if [ -d /etc/cni/net.d -a ! -f /etc/cni/net.d/10-weave.conf ] ; then + create_cni_config /etc/cni/net.d/10-weave.conf + fi +} + exec_remote() { docker $DOCKER_CLIENT_ARGS run --rm \ $(docker_run_options) \ @@ -1880,13 +1890,10 @@ case "$COMMAND" in for img in $IMAGE $EXEC_IMAGE $PLUGIN_IMAGE ; do docker pull $img done - if [ -d /opt/cni/bin ] ; then - create_cni_script /opt/cni/bin/weave-net --cni-net - create_cni_script /opt/cni/bin/weave-ipam --cni-ipam - fi - if [ -d /etc/cni/net.d -a ! -f /etc/cni/net.d/10-weave.conf ] ; then - create_cni_config /etc/cni/net.d/10-weave.conf - fi + setup_cni + ;; + setup-cni) + setup_cni ;; version) [ $# -eq 0 ] || usage