support for Bottlenecks soak throughputs
[yardstick.git] / nsb_setup.sh
1 #!/usr/bin/env bash
2 # Copyright (c) 2017 Intel Corporation.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # OPENRC handling has to be first due no_proxy
17 if [ $# -eq 1 ]; then
18     OPENRC=$(readlink -f -- "$1")
19     extra_args="${extra_args} -e openrc_file=${OPENRC}"
20     source "${OPENRC}"
21     CONTROLLER_IP=$(echo ${OS_AUTH_URL} | sed -ne "s#http://\([0-9a-zA-Z.\-]*\):*[0-9]*/.*#\1#p")
22 fi
23
24 env_http_proxy=$(sed -ne "s/^http_proxy=[\"\']\(.*\)[\"\']/\1/p" /etc/environment)
25 if [[ -z ${http_proxy} ]] && [[ ! -z ${env_http_proxy} ]]; then
26     export http_proxy=${env_http_proxy}
27 fi
28 env_https_proxy=$(sed -ne "s/^https_proxy=[\"\']\(.*\)[\"\']/\1/p" /etc/environment)
29 if [[ -z ${https_proxy} ]] && [[ ! -z ${env_https_proxy} ]]; then
30     export https_proxy=${env_https_proxy}
31 fi
32
33 # if http[s]_proxy is set (from env or /etc/environment) prepare proxy for ansible
34 if [[ ! -z ${http_proxy} ]] || [[ ! -z ${https_proxy} ]]; then
35     export no_proxy="localhost,127.0.0.1,${CONTROLLER_IP},${no_proxy}"
36     extra_args="${extra_args} -e @/tmp/proxy.yml "
37
38     cat <<EOF > /tmp/proxy.yml
39 ---
40 proxy_env:
41   http_proxy: ${http_proxy}
42   https_proxy: ${https_proxy}
43   no_proxy: ${no_proxy}
44 EOF
45
46     mkdir -p /etc/systemd/system/docker.service.d
47     cat <<EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
48 ---
49 [Service]
50 Environment="HTTP_PROXY=${http_proxy}" "HTTPS_PROXY=${https_proxy}" "NO_PROXY=${no_proxy}"
51 EOF
52
53     systemctl daemon-reload
54     systemctl restart docker
55 fi
56
57 apt-get update > /dev/null 2>&1
58 pkg=(python-pip build-essential libssl-dev libffi-dev python3-dev python-dev)
59 for i in "${pkg[@]}"; do
60     dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
61     if [  "$?" -eq "1" ]; then
62         apt-get -y install "${i}";
63     fi
64 done
65
66 pip install ansible==2.4.2 shade==1.22.2 docker-py==1.10.6
67
68 ANSIBLE_SCRIPTS="ansible"
69
70 cd ${ANSIBLE_SCRIPTS} &&\
71 ansible-playbook \
72          -e img_property="nsb" \
73          -e YARD_IMG_ARCH='amd64' ${extra_args}\
74          -i yardstick-install-inventory.ini nsb_setup.yml