summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryaoguang wang <sunshine.wang@huawei.com>2016-04-26 01:33:20 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-04-26 01:33:20 +0000
commit4488b9d07f45c54d81f44913c9f5ec6f9bfe6086 (patch)
treecd3e825ddc8551cf6b60750fb16deb5ac00876ae
parent911d39ce7a8b45ab8b6d7dd2ef1feb1a30ca4646 (diff)
parent514ad1b0b8fea733bdf9dacfe8d9006aa882fd10 (diff)
Merge "obtain openstack creds in container"
-rw-r--r--ci/docker/Dockerfile1
-rwxr-xr-xci/prepare_env.sh58
-rwxr-xr-xcommon.sh2
3 files changed, 60 insertions, 1 deletions
diff --git a/ci/docker/Dockerfile b/ci/docker/Dockerfile
index 2c243792..f5ac0e86 100644
--- a/ci/docker/Dockerfile
+++ b/ci/docker/Dockerfile
@@ -18,6 +18,7 @@ ENV REPOS_DIR /home/opnfv
# Bottlenecks repo
ENV BOTTLENECKS_REPO_DIR ${REPOS_DIR}/bottlenecks
ENV RELENG_REPO_DIR ${REPOS_DIR}/releng
+ENV creds ${BOTTLENECKS_REPO_DIR}/config/openstack.creds
#new test suite required packages can be added here
RUN apt-get update && apt-get install -y \
diff --git a/ci/prepare_env.sh b/ci/prepare_env.sh
new file mode 100755
index 00000000..a5aef66d
--- /dev/null
+++ b/ci/prepare_env.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+###############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+BASEDIR=`dirname $0`
+source ${BASEDIR}/../common.sh
+
+info "============ Preparing bottlenecks environment ==========="
+
+# definition of available installer names
+INSTALLERS=(fuel compass apex joid)
+
+if [ ! -f ${BOTTLENECKS_REPO_DIR}/config/openstack.creds ]; then
+ # If credentials file is not given, check if environment variables are set
+ # to get the creds using fetch_os_creds.sh later on
+ info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
+ if [ -z ${INSTALLER_TYPE} ]; then
+ error "Environment variable 'INSTALLER_TYPE' is not defined."
+ elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
+ info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
+ else
+ error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
+ fi
+
+ if [ -z ${INSTALLER_IP} ]; then
+ error "Environment variable 'INSTALLER_IP' is not defined."
+ fi
+ info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
+fi
+
+# Create Openstack credentials file
+# $creds is an env varialbe in the docker container pointing to
+# /home/opnfv/bottlenecks/config/openstack.creds
+if [ ! -f ${creds} ]; then
+ ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \
+ -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
+ retval=$?
+ if [ $retval != 0 ]; then
+ error "Cannot retrieve credentials file from installation. Check logs."
+ exit $retval
+ fi
+else
+ info "OpenStack credentials file given to the docker"
+fi
+
+# If we use SSL, by default use option OS_INSECURE=true which means that
+# the cacert will be self-signed
+if grep -Fq "OS_CACERT" ${creds}; then
+ echo "OS_INSECURE=true">>${creds};
+fi
+
+# Source credentials
+source ${creds}
diff --git a/common.sh b/common.sh
index 16966320..15cf2ecb 100755
--- a/common.sh
+++ b/common.sh
@@ -12,7 +12,7 @@ mkdir -p /home/opnfv/bottlenecks/config
config_file=/home/opnfv/bottlenecks/config/bottlenecks_cfg.yaml
if [ ! -f ${config_file} ]; then
- default_config_file=$(find /home/opnfv/repos -name bottlenecks_cfg.yaml)
+ default_config_file=$(find /home/opnfv -name bottlenecks_cfg.yaml)
cp $default_config_file $config_file
echo "bottlenecks_cfg.yaml not provided. Using default one"
fi