Set proxies in Cloudify container 03/68103/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Mon, 24 Jun 2019 15:21:29 +0000 (17:21 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Tue, 25 Jun 2019 16:07:28 +0000 (18:07 +0200)
add_proxy.sh now modifies Cloudify containers to allow proxies.
It follows "Update and enable Cloudify-based testcases" [1]

[1] https://gerrit.opnfv.org/gerrit/#/c/66909/

Co-Authored-By: Thierry ALLENO <thierry.alleno@orange.com>
Change-Id: I54cfcd73685695c5f66f24acd32f126786acf48e
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit f246dd3889df5302756c9c73d70b346695aca146)

functest/ci/add_proxy.sh

index 3244f24..f815ef0 100644 (file)
@@ -4,28 +4,32 @@ set -e
 
 pushd "${1:-/home/opnfv/functest/images}" > /dev/null
 
+http_proxy=${http_proxy:-http://proxy:8080}
+https_proxy=${https_proxy:-${http_proxy:-http://proxy:8080}}
+ftp_proxy=${ftp_proxy:-${http_proxy:-http://proxy:8080}}
+no_proxy=${no_proxy:-"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"}
+
 images=${images-"\
-cloudify-manager-premium-4.0.1.qcow2 \
 ubuntu-14.04-server-cloudimg-amd64-disk1.img \
 ubuntu-16.04-server-cloudimg-amd64-disk1.img"}
 
 add_proxy () {
     cat << EOF >> "$1"
-http_proxy=${http_proxy:-http://proxy:8080}
-HTTP_PROXY=${http_proxy:-http://proxy:8080}
-https_proxy=${https_proxy:-${http_proxy:-http://proxy:8080}}
-HTTPS_PROXY=${https_proxy:-${http_proxy:-http://proxy:8080}}
-ftp_proxy=${ftp_proxy:-${http_proxy:-http://proxy:8080}}
-FTP_PROXY=${ftp_proxy:-${http_proxy:-http://proxy:8080}}
-no_proxy=${no_proxy:-"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"}
-NO_PROXY=${no_proxy:-"10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"}
+http_proxy=${http_proxy}
+HTTP_PROXY=${http_proxy}
+https_proxy=${https_proxy}
+HTTPS_PROXY=${https_proxy}
+ftp_proxy=${ftp_proxy}
+FTP_PROXY=${ftp_proxy}
+no_proxy=${no_proxy}
+NO_PROXY=${no_proxy}
 EOF
 }
 
 add_proxy_apt () {
     cat << EOF >> "$1"
-Acquire::http::Proxy "${http_proxy:-http://proxy:8080}";
-Acquire::https::Proxy "${https_proxy:-http://proxy:8080}";
+Acquire::http::Proxy "${http_proxy}";
+Acquire::https::Proxy "${https_proxy}";
 EOF
 }
 
@@ -37,17 +41,35 @@ for image in $images; do
     fi
     guestmount -a "${image}" -i --rw "${tmpdir}"
     add_proxy "${tmpdir}/etc/environment"
-    if [[ ${image} == *"cloudify-manager"* ]]; then
-        echo >> "${tmpdir}/etc/sysconfig/cloudify-mgmtworker"
-        add_proxy "${tmpdir}/etc/sysconfig/cloudify-mgmtworker"
-        echo >> "${tmpdir}/etc/sysconfig/cloudify-restservice"
-        add_proxy "${tmpdir}/etc/sysconfig/cloudify-restservice"
-    fi
     if [[ ${image} == "ubuntu"* ]]; then
         add_proxy_apt "${tmpdir}/etc/apt/apt.conf"
     fi
     guestunmount "${tmpdir}"
 done
 
+sudo docker load -i cloudify-docker-manager-community-19.01.24.tar
+dockerfile=${tmpdir}/Dockerfile
+cat << EOF > $dockerfile
+FROM docker-cfy-manager:latest
+ENV HTTP_PROXY "${http_proxy}"
+ENV HTTPS_PROXY "${https_proxy}"
+ENV NO_PROXY "${no_proxy}"
+EOF
+for f in /etc/sysconfig/cloudify-mgmtworker /etc/sysconfig/cloudify-restservice; do \
+    cat << EOF >> $dockerfile
+RUN echo >> $f
+RUN echo "http_proxy=${http_proxy}" >> $f
+RUN echo "https_proxy=${https_proxy}" >> $f
+RUN echo "HTTP_PROXY=${http_proxy}" >> $f
+RUN echo "HTTPS_PROXY=${https_proxy}" >> $f
+RUN echo "no_proxy=${no_proxy}" >> $f
+EOF
+done
+sudo docker build -t docker-cfy-manager -f $dockerfile ${tmpdir}
+sudo docker save \
+    docker-cfy-manager > cloudify-docker-manager-community-19.01.24.tar
+sudo docker rmi docker-cfy-manager
+
+rm "${dockerfile}"
 rmdir "${tmpdir}"
 popd > /dev/null